diff options
author | Anthony Green <green@gcc.gnu.org> | 2004-07-04 02:12:58 +0000 |
---|---|---|
committer | Anthony Green <green@gcc.gnu.org> | 2004-07-04 02:12:58 +0000 |
commit | 94fbf267f3f84e280684ec60b2303d9c7052997f (patch) | |
tree | b1450648aff58eca57b555278c227fabb642cb7f /libjava | |
parent | 61b35a3e46c5a3675de41ce9af72cb30a12e6594 (diff) | |
download | gcc-94fbf267f3f84e280684ec60b2303d9c7052997f.zip gcc-94fbf267f3f84e280684ec60b2303d9c7052997f.tar.gz gcc-94fbf267f3f84e280684ec60b2303d9c7052997f.tar.bz2 |
[multiple changes]
2004-07-03 Mark Wielaard <mark@klomp.org>
Anthony Green <green@redhat.com>
* java/net/URL.java (getFile): Clarify return value doc.
(getPath): Return null if file is empty - not empty String.
(set): Convert protocol to lower case before doing anything.
Only change the protocol handler if it's different.
2004-07-03 Anthony Green <green@redhat.com>
* java/net/URL.java (URL): Convert protocol to lower case before
doing anything, so we getURLStreamHandler() with the proper value.
From-SVN: r84068
Diffstat (limited to 'libjava')
-rw-r--r-- | libjava/ChangeLog | 13 | ||||
-rw-r--r-- | libjava/java/net/URL.java | 27 |
2 files changed, 32 insertions, 8 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog index d99f402..edf90fb 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,16 @@ +2004-07-03 Mark Wielaard <mark@klomp.org> + Anthony Green <green@redhat.com> + + * java/net/URL.java (getFile): Clarify return value doc. + (getPath): Return null if file is empty - not empty String. + (set): Convert protocol to lower case before doing anything. + Only change the protocol handler if it's different. + +2004-07-03 Anthony Green <green@redhat.com> + + * java/net/URL.java (URL): Convert protocol to lower case before + doing anything, so we getURLStreamHandler() with the proper value. + 2004-07-02 Bryce McKinlay <mckinlay@redhat.com> * java/util/Locale.java (hashcode): Made transient. diff --git a/libjava/java/net/URL.java b/libjava/java/net/URL.java index 623f660..7357c75 100644 --- a/libjava/java/net/URL.java +++ b/libjava/java/net/URL.java @@ -262,7 +262,8 @@ public final class URL implements Serializable { if (protocol == null) throw new MalformedURLException("null protocol"); - this.protocol = protocol.toLowerCase(); + protocol = protocol.toLowerCase(); + this.protocol = protocol; if (ph != null) { @@ -512,7 +513,7 @@ public final class URL implements Serializable * Defined as <code>path[?query]</code>. * Returns the empty string if there is no file portion. * - * @return The filename specified in this URL. + * @return The filename specified in this URL, or an empty string if empty. */ public String getFile() { @@ -523,13 +524,15 @@ public final class URL implements Serializable * Returns the path of the URL. This is the part of the file before any '?' * character. * - * @return The path specified in this URL. + * @return The path specified in this URL, or null if empty. * * @since 1.3 */ public String getPath() { - int quest = (file == null) ? -1 : file.indexOf('?'); + if (file == null) + return null; + int quest = file.indexOf('?'); return quest < 0 ? getFile() : file.substring(0, quest); } @@ -699,8 +702,12 @@ public final class URL implements Serializable // invalid protocol. It will cause the handler to be set to null // thus overriding a valid handler. Callers of this method should // be aware of this. - this.ph = getURLStreamHandler(protocol); - this.protocol = protocol.toLowerCase(); + protocol = protocol.toLowerCase (); + if (! this.protocol.equals (protocol)) + { + this.ph = getURLStreamHandler(protocol); + this.protocol = protocol; + } this.authority = ""; this.port = port; this.host = host; @@ -738,8 +745,12 @@ public final class URL implements Serializable // invalid protocol. It will cause the handler to be set to null // thus overriding a valid handler. Callers of this method should // be aware of this. - this.ph = getURLStreamHandler(protocol); - this.protocol = protocol.toLowerCase(); + protocol = protocol.toLowerCase (); + if (! this.protocol.equals (protocol)) + { + this.ph = getURLStreamHandler(protocol); + this.protocol = protocol; + } this.host = host; this.userInfo = userInfo; this.port = port; |