From f1f90ae0dee37c133fb46ed973c1eddfcea023fa Mon Sep 17 00:00:00 2001 From: Bryce McKinlay Date: Fri, 23 Jul 2004 01:21:40 +0000 Subject: Makefile.am (ordinary_java_source_files): Add DefaultContentHandlerFactory.java. 2004-07-22 Bryce McKinlay * Makefile.am (ordinary_java_source_files): Add DefaultContentHandlerFactory.java. * Makefile.in: Rebuilt. * java/net/URLConnection.java (defaultFactory): New field. (getContent): (getContentHandler): Renamed from 'setContentHandler'. Try defaultFactory after user-set factory, if any. Search for content handler implementations in gnu.java.net.content, not gnu.gcj.content. * gnu/java/net/protocol/file/Connection.java (getHeaderField): Implemented. (getLastModified): Implemented. (getPermission): Create file permission here, instead of in constructor. * gnu/java/net/protocol/gcjlib/Connection.java (getHeaderField): Implemented. * gnu/java/net/protocol/jar/Connection.java (getHeaderField): Implemented. (getLastModified): Implemented. * gnu/java/awt/ClasspathToolkit.java (createImageProducer): New. Default implementation. * gnu/java/awt/peer/gtk/GtkToolkit.java (createImageProducer): New. Implement using GdkPixbufDecoder. From-SVN: r85069 --- libjava/java/net/URLConnection.java | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'libjava/java/net') diff --git a/libjava/java/net/URLConnection.java b/libjava/java/net/URLConnection.java index 7b5f6a5..4bf52b8 100644 --- a/libjava/java/net/URLConnection.java +++ b/libjava/java/net/URLConnection.java @@ -116,6 +116,9 @@ public abstract class URLConnection */ private static boolean defaultUseCaches = true; + private static ContentHandlerFactory defaultFactory + = new gnu.java.net.DefaultContentHandlerFactory(); + /** * This variable determines whether or not interaction is allowed with * the user. For example, to prompt for a username and password. @@ -436,7 +439,7 @@ public abstract class URLConnection // guessContentTypeFromName() and guessContentTypeFromStream methods // as well as FileNameMap class & fileNameMap field & get/set methods. String type = getContentType(); - ContentHandler ch = setContentHandler(type); + ContentHandler ch = getContentHandler(type); if (ch == null) return getInputStream(); @@ -963,7 +966,7 @@ public abstract class URLConnection fileNameMap = map; } - private ContentHandler setContentHandler(String contentType) + private ContentHandler getContentHandler(String contentType) { ContentHandler handler; @@ -981,12 +984,17 @@ public abstract class URLConnection else return null; - // If a non-default factory has been set, use it to find the content type. + // If a non-default factory has been set, use it. if (factory != null) handler = factory.createContentHandler(contentType); - // Non-default factory may have returned null or a factory wasn't set. - // Use the default search algorithm to find a handler for this content type. + // Now try default factory. Using this factory to instantiate built-in + // content handlers is preferable + if (handler == null) + handler = defaultFactory.createContentHandler(contentType); + + // User-set factory has not returned a handler. Use the default search + // algorithm. if (handler == null) { // Get the list of packages to check and append our default handler @@ -995,7 +1003,7 @@ public abstract class URLConnection // ever be needed (or available). String propVal = System.getProperty("java.content.handler.pkgs"); propVal = (propVal == null) ? "" : (propVal + "|"); - propVal = propVal + "gnu.gcj.content|sun.net.www.content"; + propVal = propVal + "gnu.java.net.content|sun.net.www.content"; // Replace the '/' character in the content type with '.' and // all other non-alphabetic, non-numeric characters with '_'. -- cgit v1.1