Commit c704c83c by Anthony Green Committed by Anthony Green

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
parent 9d59f307
Mon Jul 5 12:01:35 1999 Anthony Green <green@cygnus.com>
* java/net/URL.java (equals): Compare strings using String.equals.
* java/net/URL.java (sameFile): Ditto.
1999-07-02 Warren Levy <warrenl@cygnus.com> 1999-07-02 Warren Levy <warrenl@cygnus.com>
* configure: Rebuilt. * configure: Rebuilt.
......
...@@ -189,11 +189,18 @@ public final class URL implements Serializable ...@@ -189,11 +189,18 @@ public final class URL implements Serializable
return false; return false;
URL uObj = (URL) obj; URL uObj = (URL) obj;
if (protocol != uObj.protocol || host != uObj.host || port != uObj.port ||
file != uObj.file || ref != uObj.ref) // This comparison is very conservative. It assumes that any
return false; // field can be null.
return (port == uObj.port
return true; && ((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 public final Object getContent() throws IOException
...@@ -258,11 +265,16 @@ public final class URL implements Serializable ...@@ -258,11 +265,16 @@ public final class URL implements Serializable
public boolean sameFile(URL other) public boolean sameFile(URL other)
{ {
if (other == null || protocol != other.protocol || host != other.host || // This comparison is very conservative. It assumes that any
port != other.port || file != other.file) // field can be null.
return false; return (other != null
&& port == other.port
return true; && ((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, protected void set(String protocol, String host, int port, String file,
......
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