Commit e9d34968 by Michael Koch Committed by Michael Koch

2004-04-23 Michael Koch <konqueror@gmx.de>

	* java/net/URL.java
	(hashcode): Don't initialize with default value explicitely.
	(getContent): Removed redundant "final" keyword.
	(openStream): Likewise.
	(getURLStreamHandler): Fixed coding style.
	* java/net/URLConnection.java
	(defaultAllowUserInteraction): Don't initialize with default value
	explicitely.
	(connected): Likewise.
	(doOutput): Likewise.
	(ifModifiedSince): Likewise.
	(dateformats_initialized): Likewise.
	(setURLStreamHander): Use StreamTokenizer where it belongs to.

From-SVN: r81080
parent 87939d70
2004-04-23 Michael Koch <konqueror@gmx.de> 2004-04-23 Michael Koch <konqueror@gmx.de>
* java/net/URL.java
(hashcode): Don't initialize with default value explicitely.
(getContent): Removed redundant "final" keyword.
(openStream): Likewise.
(getURLStreamHandler): Fixed coding style.
* java/net/URLConnection.java
(defaultAllowUserInteraction): Don't initialize with default value
explicitely.
(connected): Likewise.
(doOutput): Likewise.
(ifModifiedSince): Likewise.
(dateformats_initialized): Likewise.
(setURLStreamHander): Use StreamTokenizer where it belongs to.
2004-04-23 Michael Koch <konqueror@gmx.de>
* gnu/java/nio/channels/FileChannelImpl.java * gnu/java/nio/channels/FileChannelImpl.java
(SET, CUR): Unused, removed. (SET, CUR): Unused, removed.
(read): Implement here directly. (read): Implement here directly.
......
...@@ -141,6 +141,11 @@ public final class URL implements Serializable ...@@ -141,6 +141,11 @@ public final class URL implements Serializable
private String host; private String host;
/** /**
* The user information necessary to establish the connection.
*/
private String userInfo;
/**
* The port number of this protocol or -1 if the port number used is * The port number of this protocol or -1 if the port number used is
* the default for this protocol. * the default for this protocol.
*/ */
...@@ -159,7 +164,7 @@ public final class URL implements Serializable ...@@ -159,7 +164,7 @@ public final class URL implements Serializable
/** /**
* This is the hashCode for this URL * This is the hashCode for this URL
*/ */
private int hashCode = 0; private int hashCode;
/** /**
* The protocol handler in use for this URL * The protocol handler in use for this URL
...@@ -276,7 +281,9 @@ public final class URL implements Serializable ...@@ -276,7 +281,9 @@ public final class URL implements Serializable
this.host = host; this.host = host;
this.port = port; this.port = port;
this.authority = null; this.authority = (host != null) ? host : "";
if (port >= 0)
this.authority += ":" + port;
int hashAt = file.indexOf('#'); int hashAt = file.indexOf('#');
if (hashAt < 0) if (hashAt < 0)
...@@ -480,7 +487,7 @@ public final class URL implements Serializable ...@@ -480,7 +487,7 @@ public final class URL implements Serializable
* *
* @since 1.3 * @since 1.3
*/ */
public final Object getContent() throws IOException public Object getContent() throws IOException
{ {
return openConnection().getContent(); return openConnection().getContent();
} }
...@@ -494,7 +501,7 @@ public final class URL implements Serializable ...@@ -494,7 +501,7 @@ public final class URL implements Serializable
* *
* @exception IOException If an error occurs * @exception IOException If an error occurs
*/ */
public final Object getContent (Class[] classes) throws IOException public Object getContent(Class[] classes) throws IOException
{ {
// FIXME: implement this // FIXME: implement this
return getContent(); return getContent();
...@@ -653,7 +660,7 @@ public final class URL implements Serializable ...@@ -653,7 +660,7 @@ public final class URL implements Serializable
* *
* @exception IOException If an error occurs * @exception IOException If an error occurs
*/ */
public final InputStream openStream() throws IOException public InputStream openStream() throws IOException
{ {
return openConnection().getInputStream(); return openConnection().getInputStream();
} }
...@@ -694,11 +701,17 @@ public final class URL implements Serializable ...@@ -694,11 +701,17 @@ public final class URL implements Serializable
// be aware of this. // be aware of this.
this.ph = getURLStreamHandler(protocol); this.ph = getURLStreamHandler(protocol);
this.protocol = protocol.toLowerCase(); this.protocol = protocol.toLowerCase();
this.authority = null; this.authority = "";
this.port = port; this.port = port;
this.host = host; this.host = host;
this.file = file; this.file = file;
this.ref = ref; this.ref = ref;
if (host != null)
this.authority += host;
if (port >= 0)
this.authority += ":" + port;
hashCode = hashCode(); // Used for serialization. hashCode = hashCode(); // Used for serialization.
} }
...@@ -727,15 +740,15 @@ public final class URL implements Serializable ...@@ -727,15 +740,15 @@ public final class URL implements Serializable
// be aware of this. // be aware of this.
this.ph = getURLStreamHandler(protocol); this.ph = getURLStreamHandler(protocol);
this.protocol = protocol.toLowerCase(); this.protocol = protocol.toLowerCase();
if (userInfo == null) this.host = host;
this.host = host; this.userInfo = userInfo;
else
this.host = userInfo + "@" + host;
this.port = port; this.port = port;
this.file = path;
this.authority = authority;
if (query == null) if (query == null)
this.file = path; this.file = file;
else else
this.file = path + "?" + query; this.file = file + "?" + query;
this.ref = ref; this.ref = ref;
hashCode = hashCode(); // Used for serialization. hashCode = hashCode(); // Used for serialization.
} }
...@@ -811,13 +824,13 @@ public final class URL implements Serializable ...@@ -811,13 +824,13 @@ public final class URL implements Serializable
// If a non-default factory has been set, use it to find the protocol. // If a non-default factory has been set, use it to find the protocol.
if (factory != null) if (factory != null)
{ {
ph = factory.createURLStreamHandler (protocol); ph = factory.createURLStreamHandler(protocol);
} }
else if (protocol.equals ("core")) else if (protocol.equals("core"))
{ {
ph = new gnu.java.net.protocol.core.Handler(); ph = new gnu.java.net.protocol.core.Handler();
} }
else if (protocol.equals ("file")) else if (protocol.equals("file"))
{ {
// This is an interesting case. It's tempting to think that we // This is an interesting case. It's tempting to think that we
// could call Class.forName ("gnu.java.net.protocol.file.Handler") to // could call Class.forName ("gnu.java.net.protocol.file.Handler") to
......
...@@ -432,10 +432,10 @@ public abstract class URLConnection ...@@ -432,10 +432,10 @@ public abstract class URLConnection
String type = getContentType(); String type = getContentType();
ContentHandler ch = setContentHandler(type); ContentHandler ch = setContentHandler(type);
if (ch != null) if (ch == null)
return ch.getContent(this); return getInputStream();
return getInputStream(); return ch.getContent(this);
} }
/** /**
...@@ -993,7 +993,6 @@ public abstract class URLConnection ...@@ -993,7 +993,6 @@ public abstract class URLConnection
// Replace the '/' character in the content type with '.' and // Replace the '/' character in the content type with '.' and
// all other non-alphabetic, non-numeric characters with '_'. // all other non-alphabetic, non-numeric characters with '_'.
StringTokenizer pkgPrefix = new StringTokenizer(propVal, "|");
char[] cArray = contentType.toCharArray(); char[] cArray = contentType.toCharArray();
for (int i = 0; i < cArray.length; i++) for (int i = 0; i < cArray.length; i++)
{ {
...@@ -1007,6 +1006,7 @@ public abstract class URLConnection ...@@ -1007,6 +1006,7 @@ public abstract class URLConnection
String contentClass = new String(cArray); String contentClass = new String(cArray);
// See if a class of this content type exists in any of the packages. // See if a class of this content type exists in any of the packages.
StringTokenizer pkgPrefix = new StringTokenizer(propVal, "|");
do do
{ {
String facName = pkgPrefix.nextToken() + "." + contentClass; String facName = pkgPrefix.nextToken() + "." + contentClass;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment