aboutsummaryrefslogtreecommitdiff
path: root/libjava/java
diff options
context:
space:
mode:
authorAnthony Green <green@cygnus.com>1999-07-05 13:35:21 +0000
committerAnthony Green <green@gcc.gnu.org>1999-07-05 13:35:21 +0000
commitc704c83cbd4edda438c056fcd2c9f27eeb2497fc (patch)
tree55d01fcc3072c77eb98a8cd5ef64451f2ed1c8c9 /libjava/java
parent9d59f3071fe2cfa08960063b0d1c78f86d4b5e0e (diff)
downloadgcc-c704c83cbd4edda438c056fcd2c9f27eeb2497fc.zip
gcc-c704c83cbd4edda438c056fcd2c9f27eeb2497fc.tar.gz
gcc-c704c83cbd4edda438c056fcd2c9f27eeb2497fc.tar.bz2
URL.java (equals): Compare strings using String.equals.
* java/net/URL.java (equals): Compare strings using String.equals. * java/net/URL.java (sameFile): Ditto. From-SVN: r27947
Diffstat (limited to 'libjava/java')
-rw-r--r--libjava/java/net/URL.java32
1 files changed, 22 insertions, 10 deletions
diff --git a/libjava/java/net/URL.java b/libjava/java/net/URL.java
index b6dc13d..d2f0bc2 100644
--- a/libjava/java/net/URL.java
+++ b/libjava/java/net/URL.java
@@ -189,11 +189,18 @@ public final class URL implements Serializable
return false;
URL uObj = (URL) obj;
- if (protocol != uObj.protocol || host != uObj.host || port != uObj.port ||
- file != uObj.file || ref != uObj.ref)
- return false;
-
- return true;
+
+ // This comparison is very conservative. It assumes that any
+ // field can be null.
+ return (port == uObj.port
+ && ((protocol == null && uObj.protocol == null)
+ || (protocol != null && protocol.equals(uObj.protocol)))
+ && ((host == null && uObj.host == null)
+ || (host != null && host.equals(uObj.host)))
+ && ((file == null && uObj.file == null)
+ || (file != null && file.equals(uObj.file)))
+ && ((ref == null && uObj.ref == null)
+ || (ref != null && ref.equals(uObj.ref))));
}
public final Object getContent() throws IOException
@@ -258,11 +265,16 @@ public final class URL implements Serializable
public boolean sameFile(URL other)
{
- if (other == null || protocol != other.protocol || host != other.host ||
- port != other.port || file != other.file)
- return false;
-
- return true;
+ // This comparison is very conservative. It assumes that any
+ // field can be null.
+ return (other != null
+ && port == other.port
+ && ((protocol == null && other.protocol == null)
+ || (protocol != null && protocol.equals(other.protocol)))
+ && ((host == null && other.host == null)
+ || (host != null && host.equals(other.host)))
+ && ((file == null && other.file == null)
+ || (file != null && file.equals(other.file))));
}
protected void set(String protocol, String host, int port, String file,