You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by te...@apache.org on 2007/01/05 15:44:06 UTC

svn commit: r493040 [11/11] - in /harmony/enhanced/classlib/trunk/modules/luni/src/main/java: java/net/ org/apache/harmony/luni/util/

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLStreamHandler.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLStreamHandler.java?view=diff&rev=493040&r1=493039&r2=493040
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLStreamHandler.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLStreamHandler.java Fri Jan  5 06:44:04 2007
@@ -17,7 +17,6 @@
 
 package java.net;
 
-
 import java.io.IOException;
 
 import org.apache.harmony.luni.util.Msg;
@@ -26,67 +25,68 @@
  * The abstract superclass of all classes that implement Protocol Handler.
  */
 public abstract class URLStreamHandler {
-	/**
-	 * Establishes a connection to the resource specified by <code>URL</code>.
-	 * Since different protocols may have unique ways of connecting, it must be
-	 * overwritten by the subclass.
-	 * 
-	 * @return java.net.URLConnection
-	 * @param u
-	 *            java.net.URL
-	 * 
-	 * @exception IOException
-	 *                thrown if an IO error occurs during connection
-	 *                establishment
-	 */
-	protected abstract URLConnection openConnection(URL u) throws IOException;
-	
-	/**
-	 * The method is the same as <code>openConnection(URL u)</code> except 
-	 * that it uses the <code>proxy</code> to establish a connection to the 
-	 * <code>URL</code>. Since different protocols may have different ways of
-	 * connecting, it must be overwritten by the subclass.
-	 * 
-	 * @return java.net.URLConnection
-	 * @param u
-	 *            java.net.URL
-	 * @param proxy
-	 *            the proxy which is used to make the connection
-	 * 
-	 * @throws IOException
-	 *                thrown if an IO error occurs during connection
-	 *                establishment
-	 * @throws IllegalArgumentException
-	 *             if any argument is null or the type of proxy is wrong.
-	 * @throws UnsupportedOperationException
-	 *             if the protocol handler doesn't support this method.
-	 */
-	protected URLConnection openConnection(URL u, Proxy proxy) throws IOException{
-		throw new UnsupportedOperationException(Msg.getString("K034d"));
-	}
-
-	/**
-	 * Parse the <code>string</code>str into <code>URL</code> using u's
-	 * context. URL strings generally have the following format:
-	 * <code><center>//www.company.com/java/file1.java#reference </center></code>
-	 * The string is parsed in HTTP format. If the protocol has a different URL
-	 * format this method must be overridden.
-	 * 
-	 * @param u
-	 *            java.net.URL The URL to receive parsed values.
-	 * @param str
-	 *            java.lang.String The string URL spec from which u is derived
-	 * @param start
-	 *            int The index in the string from which to begin parsing
-	 * @param end
-	 *            int The index to stop parsing
-	 * 
-	 * @see #toExternalForm
-	 * @see URL
-	 */
-	protected void parseURL(URL u, String str, int start, int end) {
+    /**
+     * Establishes a connection to the resource specified by <code>URL</code>.
+     * Since different protocols may have unique ways of connecting, it must be
+     * overwritten by the subclass.
+     * 
+     * @return java.net.URLConnection
+     * @param u
+     *            java.net.URL
+     * 
+     * @exception IOException
+     *                thrown if an IO error occurs during connection
+     *                establishment
+     */
+    protected abstract URLConnection openConnection(URL u) throws IOException;
+
+    /**
+     * The method is the same as <code>openConnection(URL u)</code> except
+     * that it uses the <code>proxy</code> to establish a connection to the
+     * <code>URL</code>. Since different protocols may have different ways of
+     * connecting, it must be overwritten by the subclass.
+     * 
+     * @return java.net.URLConnection
+     * @param u
+     *            java.net.URL
+     * @param proxy
+     *            the proxy which is used to make the connection
+     * 
+     * @throws IOException
+     *             thrown if an IO error occurs during connection establishment
+     * @throws IllegalArgumentException
+     *             if any argument is null or the type of proxy is wrong.
+     * @throws UnsupportedOperationException
+     *             if the protocol handler doesn't support this method.
+     */
+    protected URLConnection openConnection(URL u, Proxy proxy)
+            throws IOException {
+        throw new UnsupportedOperationException(Msg.getString("K034d")); //$NON-NLS-1$
+    }
+
+    /**
+     * Parse the <code>string</code>str into <code>URL</code> using u's
+     * context. URL strings generally have the following format:
+     * <code><center>//www.company.com/java/file1.java#reference </center></code>
+     * The string is parsed in HTTP format. If the protocol has a different URL
+     * format this method must be overridden.
+     * 
+     * @param u
+     *            java.net.URL The URL to receive parsed values.
+     * @param str
+     *            java.lang.String The string URL spec from which u is derived
+     * @param start
+     *            int The index in the string from which to begin parsing
+     * @param end
+     *            int The index to stop parsing
+     * 
+     * @see #toExternalForm
+     * @see URL
+     */
+    protected void parseURL(URL u, String str, int start, int end) {
         // For compatibility, refer to Harmony-2941
-        if (str.startsWith("//", start) && str.indexOf('/', start + 2) == -1
+        if (str.startsWith("//", start) //$NON-NLS-1$
+                && str.indexOf('/', start + 2) == -1
                 && end <= Integer.MIN_VALUE + 1) {
             throw new StringIndexOutOfBoundsException(end - 2 - start);
         }
@@ -96,95 +96,95 @@
             }
             return;
         }
-		String parseString = "";
-		if (start < end) {
+        String parseString = ""; //$NON-NLS-1$
+        if (start < end) {
             parseString = str.substring(start, end);
         }
-		end -= start;
-		int fileIdx = 0;
+        end -= start;
+        int fileIdx = 0;
 
-		// Default is to use info from context
-		String host = u.getHost();
-		int port = u.getPort();
-		String ref = u.getRef();
-		String file = u.getPath();
-		String query = u.getQuery();
-		String authority = u.getAuthority();
-		String userInfo = u.getUserInfo();
-
-		int refIdx = parseString.indexOf('#', 0);
-		if (parseString.startsWith("//")) {
-			int hostIdx = 2, portIdx = -1;
-			port = -1;
-			fileIdx = parseString.indexOf('/', hostIdx);
+        // Default is to use info from context
+        String host = u.getHost();
+        int port = u.getPort();
+        String ref = u.getRef();
+        String file = u.getPath();
+        String query = u.getQuery();
+        String authority = u.getAuthority();
+        String userInfo = u.getUserInfo();
+
+        int refIdx = parseString.indexOf('#', 0);
+        if (parseString.startsWith("//")) { //$NON-NLS-1$
+            int hostIdx = 2, portIdx = -1;
+            port = -1;
+            fileIdx = parseString.indexOf('/', hostIdx);
             int questionMarkIndex = parseString.indexOf('?', hostIdx);
             if ((questionMarkIndex != -1)
                     && ((fileIdx == -1) || (fileIdx > questionMarkIndex))) {
                 fileIdx = questionMarkIndex;
             }
-			if (fileIdx == -1) {
-				fileIdx = end;
-				// Use default
-				file = "";
-			}
-			int hostEnd = fileIdx;
-			if (refIdx != -1 && refIdx < fileIdx) {
+            if (fileIdx == -1) {
+                fileIdx = end;
+                // Use default
+                file = ""; //$NON-NLS-1$
+            }
+            int hostEnd = fileIdx;
+            if (refIdx != -1 && refIdx < fileIdx) {
                 hostEnd = refIdx;
             }
-			int userIdx = parseString.lastIndexOf('@', hostEnd);
-			authority = parseString.substring(hostIdx, hostEnd);
-			if (userIdx > -1) {
-				userInfo = parseString.substring(hostIdx, userIdx);
-				hostIdx = userIdx + 1;
-			}
-
-			portIdx = parseString.indexOf(':', userIdx == -1 ? hostIdx
-					: userIdx);
-			int endOfIPv6Addr = parseString.indexOf(']');
-			// if there are square braces, ie. IPv6 address, use last ':'
-			if (endOfIPv6Addr != -1) {
-				try {
-					if (parseString.length() > endOfIPv6Addr + 1) {
-						char c = parseString.charAt(endOfIPv6Addr + 1);
-						if (c == ':') {
-							portIdx = endOfIPv6Addr + 1;
-						} else {
-							portIdx = -1;
-						}
-					} else {
-						portIdx = -1;
-					}
-				} catch (Exception e) {
-					// Ignored
-				}
-			}
+            int userIdx = parseString.lastIndexOf('@', hostEnd);
+            authority = parseString.substring(hostIdx, hostEnd);
+            if (userIdx > -1) {
+                userInfo = parseString.substring(hostIdx, userIdx);
+                hostIdx = userIdx + 1;
+            }
+
+            portIdx = parseString.indexOf(':', userIdx == -1 ? hostIdx
+                    : userIdx);
+            int endOfIPv6Addr = parseString.indexOf(']');
+            // if there are square braces, ie. IPv6 address, use last ':'
+            if (endOfIPv6Addr != -1) {
+                try {
+                    if (parseString.length() > endOfIPv6Addr + 1) {
+                        char c = parseString.charAt(endOfIPv6Addr + 1);
+                        if (c == ':') {
+                            portIdx = endOfIPv6Addr + 1;
+                        } else {
+                            portIdx = -1;
+                        }
+                    } else {
+                        portIdx = -1;
+                    }
+                } catch (Exception e) {
+                    // Ignored
+                }
+            }
 
-			if (portIdx == -1 || portIdx > fileIdx) {
+            if (portIdx == -1 || portIdx > fileIdx) {
                 host = parseString.substring(hostIdx, hostEnd);
             } else {
-				host = parseString.substring(hostIdx, portIdx);
-				String portString = parseString.substring(portIdx + 1, hostEnd);
-				if (portString.length() == 0) {
+                host = parseString.substring(hostIdx, portIdx);
+                String portString = parseString.substring(portIdx + 1, hostEnd);
+                if (portString.length() == 0) {
                     port = -1;
                 } else {
                     port = Integer.parseInt(portString);
                 }
-			}
-		}
+            }
+        }
 
-		if (refIdx > -1) {
+        if (refIdx > -1) {
             ref = parseString.substring(refIdx + 1, end);
         }
-		int fileEnd = (refIdx == -1 ? end : refIdx);
+        int fileEnd = (refIdx == -1 ? end : refIdx);
 
-		int queryIdx = parseString.lastIndexOf('?', fileEnd);
+        int queryIdx = parseString.lastIndexOf('?', fileEnd);
         boolean canonicalize = false;
         if (queryIdx > -1) {
             query = parseString.substring(queryIdx + 1, fileEnd);
             if (queryIdx == 0 && file != null) {
-                if (file.equals("")) {
-                    file = "/";
-                } else if (file.startsWith("/")) {
+                if (file.equals("")) { //$NON-NLS-1$
+                    file = "/"; //$NON-NLS-1$
+                } else if (file.startsWith("/")) { //$NON-NLS-1$
                     canonicalize = true;
                 }
                 int last = file.lastIndexOf('/') + 1;
@@ -197,224 +197,224 @@
             query = null;
         }
 
-		if (fileIdx > -1) {
-			if (fileIdx < end && parseString.charAt(fileIdx) == '/') {
+        if (fileIdx > -1) {
+            if (fileIdx < end && parseString.charAt(fileIdx) == '/') {
                 file = parseString.substring(fileIdx, fileEnd);
             } else if (fileEnd > fileIdx) {
-				if (file == null) {
-                    file = "";
-                } else if (file.equals("")) {
-                    file = "/";
-                } else if (file.startsWith("/")) {
+                if (file == null) {
+                    file = ""; //$NON-NLS-1$
+                } else if (file.equals("")) { //$NON-NLS-1$
+                    file = "/"; //$NON-NLS-1$
+                } else if (file.startsWith("/")) { //$NON-NLS-1$
                     canonicalize = true;
                 }
-				int last = file.lastIndexOf('/') + 1;
-				if (last == 0) {
+                int last = file.lastIndexOf('/') + 1;
+                if (last == 0) {
                     file = parseString.substring(fileIdx, fileEnd);
                 } else {
                     file = file.substring(0, last)
-							+ parseString.substring(fileIdx, fileEnd);
+                            + parseString.substring(fileIdx, fileEnd);
                 }
-			}
-		}
-		if (file == null) {
-            file = "";
+            }
+        }
+        if (file == null) {
+            file = ""; //$NON-NLS-1$
         }
 
-		if (host == null) {
-            host = "";
+        if (host == null) {
+            host = ""; //$NON-NLS-1$
         }
 
-		if (canonicalize) {
-			// modify file if there's any relative referencing
-			int dirIndex;
-			while ((dirIndex = file.indexOf("/./")) >= 0) {
+        if (canonicalize) {
+            // modify file if there's any relative referencing
+            int dirIndex;
+            while ((dirIndex = file.indexOf("/./")) >= 0) { //$NON-NLS-1$
                 file = file.substring(0, dirIndex + 1)
-						+ file.substring(dirIndex + 3);
+                        + file.substring(dirIndex + 3);
             }
-			if (file.endsWith("/.")) {
+            if (file.endsWith("/.")) { //$NON-NLS-1$
                 file = file.substring(0, file.length() - 1);
             }
-			while ((dirIndex = file.indexOf("/../")) >= 0) {
-				if (dirIndex != 0) {
-					file = file.substring(0, file
-							.lastIndexOf('/', dirIndex - 1))
-							+ file.substring(dirIndex + 3);
-				} else {
+            while ((dirIndex = file.indexOf("/../")) >= 0) { //$NON-NLS-1$
+                if (dirIndex != 0) {
+                    file = file.substring(0, file
+                            .lastIndexOf('/', dirIndex - 1))
+                            + file.substring(dirIndex + 3);
+                } else {
                     file = file.substring(dirIndex + 3);
                 }
-			}
-			if (file.endsWith("/..") && file.length() > 3) {
+            }
+            if (file.endsWith("/..") && file.length() > 3) { //$NON-NLS-1$
                 file = file.substring(0, file.lastIndexOf('/',
-						file.length() - 4) + 1);
+                        file.length() - 4) + 1);
             }
-		}
+        }
+
+        setURL(u, u.getProtocol(), host, port, authority, userInfo, file,
+                query, ref);
+    }
 
-		setURL(u, u.getProtocol(), host, port, authority, userInfo, file,
-				query, ref);
-	}
-
-	/**
-	 * Sets the fields of the <code>URL</code> with the supplied arguments
-	 * 
-	 * @param u
-	 *            java.net.URL The non-null URL to be set
-	 * @param protocol
-	 *            java.lang.String The protocol
-	 * @param host
-	 *            java.lang.String The host name
-	 * @param port
-	 *            int The port number
-	 * @param file
-	 *            java.lang.String The file component
-	 * @param ref
-	 *            java.lang.String The reference
-	 * 
-	 * @see java.util.Set
-	 * 
-	 * @deprecated use setURL(URL, String String, int, String, String, String,
-	 *             String, String)
-	 */
-	@Deprecated
+    /**
+     * Sets the fields of the <code>URL</code> with the supplied arguments
+     * 
+     * @param u
+     *            java.net.URL The non-null URL to be set
+     * @param protocol
+     *            java.lang.String The protocol
+     * @param host
+     *            java.lang.String The host name
+     * @param port
+     *            int The port number
+     * @param file
+     *            java.lang.String The file component
+     * @param ref
+     *            java.lang.String The reference
+     * 
+     * @see java.util.Set
+     * 
+     * @deprecated use setURL(URL, String String, int, String, String, String,
+     *             String, String)
+     */
+    @Deprecated
     protected void setURL(URL u, String protocol, String host, int port,
-			String file, String ref) {
-		if (this != u.strmHandler) {
+            String file, String ref) {
+        if (this != u.strmHandler) {
             throw new SecurityException();
         }
-		u.set(protocol, host, port, file, ref);
-	}
+        u.set(protocol, host, port, file, ref);
+    }
 
-	/**
-	 * Sets the fields of the <code>URL</code> with the supplied arguments
-	 * 
-	 * @param u
-	 *            java.net.URL The non-null URL to be set
-	 * @param protocol
-	 *            java.lang.String The protocol
-	 * @param host
-	 *            java.lang.String The host name
-	 * @param port
-	 *            int The port number
-	 * @param authority
-	 *            java.lang.String The authority
-	 * @param userInfo
-	 *            java.lang.String The user info
-	 * @param file
-	 *            java.lang.String The file component
-	 * @param query
-	 *            java.lang.String The query
-	 * @param ref
-	 *            java.lang.String The reference
-	 * 
-	 * @see java.util.Set
-	 */
-	protected void setURL(URL u, String protocol, String host, int port,
-			String authority, String userInfo, String file, String query,
-			String ref) {
-		if (this != u.strmHandler) {
+    /**
+     * Sets the fields of the <code>URL</code> with the supplied arguments
+     * 
+     * @param u
+     *            java.net.URL The non-null URL to be set
+     * @param protocol
+     *            java.lang.String The protocol
+     * @param host
+     *            java.lang.String The host name
+     * @param port
+     *            int The port number
+     * @param authority
+     *            java.lang.String The authority
+     * @param userInfo
+     *            java.lang.String The user info
+     * @param file
+     *            java.lang.String The file component
+     * @param query
+     *            java.lang.String The query
+     * @param ref
+     *            java.lang.String The reference
+     * 
+     * @see java.util.Set
+     */
+    protected void setURL(URL u, String protocol, String host, int port,
+            String authority, String userInfo, String file, String query,
+            String ref) {
+        if (this != u.strmHandler) {
             throw new SecurityException();
         }
-		u.set(protocol, host, port, authority, userInfo, file, query, ref);
-	}
+        u.set(protocol, host, port, authority, userInfo, file, query, ref);
+    }
+
+    /**
+     * Answers the string equivalent of an URL using HTTP parsinf format.
+     * 
+     * @return java.lang.String the string representation of this URL
+     * @param url
+     *            java.net.URL the url object to be processed
+     * 
+     * @see #parseURL
+     * @see URL#toExternalForm()
+     */
+    protected String toExternalForm(URL url) {
+        StringBuffer answer = new StringBuffer(url.getProtocol().length()
+                + url.getFile().length() + 16);
+        answer.append(url.getProtocol());
+        answer.append(':');
+        String authority = url.getAuthority();
+        if (authority != null && authority.length() > 0) {
+            answer.append("//"); //$NON-NLS-1$
+            answer.append(url.getAuthority());
+        }
+
+        String file = url.getFile();
+        String ref = url.getRef();
+        // file is never null
+        answer.append(file);
+        if (ref != null) {
+            answer.append('#');
+            answer.append(ref);
+        }
+        return answer.toString();
+    }
 
-	/**
-	 * Answers the string equivalent of an URL using HTTP parsinf format.
-	 * 
-	 * @return java.lang.String the string representation of this URL
-	 * @param url
-	 *            java.net.URL the url object to be processed
-	 * 
-	 * @see #parseURL
-	 * @see URL#toExternalForm()
-	 */
-	protected String toExternalForm(URL url) {
-		StringBuffer answer = new StringBuffer(url.getProtocol().length()
-				+ url.getFile().length() + 16);
-		answer.append(url.getProtocol());
-		answer.append(':');
-		String authority = url.getAuthority();
-		if (authority != null && authority.length() > 0) {
-			answer.append("//");
-			answer.append(url.getAuthority());
-		}
-
-		String file = url.getFile();
-		String ref = url.getRef();
-		// file is never null
-		answer.append(file);
-		if (ref != null) {
-			answer.append('#');
-			answer.append(ref);
-		}
-		return answer.toString();
-	}
-
-	/**
-	 * Compares the two urls, and answers true if they represent the same URL.
-	 * Two URLs are equal if they have the same file, host, port, protocol,
-	 * query, and ref components.
-	 * 
-	 * @param url1
-	 *            URL the first URL to compare
-	 * @param url2
-	 *            URL the second URL to compare
-	 * @return <code>true</code> if the URLs are the same <code>false</code>
-	 *         if the URLs are different
-	 * 
-	 * @see #hashCode
-	 */
-	protected boolean equals(URL url1, URL url2) {
-		if (!sameFile(url1, url2)) {
+    /**
+     * Compares the two urls, and answers true if they represent the same URL.
+     * Two URLs are equal if they have the same file, host, port, protocol,
+     * query, and ref components.
+     * 
+     * @param url1
+     *            URL the first URL to compare
+     * @param url2
+     *            URL the second URL to compare
+     * @return <code>true</code> if the URLs are the same <code>false</code>
+     *         if the URLs are different
+     * 
+     * @see #hashCode
+     */
+    protected boolean equals(URL url1, URL url2) {
+        if (!sameFile(url1, url2)) {
             return false;
         }
-		String s1 = url1.getRef(), s2 = url2.getRef();
-		if (s1 != s2 && (s1 == null || !s1.equals(s2))) {
+        String s1 = url1.getRef(), s2 = url2.getRef();
+        if (s1 != s2 && (s1 == null || !s1.equals(s2))) {
             return false;
         }
-		s1 = url1.getQuery();
-		s2 = url2.getQuery();
-		return s1 == s2 || (s1 != null && s1.equals(s2));
-	}
-
-	/**
-	 * Return the default port.
-	 */
-	protected int getDefaultPort() {
-		return -1;
-	}
-
-	/**
-	 * Return the InetAddress for the host of the URL, or null.
-	 */
-	protected InetAddress getHostAddress(URL url) {
-		try {
-			String host = url.getHost();
-			if (host == null || host.length() == 0) {
+        s1 = url1.getQuery();
+        s2 = url2.getQuery();
+        return s1 == s2 || (s1 != null && s1.equals(s2));
+    }
+
+    /**
+     * Return the default port.
+     */
+    protected int getDefaultPort() {
+        return -1;
+    }
+
+    /**
+     * Return the InetAddress for the host of the URL, or null.
+     */
+    protected InetAddress getHostAddress(URL url) {
+        try {
+            String host = url.getHost();
+            if (host == null || host.length() == 0) {
                 return null;
             }
-			return InetAddress.getByName(host);
-		} catch (UnknownHostException e) {
-			return null;
-		}
-	}
-
-	/**
-	 * Answers a hash code for the URL object.
-	 * 
-	 * @return int the hashcode for hashtable indexing
-	 */
-	protected int hashCode(URL url) {
-		return toExternalForm(url).hashCode();
-	}
-
-	/**
-	 * Compares the two urls, and answers true if they have the same host
-	 * components.
-	 * 
-	 * @return <code>true</code> if the hosts of the URLs are the same
-	 *         <code>false</code> if the hosts are different
-	 */
-	protected boolean hostsEqual(URL url1, URL url2) {
+            return InetAddress.getByName(host);
+        } catch (UnknownHostException e) {
+            return null;
+        }
+    }
+
+    /**
+     * Answers a hash code for the URL object.
+     * 
+     * @return int the hashcode for hashtable indexing
+     */
+    protected int hashCode(URL url) {
+        return toExternalForm(url).hashCode();
+    }
+
+    /**
+     * Compares the two urls, and answers true if they have the same host
+     * components.
+     * 
+     * @return <code>true</code> if the hosts of the URLs are the same
+     *         <code>false</code> if the hosts are different
+     */
+    protected boolean hostsEqual(URL url1, URL url2) {
         String host1 = getHost(url1), host2 = getHost(url2);
         if (host1 == host2 || (host1 != null && host1.equalsIgnoreCase(host2))) {
             return true;
@@ -428,46 +428,47 @@
         return false;
     }
 
-	/**
-	 * Answers true if the urls refer to the same file. Compares the protocol,
-	 * host, port and file components.
-	 * 
-	 * @return boolean true if the same resource, false otherwise
-	 */
-	protected boolean sameFile(URL url1, URL url2) {
-		String s1 = url1.getProtocol();
-		String s2 = url2.getProtocol();
-		if (s1 != s2 && (s1 == null || !s1.equals(s2))) {
+    /**
+     * Answers true if the urls refer to the same file. Compares the protocol,
+     * host, port and file components.
+     * 
+     * @return boolean true if the same resource, false otherwise
+     */
+    protected boolean sameFile(URL url1, URL url2) {
+        String s1 = url1.getProtocol();
+        String s2 = url2.getProtocol();
+        if (s1 != s2 && (s1 == null || !s1.equals(s2))) {
             return false;
         }
 
-		s1 = url1.getFile();
-		s2 = url2.getFile();
-		if (s1 != s2 && (s1 == null || !s1.equals(s2))) {
+        s1 = url1.getFile();
+        s2 = url2.getFile();
+        if (s1 != s2 && (s1 == null || !s1.equals(s2))) {
             return false;
         }
-		if (!hostsEqual(url1, url2)) {
+        if (!hostsEqual(url1, url2)) {
             return false;
         }
-		int p1 = url1.getPort();
-		if (p1 == -1) {
+        int p1 = url1.getPort();
+        if (p1 == -1) {
             p1 = getDefaultPort();
         }
-		int p2 = url2.getPort();
-		if (p2 == -1) {
+        int p2 = url2.getPort();
+        if (p2 == -1) {
             p2 = getDefaultPort();
         }
-		return p1 == p2;
-	}
-    
+        return p1 == p2;
+    }
+
     /*
      * If the URL host is empty while protocal is file, the host is regarded as
      * localhost.
      */
     private static String getHost(URL url) {
         String host = url.getHost();
-        if ("file".equals(url.getProtocol()) && "".equals(host)) {
-            host = "localhost";
+        if ("file".equals(url.getProtocol()) //$NON-NLS-1$
+                && "".equals(host)) { //$NON-NLS-1$
+            host = "localhost"; //$NON-NLS-1$
         }
         return host;
     }

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLStreamHandlerFactory.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLStreamHandlerFactory.java?view=diff&rev=493040&r1=493039&r2=493040
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLStreamHandlerFactory.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLStreamHandlerFactory.java Fri Jan  5 06:44:04 2007
@@ -17,19 +17,17 @@
 
 package java.net;
 
-
 /**
  * Defines a factory which creates URL Stream (protocol) Handler It is used by
  * the classes <code>URL</code>
  */
-
 public interface URLStreamHandlerFactory {
-	/**
-	 * Creates a new <code>URL Stream Handler</code> instance.
-	 * 
-	 * @return java.net.URLStreamHandler
-	 * @param protocol
-	 *            java.lang.String
-	 */
-	URLStreamHandler createURLStreamHandler(String protocol);
+    /**
+     * Creates a new <code>URL Stream Handler</code> instance.
+     * 
+     * @return java.net.URLStreamHandler
+     * @param protocol
+     *            java.lang.String
+     */
+    URLStreamHandler createURLStreamHandler(String protocol);
 }

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/UnknownHostException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/UnknownHostException.java?view=diff&rev=493040&r1=493039&r2=493040
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/UnknownHostException.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/UnknownHostException.java Fri Jan  5 06:44:04 2007
@@ -17,33 +17,31 @@
 
 package java.net;
 
-
 import java.io.IOException;
 
 /**
- * This UnknownHostException is thrown when an IP address resolution is attempted
- * and no host or resolver may be found.
+ * This UnknownHostException is thrown when an IP address resolution is
+ * attempted and no host or resolver may be found.
  */
 public class UnknownHostException extends IOException {
 
     private static final long serialVersionUID = -4639126076052875403L;
 
     /**
-	 * Constructs a new instance of this class with its walkback filled in.
-	 */
-	public UnknownHostException() {
-		super();
-	}
-
-	/**
-	 * Constructs a new instance of this class with its walkback and message
-	 * filled in.
-	 * 
-	 * @param detailMessage
-	 *            String The detail message for the exception.
-	 */
-	public UnknownHostException(String detailMessage) {
-		super(detailMessage);
-	}
+     * Constructs a new instance of this class with its walkback filled in.
+     */
+    public UnknownHostException() {
+        super();
+    }
 
+    /**
+     * Constructs a new instance of this class with its walkback and message
+     * filled in.
+     * 
+     * @param detailMessage
+     *            String The detail message for the exception.
+     */
+    public UnknownHostException(String detailMessage) {
+        super(detailMessage);
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/UnknownServiceException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/UnknownServiceException.java?view=diff&rev=493040&r1=493039&r2=493040
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/UnknownServiceException.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/UnknownServiceException.java Fri Jan  5 06:44:04 2007
@@ -17,7 +17,6 @@
 
 package java.net;
 
-
 import java.io.IOException;
 
 /**
@@ -31,20 +30,20 @@
     private static final long serialVersionUID = -4169033248853639508L;
 
     /**
-	 * Constructs a new instance of this class with its walkback filled in.
-	 */
-	public UnknownServiceException() {
-		super();
-	}
+     * Constructs a new instance of this class with its walkback filled in.
+     */
+    public UnknownServiceException() {
+        super();
+    }
 
-	/**
-	 * Constructs a new instance of this class with its walkback and message
-	 * filled in.
-	 * 
-	 * @param detailMessage
-	 *            String The detail message for the exception.
-	 */
-	public UnknownServiceException(String detailMessage) {
-		super(detailMessage);
-	}
+    /**
+     * Constructs a new instance of this class with its walkback and message
+     * filled in.
+     * 
+     * @param detailMessage
+     *            String The detail message for the exception.
+     */
+    public UnknownServiceException(String detailMessage) {
+        super(detailMessage);
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties?view=diff&rev=493040&r1=493039&r2=493040
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties Fri Jan  5 06:44:04 2007
@@ -312,3 +312,8 @@
 KA017=Received HTTP_PROXY_AUTH (407) code while not using proxy
 KA018=Received authentication challenge is null
 KA019=Destination address is null
+KA020=Illegal IPv6 address
+KA021=Scope id is not found for the given address
+KA022=Illegal Proxy.Type or SocketAddress argument
+KA023=Proxy is null or invalid type
+KA024=One of urls is null