This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FYI: Patch: java.net.URLConnection


Hi list,


I commited the attached patch as obvious as it contains little fixes to 
java.net.URLConnection. This makes it more merged with classpath too.


Michael


2004-01-06  Michael Koch  <konqueror@gmx.de>

	* java/net/URLConnection.java
	(contentHandler): Removed.
	(locale): Removed.
	(getHeaderFields): Return an empty map instead of null.
	(getContent): Connect if needed, renamed "cType" to "type" and
	"contentHandler" to "ch" and made it a local variable.
	(getPermission): Don't use package in class name.
	(setDefaultRequestProperty): Fixed typo in documentation.
	(initializeDateFormats): Made locale a local variable.

Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/libjava/ChangeLog,v
retrieving revision 1.2515
diff -u -b -B -r1.2515 ChangeLog
--- ChangeLog	6 Jan 2004 08:34:56 -0000	1.2515
+++ ChangeLog	6 Jan 2004 08:52:55 -0000
@@ -1,5 +1,17 @@
 2004-01-06  Michael Koch  <konqueror@gmx.de>
 
+	* java/net/URLConnection.java
+	(contentHandler): Removed.
+	(locale): Removed.
+	(getHeaderFields): Return an empty map instead of null.
+	(getContent): Connect if needed, renamed "cType" to "type" and
+	"contentHandler" to "ch" and made it a local variable.
+	(getPermission): Don't use package in class name.
+	(setDefaultRequestProperty): Fixed typo in documentation.
+	(initializeDateFormats): Made locale a local variable.
+
+2004-01-06  Michael Koch  <konqueror@gmx.de>
+
 	* java/lang/Package.java
 	(getPackage): Get the current class loader directly.
 	* java/lang/SecurityManager.java
Index: java/net/URLConnection.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/URLConnection.java,v
retrieving revision 1.25
diff -u -b -B -r1.25 URLConnection.java
--- java/net/URLConnection.java	13 Oct 2003 05:34:53 -0000	1.25
+++ java/net/URLConnection.java	6 Jan 2004 08:52:55 -0000
@@ -41,8 +41,8 @@
 import java.io.InputStream;
 import java.io.IOException;
 import java.io.OutputStream;
-import java.security.Permission;
 import java.security.AllPermission;
+import java.security.Permission;
 import java.text.ParsePosition;
 import java.text.SimpleDateFormat;
 import java.util.Collections;
@@ -165,9 +165,7 @@
    */
   protected URL url;
 
-  private static ContentHandler contentHandler;
   private static Hashtable handlers = new Hashtable();
-  private static Locale locale; 
   private static SimpleDateFormat dateFormat1, dateFormat2, dateFormat3;
   private static boolean dateformats_initialized = false;
 
@@ -315,7 +313,7 @@
   public Map getHeaderFields()
   {
     // Subclasses for specific protocols override this.
-    return null;
+    return Collections.EMPTY_MAP;
   }
 
   /**
@@ -419,16 +417,20 @@
    */
   public Object getContent() throws IOException
   {
+    if (!connected)
+      connect();
+
     // FIXME: Doc indicates that other criteria should be applied as
     // heuristics to determine the true content type, e.g. see 
     // guessContentTypeFromName() and guessContentTypeFromStream methods
     // as well as FileNameMap class & fileNameMap field & get/set methods.
-    String cType = getContentType();
-    contentHandler = setContentHandler(cType);
-    if (contentHandler == null)
+    String type = getContentType();
+    ContentHandler ch = setContentHandler(type);
+
+    if (ch == null)
       return getInputStream();
 
-    return contentHandler.getContent(this);
+    return ch.getContent(this);
   }
 
   /**
@@ -463,7 +465,7 @@
   public Permission getPermission() throws IOException
   {
     // Subclasses may override this.
-    return new java.security.AllPermission();
+    return new AllPermission();
   }
 
   /**
@@ -803,7 +805,7 @@
    * @deprecated 1.3 The method setRequestProperty should be used instead.
    * This method does nothing now.
    *
-   * @see URLConnectionr#setRequestProperty(String key, String value)
+   * @see URLConnection#setRequestProperty(String key, String value)
    */
   public static void setDefaultRequestProperty (String key, String value)
   {
@@ -1036,7 +1038,8 @@
   {
     if (dateformats_initialized)
       return;
-    locale = new Locale("En", "Us", "Unix");
+
+    Locale locale = new Locale("En", "Us", "Unix");
     dateFormat1 = new SimpleDateFormat("EEE, dd MMM yyyy hh:mm:ss 'GMT'", 
                                        locale);
     dateFormat2 = new SimpleDateFormat("EEEE, dd-MMM-yy hh:mm:ss 'GMT'", 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]