harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r493040 [3/11] - in /harmony/enhanced/classlib/trunk/modules/luni/src/main/java: java/net/ org/apache/harmony/luni/util/
Date Fri, 05 Jan 2007 14:44:06 GMT
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/HttpURLConnection.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/HttpURLConnection.java?view=diff&rev=493040&r1=493039&r2=493040
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/HttpURLConnection.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/HttpURLConnection.java Fri Jan  5 06:44:04 2007
@@ -17,10 +17,8 @@
 
 package java.net;
 
-
 import java.io.IOException;
-import java.net.ProtocolException;
-import java.net.URL;
+
 import org.apache.harmony.luni.util.Msg;
 
 /**
@@ -32,444 +30,443 @@
  * @see URLConnection
  * @see URLStreamHandler
  */
-public abstract class HttpURLConnection extends java.net.URLConnection {
-	private String methodTokens[] = { "GET", "DELETE", "HEAD", "OPTIONS",
-			"POST", "PUT", "TRACE" };
+public abstract class HttpURLConnection extends URLConnection {
+    @SuppressWarnings("nls")
+    private String methodTokens[] = { "GET", "DELETE", "HEAD", "OPTIONS",
+            "POST", "PUT", "TRACE" };
+
+    // Request method, DEFAULT: "GET"
+    protected String method = "GET"; //$NON-NLS-1$
 
-	protected String method = "GET"; // request method, DEFAULT: "GET"
+    // Response code obtained from the request
+    protected int responseCode = -1;
 
-	protected int responseCode = -1; // response code obtained from the request
+    // Response message, corresponds to the response code
+    protected String responseMessage;
 
-	protected String responseMessage; // response message corresponds to the
-										// response code
+    protected boolean instanceFollowRedirects = followRedirects;
 
-	protected boolean instanceFollowRedirects = followRedirects;
+    private static boolean followRedirects = true;
 
-	private static boolean followRedirects = true;
-    
     protected int chunkLength = -1;
 
     protected int fixedContentLength = -1;
-    
+
     private final static int DEFAULT_CHUNK_LENGTH = 1024;
 
-	// 2XX: generally "OK"
-	// 3XX: relocation/redirect
-	// 4XX: client error
-	// 5XX: server error
-	/**
-	 * Numeric status code, 202: Accepted
-	 */
-	public final static int HTTP_ACCEPTED = 202;
-
-	/**
-	 * Numeric status code, 502: Bad Gateway
-	 */
-	public final static int HTTP_BAD_GATEWAY = 502;
-
-	/**
-	 * Numeric status code, 405: Bad Method
-	 */
-	public final static int HTTP_BAD_METHOD = 405;
-
-	/**
-	 * Numeric status code, 400: Bad Request
-	 */
-	public final static int HTTP_BAD_REQUEST = 400;
-
-	/**
-	 * Numeric status code, 408: Client Timeout
-	 */
-	public final static int HTTP_CLIENT_TIMEOUT = 408;
-
-	/**
-	 * Numeric status code, 409: Conflict
-	 */
-	public final static int HTTP_CONFLICT = 409;
-
-	/**
-	 * Numeric status code, 201: Created
-	 */
-	public final static int HTTP_CREATED = 201;
-
-	/**
-	 * Numeric status code, 413: Entity too large
-	 */
-	public final static int HTTP_ENTITY_TOO_LARGE = 413;
-
-	/**
-	 * Numeric status code, 403: Forbidden
-	 */
-	public final static int HTTP_FORBIDDEN = 403;
-
-	/**
-	 * Numeric status code, 504: Gateway timeout
-	 */
-	public final static int HTTP_GATEWAY_TIMEOUT = 504;
-
-	/**
-	 * Numeric status code, 410: Gone
-	 */
-	public final static int HTTP_GONE = 410;
-
-	/**
-	 * Numeric status code, 500: Internal error
-	 */
-	public final static int HTTP_INTERNAL_ERROR = 500;
-
-	/**
-	 * Numeric status code, 411: Length required
-	 */
-	public final static int HTTP_LENGTH_REQUIRED = 411;
-
-	/**
-	 * Numeric status code, 301 Moved permanently
-	 */
-	public final static int HTTP_MOVED_PERM = 301;
-
-	/**
-	 * Numeric status code, 302: Moved temporarily
-	 */
-	public final static int HTTP_MOVED_TEMP = 302;
-
-	/**
-	 * Numeric status code, 300: Multiple choices
-	 */
-	public final static int HTTP_MULT_CHOICE = 300;
-
-	/**
-	 * Numeric status code, 204: No content
-	 */
-	public final static int HTTP_NO_CONTENT = 204;
-
-	/**
-	 * Numeric status code, 406: Not acceptable
-	 */
-	public final static int HTTP_NOT_ACCEPTABLE = 406;
-
-	/**
-	 * Numeric status code, 203: Not authoritative
-	 */
-	public final static int HTTP_NOT_AUTHORITATIVE = 203;
-
-	/**
-	 * Numeric status code, 404: Not found
-	 */
-	public final static int HTTP_NOT_FOUND = 404;
-
-	/**
-	 * Numeric status code, 501: Not implemented
-	 */
-	public final static int HTTP_NOT_IMPLEMENTED = 501;
-
-	/**
-	 * Numeric status code, 304: Not modified
-	 */
-	public final static int HTTP_NOT_MODIFIED = 304;
-
-	/**
-	 * Numeric status code, 200: OK
-	 */
-	public final static int HTTP_OK = 200;
-
-	/**
-	 * Numeric status code, 206: Partial
-	 */
-	public final static int HTTP_PARTIAL = 206;
-
-	/**
-	 * Numeric status code, 402: Payment required
-	 */
-	public final static int HTTP_PAYMENT_REQUIRED = 402;
-
-	/**
-	 * Numeric status code, 412: Precondition failed
-	 */
-	public final static int HTTP_PRECON_FAILED = 412;
-
-	/**
-	 * Numeric status code, 407: Proxy authentication required
-	 */
-	public final static int HTTP_PROXY_AUTH = 407;
-
-	/**
-	 * Numeric status code, 414: Request too long
-	 */
-	public final static int HTTP_REQ_TOO_LONG = 414;
-
-	/**
-	 * Numeric status code, 205: Reset
-	 */
-	public final static int HTTP_RESET = 205;
-
-	/**
-	 * Numeric status code, 303: See other
-	 */
-	public final static int HTTP_SEE_OTHER = 303;
-
-	/**
-	 * @deprecated Use HTTP_INTERNAL_ERROR
-	 */
-	@Deprecated
+    // 2XX: generally "OK"
+    // 3XX: relocation/redirect
+    // 4XX: client error
+    // 5XX: server error
+    /**
+     * Numeric status code, 202: Accepted
+     */
+    public final static int HTTP_ACCEPTED = 202;
+
+    /**
+     * Numeric status code, 502: Bad Gateway
+     */
+    public final static int HTTP_BAD_GATEWAY = 502;
+
+    /**
+     * Numeric status code, 405: Bad Method
+     */
+    public final static int HTTP_BAD_METHOD = 405;
+
+    /**
+     * Numeric status code, 400: Bad Request
+     */
+    public final static int HTTP_BAD_REQUEST = 400;
+
+    /**
+     * Numeric status code, 408: Client Timeout
+     */
+    public final static int HTTP_CLIENT_TIMEOUT = 408;
+
+    /**
+     * Numeric status code, 409: Conflict
+     */
+    public final static int HTTP_CONFLICT = 409;
+
+    /**
+     * Numeric status code, 201: Created
+     */
+    public final static int HTTP_CREATED = 201;
+
+    /**
+     * Numeric status code, 413: Entity too large
+     */
+    public final static int HTTP_ENTITY_TOO_LARGE = 413;
+
+    /**
+     * Numeric status code, 403: Forbidden
+     */
+    public final static int HTTP_FORBIDDEN = 403;
+
+    /**
+     * Numeric status code, 504: Gateway timeout
+     */
+    public final static int HTTP_GATEWAY_TIMEOUT = 504;
+
+    /**
+     * Numeric status code, 410: Gone
+     */
+    public final static int HTTP_GONE = 410;
+
+    /**
+     * Numeric status code, 500: Internal error
+     */
+    public final static int HTTP_INTERNAL_ERROR = 500;
+
+    /**
+     * Numeric status code, 411: Length required
+     */
+    public final static int HTTP_LENGTH_REQUIRED = 411;
+
+    /**
+     * Numeric status code, 301 Moved permanently
+     */
+    public final static int HTTP_MOVED_PERM = 301;
+
+    /**
+     * Numeric status code, 302: Moved temporarily
+     */
+    public final static int HTTP_MOVED_TEMP = 302;
+
+    /**
+     * Numeric status code, 300: Multiple choices
+     */
+    public final static int HTTP_MULT_CHOICE = 300;
+
+    /**
+     * Numeric status code, 204: No content
+     */
+    public final static int HTTP_NO_CONTENT = 204;
+
+    /**
+     * Numeric status code, 406: Not acceptable
+     */
+    public final static int HTTP_NOT_ACCEPTABLE = 406;
+
+    /**
+     * Numeric status code, 203: Not authoritative
+     */
+    public final static int HTTP_NOT_AUTHORITATIVE = 203;
+
+    /**
+     * Numeric status code, 404: Not found
+     */
+    public final static int HTTP_NOT_FOUND = 404;
+
+    /**
+     * Numeric status code, 501: Not implemented
+     */
+    public final static int HTTP_NOT_IMPLEMENTED = 501;
+
+    /**
+     * Numeric status code, 304: Not modified
+     */
+    public final static int HTTP_NOT_MODIFIED = 304;
+
+    /**
+     * Numeric status code, 200: OK
+     */
+    public final static int HTTP_OK = 200;
+
+    /**
+     * Numeric status code, 206: Partial
+     */
+    public final static int HTTP_PARTIAL = 206;
+
+    /**
+     * Numeric status code, 402: Payment required
+     */
+    public final static int HTTP_PAYMENT_REQUIRED = 402;
+
+    /**
+     * Numeric status code, 412: Precondition failed
+     */
+    public final static int HTTP_PRECON_FAILED = 412;
+
+    /**
+     * Numeric status code, 407: Proxy authentication required
+     */
+    public final static int HTTP_PROXY_AUTH = 407;
+
+    /**
+     * Numeric status code, 414: Request too long
+     */
+    public final static int HTTP_REQ_TOO_LONG = 414;
+
+    /**
+     * Numeric status code, 205: Reset
+     */
+    public final static int HTTP_RESET = 205;
+
+    /**
+     * Numeric status code, 303: See other
+     */
+    public final static int HTTP_SEE_OTHER = 303;
+
+    /**
+     * @deprecated Use HTTP_INTERNAL_ERROR
+     */
+    @Deprecated
     public final static int HTTP_SERVER_ERROR = 500;
 
-	/**
-	 * Numeric status code, 305: Use proxy
-	 */
-	public final static int HTTP_USE_PROXY = 305;
-
-	/**
-	 * Numeric status code, 401: Unauthorized
-	 */
-	public final static int HTTP_UNAUTHORIZED = 401;
-
-	/**
-	 * Numeric status code, 415: Unsupported type
-	 */
-	public final static int HTTP_UNSUPPORTED_TYPE = 415;
-
-	/**
-	 * Numeric status code, 503: Unavailable
-	 */
-	public final static int HTTP_UNAVAILABLE = 503;
-
-	/**
-	 * Numeric status code, 505: Version not supported
-	 */
-	public final static int HTTP_VERSION = 505;
-
-	/**
-	 * Constructs a <code>HttpURLConnection</code> pointing to the resource
-	 * specified by the <code>URL</code>.
-	 * 
-	 * @param url
-	 *            the URL of this connection
-	 * 
-	 * @see URL
-	 * @see URLConnection
-	 */
-	protected HttpURLConnection(URL url) {
-		super(url);
-	}
-
-	/**
-	 * Closes the connection with the HTTP server
-	 * 
-	 * @see URLConnection#connect()
-	 * @see URLConnection#connected
-	 */
-	public abstract void disconnect();
-
-	/**
-	 * Answers a input stream from the server in the case of error such as the
-	 * requested file (txt, htm, html) is not found on the remote server.
-	 * <p>
-	 * If the content type is not what stated above,
-	 * <code>FileNotFoundException</code> is thrown.
-	 * 
-	 * @return the error input stream returned by the server.
-	 */
-	public java.io.InputStream getErrorStream() {
-		return null;
-	}
-
-	/**
-	 * Answers the value of <code>followRedirects</code> which indicates if
-	 * this connection will follows a different URL redirected by the server. It
-	 * is enabled by default.
-	 * 
-	 * @return The value of the flag
-	 * 
-	 * @see #setFollowRedirects
-	 */
-	public static boolean getFollowRedirects() {
-		return followRedirects;
-	}
-
-	/**
-	 * Answers the permission object (in this case, SocketPermission) with the
-	 * host and the port number as the target name and "resolve, connect" as the
-	 * action list.
-	 * 
-	 * @return the permission object required for this connection
-	 * 
-	 * @throws IOException
-	 *             if an IO exception occurs during the creation of the
-	 *             permission object.
-	 */
-	@Override
+    /**
+     * Numeric status code, 305: Use proxy
+     */
+    public final static int HTTP_USE_PROXY = 305;
+
+    /**
+     * Numeric status code, 401: Unauthorized
+     */
+    public final static int HTTP_UNAUTHORIZED = 401;
+
+    /**
+     * Numeric status code, 415: Unsupported type
+     */
+    public final static int HTTP_UNSUPPORTED_TYPE = 415;
+
+    /**
+     * Numeric status code, 503: Unavailable
+     */
+    public final static int HTTP_UNAVAILABLE = 503;
+
+    /**
+     * Numeric status code, 505: Version not supported
+     */
+    public final static int HTTP_VERSION = 505;
+
+    /**
+     * Constructs a <code>HttpURLConnection</code> pointing to the resource
+     * specified by the <code>URL</code>.
+     * 
+     * @param url
+     *            the URL of this connection
+     * 
+     * @see URL
+     * @see URLConnection
+     */
+    protected HttpURLConnection(URL url) {
+        super(url);
+    }
+
+    /**
+     * Closes the connection with the HTTP server
+     * 
+     * @see URLConnection#connect()
+     * @see URLConnection#connected
+     */
+    public abstract void disconnect();
+
+    /**
+     * Answers a input stream from the server in the case of error such as the
+     * requested file (txt, htm, html) is not found on the remote server.
+     * <p>
+     * If the content type is not what stated above,
+     * <code>FileNotFoundException</code> is thrown.
+     * 
+     * @return the error input stream returned by the server.
+     */
+    public java.io.InputStream getErrorStream() {
+        return null;
+    }
+
+    /**
+     * Answers the value of <code>followRedirects</code> which indicates if
+     * this connection will follows a different URL redirected by the server. It
+     * is enabled by default.
+     * 
+     * @return The value of the flag
+     * 
+     * @see #setFollowRedirects
+     */
+    public static boolean getFollowRedirects() {
+        return followRedirects;
+    }
+
+    /**
+     * Answers the permission object (in this case, SocketPermission) with the
+     * host and the port number as the target name and "resolve, connect" as the
+     * action list.
+     * 
+     * @return the permission object required for this connection
+     * 
+     * @throws IOException
+     *             if an IO exception occurs during the creation of the
+     *             permission object.
+     */
+    @Override
     public java.security.Permission getPermission() throws IOException {
-		int port = url.getPort();
-		if (port < 0) {
+        int port = url.getPort();
+        if (port < 0) {
             port = 80;
         }
-		return new java.net.SocketPermission(url.getHost() + ":" + port,
-				"connect, resolve");
-	}
-
-	/**
-	 * Answers the request method which will be used to make the request to the
-	 * remote HTTP server. All possible methods of this HTTP implementation is listed in
-	 * the class definition.
-	 * 
-	 * @return the request method string
-	 * 
-	 * @see #method
-	 * @see #setRequestMethod
-	 */
-	public String getRequestMethod() {
-		return method;
-	}
-
-	/**
-	 * Answers the response code returned by the remote HTTP server
-	 * 
-	 * @return the response code, -1 if no valid response code
-	 * 
-	 * @throws IOException
-	 *             if there is an IO error during the retrieval.
-	 * 
-	 * @see #getResponseMessage
-	 */
-	public int getResponseCode() throws IOException {
-		// Response Code Sample : " HTTP/1.0 200 OK "
-
-		// Call getInputStream() first since getHeaderField() doesn't return
-		// exceptions
-		getInputStream();
-		String response = getHeaderField(0);
-		if (response == null) {
+        return new SocketPermission(url.getHost() + ":" + port, //$NON-NLS-1$
+                "connect, resolve"); //$NON-NLS-1$
+    }
+
+    /**
+     * Answers the request method which will be used to make the request to the
+     * remote HTTP server. All possible methods of this HTTP implementation is
+     * listed in the class definition.
+     * 
+     * @return the request method string
+     * 
+     * @see #method
+     * @see #setRequestMethod
+     */
+    public String getRequestMethod() {
+        return method;
+    }
+
+    /**
+     * Answers the response code returned by the remote HTTP server
+     * 
+     * @return the response code, -1 if no valid response code
+     * 
+     * @throws IOException
+     *             if there is an IO error during the retrieval.
+     * 
+     * @see #getResponseMessage
+     */
+    public int getResponseCode() throws IOException {
+        // Call getInputStream() first since getHeaderField() doesn't return
+        // exceptions
+        getInputStream();
+        String response = getHeaderField(0);
+        if (response == null) {
             return -1;
         }
-		response = response.trim();
-		int mark = response.indexOf(" ") + 1;
-		if (mark == 0) {
+        response = response.trim();
+        int mark = response.indexOf(" ") + 1; //$NON-NLS-1$
+        if (mark == 0) {
             return -1;
         }
-		int last = mark + 3;
-		if (last > response.length()) {
+        int last = mark + 3;
+        if (last > response.length()) {
             last = response.length();
         }
-		responseCode = Integer.parseInt(response.substring(mark, last));
-		if (last + 1 <= response.length()) {
+        responseCode = Integer.parseInt(response.substring(mark, last));
+        if (last + 1 <= response.length()) {
             responseMessage = response.substring(last + 1);
         }
-		return responseCode;
-	}
+        return responseCode;
+    }
 
-	/**
-	 * Answers the response message returned the remote HTTP server
-	 * 
-	 * @return the response message. <code>null</code> if such response exists
-	 * 
-	 * @throws IOException
-	 *             if there is an IO error during the retrieval.
-	 * 
-	 * @see #getResponseCode()
-	 * @see IOException
-	 */
-	public String getResponseMessage() throws IOException {
-		if (responseMessage != null) {
+    /**
+     * Answers the response message returned the remote HTTP server
+     * 
+     * @return the response message. <code>null</code> if such response exists
+     * 
+     * @throws IOException
+     *             if there is an IO error during the retrieval.
+     * 
+     * @see #getResponseCode()
+     * @see IOException
+     */
+    public String getResponseMessage() throws IOException {
+        if (responseMessage != null) {
             return responseMessage;
         }
-		getResponseCode();
-		return responseMessage;
-	}
-
-	/**
-	 * Sets the flag of whether this connection will follow redirects returned
-	 * by the remote server. This method can only be called with the permission
-	 * from the security manager
-	 * 
-	 * @param auto
-	 *            The value to set
-	 * 
-	 * @see java.lang.SecurityManager#checkSetFactory()
-	 */
-
-	public static void setFollowRedirects(boolean auto) {
-		SecurityManager security = System.getSecurityManager();
-		if (security != null) {
+        getResponseCode();
+        return responseMessage;
+    }
+
+    /**
+     * Sets the flag of whether this connection will follow redirects returned
+     * by the remote server. This method can only be called with the permission
+     * from the security manager
+     * 
+     * @param auto
+     *            The value to set
+     * 
+     * @see java.lang.SecurityManager#checkSetFactory()
+     */
+    public static void setFollowRedirects(boolean auto) {
+        SecurityManager security = System.getSecurityManager();
+        if (security != null) {
             security.checkSetFactory();
         }
-		followRedirects = auto;
-	}
+        followRedirects = auto;
+    }
 
-	/**
-	 * Sets the request command which will be sent to the remote HTTP server.
-	 * This method can only be called before the connection is made.
-	 * 
-	 * @param method
-	 *            The <code>non-null</code> string representing the method
-	 * 
-	 * @throws java.net.ProtocolException
-	 *             Thrown when this is called after connected, or the method is
-	 *             not supported by this HTTP implementation.
-	 * 
-	 * @see #getRequestMethod()
-	 * @see #method
-	 */
-	public void setRequestMethod(String method) throws ProtocolException {
-		if (connected) {
-            throw new ProtocolException(Msg.getString("K0037"));
-        }
-		for (int i = 0; i < methodTokens.length; i++) {
-			if (methodTokens[i].equals(method)) {
-				// if there is a supported method that matches the desired
-				// method, then set the current method and return
-				this.method = methodTokens[i];
-				return;
-			}
-		}
-		// if none matches, then throw ProtocolException
-		throw new ProtocolException();
-	}
-
-	/**
-	 * Answers if this connection uses proxy.
-	 * 
-	 * @return true if this connection supports proxy, false otherwise.
-	 */
-	public abstract boolean usingProxy();
-
-	/**
-	 * Answers if this connection follows redirects.
-	 * 
-	 * @return true if this connection follows redirects, false otherwise.
-	 */
-	public boolean getInstanceFollowRedirects() {
-		return instanceFollowRedirects;
-	}
-
-	/**
-	 * Sets if this connection follows redirects.
-	 * 
-	 * @param followRedirects
-	 *            true if this connection should follows redirects, false
-	 *            otherwise.
-	 */
-	public void setInstanceFollowRedirects(boolean followRedirects) {
-		instanceFollowRedirects = followRedirects;
-	}
-
-	/**
-	 * Answers the date value in the form of milliseconds since epoch
-	 * corresponding to the field <code>field</code>. Answers
-	 * <code>defaultValue</code> if no such field can be found in the response
-	 * header.
-	 * 
-	 * @param field
-	 *            the field in question
-	 * @param defaultValue
-	 *            the default value if no field is found
-	 * @return milliseconds since epoch
-	 */
-	@Override
+    /**
+     * Sets the request command which will be sent to the remote HTTP server.
+     * This method can only be called before the connection is made.
+     * 
+     * @param method
+     *            The <code>non-null</code> string representing the method
+     * 
+     * @throws ProtocolException
+     *             Thrown when this is called after connected, or the method is
+     *             not supported by this HTTP implementation.
+     * 
+     * @see #getRequestMethod()
+     * @see #method
+     */
+    public void setRequestMethod(String method) throws ProtocolException {
+        if (connected) {
+            throw new ProtocolException(Msg.getString("K0037")); //$NON-NLS-1$
+        }
+        for (int i = 0; i < methodTokens.length; i++) {
+            if (methodTokens[i].equals(method)) {
+                // if there is a supported method that matches the desired
+                // method, then set the current method and return
+                this.method = methodTokens[i];
+                return;
+            }
+        }
+        // if none matches, then throw ProtocolException
+        throw new ProtocolException();
+    }
+
+    /**
+     * Answers if this connection uses proxy.
+     * 
+     * @return true if this connection supports proxy, false otherwise.
+     */
+    public abstract boolean usingProxy();
+
+    /**
+     * Answers if this connection follows redirects.
+     * 
+     * @return true if this connection follows redirects, false otherwise.
+     */
+    public boolean getInstanceFollowRedirects() {
+        return instanceFollowRedirects;
+    }
+
+    /**
+     * Sets if this connection follows redirects.
+     * 
+     * @param followRedirects
+     *            true if this connection should follows redirects, false
+     *            otherwise.
+     */
+    public void setInstanceFollowRedirects(boolean followRedirects) {
+        instanceFollowRedirects = followRedirects;
+    }
+
+    /**
+     * Answers the date value in the form of milliseconds since epoch
+     * corresponding to the field <code>field</code>. Answers
+     * <code>defaultValue</code> if no such field can be found in the response
+     * header.
+     * 
+     * @param field
+     *            the field in question
+     * @param defaultValue
+     *            the default value if no field is found
+     * @return milliseconds since epoch
+     */
+    @Override
     public long getHeaderFieldDate(String field, long defaultValue) {
-		return super.getHeaderFieldDate(field, defaultValue);
-	}
-    
-    
+        return super.getHeaderFieldDate(field, defaultValue);
+    }
+
     /**
      * If length of a HTTP request body is known ahead, sets fixed length to
      * enable streaming without buffering. Sets after connection will cause an
@@ -485,13 +482,13 @@
      */
     public void setFixedLengthStreamingMode(int contentLength) {
         if (super.connected) {
-            throw new IllegalStateException(Msg.getString("K0079"));
+            throw new IllegalStateException(Msg.getString("K0079")); //$NON-NLS-1$
         }
         if (0 < chunkLength) {
-            throw new IllegalStateException(Msg.getString("KA003"));
+            throw new IllegalStateException(Msg.getString("KA003")); //$NON-NLS-1$
         }
         if (0 > contentLength) {
-            throw new IllegalArgumentException(Msg.getString("K0051"));
+            throw new IllegalArgumentException(Msg.getString("K0051")); //$NON-NLS-1$
         }
         this.fixedContentLength = contentLength;
     }
@@ -510,10 +507,10 @@
      */
     public void setChunkedStreamingMode(int chunklen) {
         if (super.connected) {
-            throw new IllegalStateException(Msg.getString("K0079"));
+            throw new IllegalStateException(Msg.getString("K0079")); //$NON-NLS-1$
         }
         if (0 <= fixedContentLength) {
-            throw new IllegalStateException(Msg.getString("KA003"));
+            throw new IllegalStateException(Msg.getString("KA003")); //$NON-NLS-1$
         }
         if (0 >= chunklen) {
             chunkLength = DEFAULT_CHUNK_LENGTH;

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Inet4Address.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Inet4Address.java?view=diff&rev=493040&r1=493039&r2=493040
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Inet4Address.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Inet4Address.java Fri Jan  5 06:44:04 2007
@@ -19,21 +19,20 @@
 
 import java.io.ObjectStreamException;
 
-
 public final class Inet4Address extends InetAddress {
 
-	private static final long serialVersionUID = 3286316764910316507L;
+    private static final long serialVersionUID = 3286316764910316507L;
+
+    Inet4Address(byte[] address) {
+        ipaddress = address;
+    }
 
-	Inet4Address(byte[] address) {
-		ipaddress = address;
-	}
-
-	Inet4Address(byte[] address, String name) {
-		ipaddress = address;
-		hostName = name;
-	}
+    Inet4Address(byte[] address, String name) {
+        ipaddress = address;
+        hostName = name;
+    }
 
-	/**
+    /**
      * Answers true if the address is a multicast address. Valid IPv4 multicast
      * addresses are prefixed with 1110 = 0xE
      * 
@@ -44,78 +43,81 @@
         return (ipaddress[0] & 0xF0) == 0xE0;
     }
 
-	/**
-	 * Answers if the address is the ANY Address
-	 * 
-	 * @return boolean
-	 */
-	@Override
+    /**
+     * Answers if the address is the ANY Address
+     * 
+     * @return boolean
+     */
+    @Override
     public boolean isAnyLocalAddress() {
-		for (int i = 0; i < ipaddress.length; i++) {
-			if (ipaddress[i] != 0) {
+        for (int i = 0; i < ipaddress.length; i++) {
+            if (ipaddress[i] != 0) {
                 return false;
             }
-		}
-		return true;
-	}
-
-	/**
-	 * Answers true if the address is a loopback address.
-	 * Loopback ipv4 addresses are prefixed with: 011111111 = 127
+        }
+        return true;
+    }
+
+    /**
+     * Answers true if the address is a loopback address. Loopback ipv4
+     * addresses are prefixed with: 011111111 = 127
+     * 
      * @return boolean
-	 */
-	@Override
+     */
+    @Override
     public boolean isLoopbackAddress() {
-		return (ipaddress[0] & 255) == 127;
-	}
+        return (ipaddress[0] & 255) == 127;
+    }
 
-	/**
-	 * Answers whether this address has link-local scope.
-	 * 
-	 * RFC 3484 Default Address Selection for Internet Protocol version 6 (IPv6)
-	 * states IPv4 auto-configuration addresses, prefix 169.254/16, 
-	 * IPv4 loopback addresses, prefix 127/8, are assigned link-local scope.
-	 * 
-	 * @return boolean
-	 */
-	@Override
+    /**
+     * Answers whether this address has link-local scope.
+     * 
+     * RFC 3484 Default Address Selection for Internet Protocol version 6 (IPv6)
+     * states IPv4 auto-configuration addresses, prefix 169.254/16, IPv4
+     * loopback addresses, prefix 127/8, are assigned link-local scope.
+     * 
+     * @return boolean
+     */
+    @Override
     public boolean isLinkLocalAddress() {
-		// The reference implementation does not return true
-		// for loopback addresses even though RFC 3484 says to do so
-		return (((ipaddress[0] & 255) == 169) && ((ipaddress[1] & 255) == 254));
-	}
-
-	/**
-	 * Answers whether this address has site-local scope.
-	 * RFC 3484 Default Address Selection for Internet Protocol version 6 (IPv6)
-	 * states IPv4 private addresses, prefixes 10/8, 172.16/12, and 192.168/16,
-	 * are assigned site-local scope.
+        // The reference implementation does not return true for loopback
+        // addresses even though RFC 3484 says to do so
+        return (((ipaddress[0] & 255) == 169) && ((ipaddress[1] & 255) == 254));
+    }
+
+    /**
+     * Answers whether this address has site-local scope. RFC 3484 Default
+     * Address Selection for Internet Protocol version 6 (IPv6) states IPv4
+     * private addresses, prefixes 10/8, 172.16/12, and 192.168/16, are assigned
+     * site-local scope.
+     * 
      * @return boolean
-	 */
-	@Override
+     */
+    @Override
     public boolean isSiteLocalAddress() {
-		return ((ipaddress[0] & 255) == 10) || ((ipaddress[0] & 255) == 172)
-				&& (((ipaddress[1] & 255) > 15) && (ipaddress[1] & 255) < 32)
-				|| ((ipaddress[0] & 255) == 192)
-				&& ((ipaddress[1] & 255) == 168);
-	}
-
-	/**
-	 * Answers true if an address is a global multicast address.
-	 * Valid MCGlobal IPv4 addresses are 224.0.1.0 - 238.255.255.255
+        return ((ipaddress[0] & 255) == 10) || ((ipaddress[0] & 255) == 172)
+                && (((ipaddress[1] & 255) > 15) && (ipaddress[1] & 255) < 32)
+                || ((ipaddress[0] & 255) == 192)
+                && ((ipaddress[1] & 255) == 168);
+    }
+
+    /**
+     * Answers true if an address is a global multicast address. Valid MCGlobal
+     * IPv4 addresses are 224.0.1.0 - 238.255.255.255
+     * 
      * @return boolean true, if the address is in the global multicast group,
      *         false otherwise
-	 */
-	@Override
+     */
+    @Override
     public boolean isMCGlobal() {
 
-		// Check if we have a prefix of 1110
-		if (!isMulticastAddress()) {
+        // Check if we have a prefix of 1110
+        if (!isMulticastAddress()) {
             return false;
         }
 
-		int address = InetAddress.bytesToInt(ipaddress, 0);
-		/*
+        int address = InetAddress.bytesToInt(ipaddress, 0);
+        /*
          * Now check the boundaries of the global space if we have an address
          * that is prefixed by something less than 111000000000000000000001
          * (fortunately we don't have to worry about sign after shifting 8 bits
@@ -134,102 +136,97 @@
             return false;
         }
 
-		return true;
-
-	}
+        return true;
+    }
 
-	/**
+    /**
      * Answers false for all IPv4 addresses. There are no valid IPv4 Node-local
      * addresses
      * 
      * @return boolean
      */
-	@Override
+    @Override
     public boolean isMCNodeLocal() {
-		return false;
-	}
+        return false;
+    }
 
-	/**
+    /**
      * Answers true if the address is a link-local address.The valid range for
      * IPv4 link-local addresses is: 224.0.0.0 to 239.0.0.255 Hence a mask of
      * 111000000000000000000000 = 0xE00000
      * 
      * @return boolean
      */
-	@Override
+    @Override
     public boolean isMCLinkLocal() {
-		return InetAddress.bytesToInt(ipaddress, 0) >>> 8 == 0xE00000;
-	}
+        return InetAddress.bytesToInt(ipaddress, 0) >>> 8 == 0xE00000;
+    }
 
-	/**
+    /**
      * Answers true if the address is a site-local address.The valid range for
      * IPv4 site-local addresses is: 239.255.0.0 to 239.255.255.255 Hence a mask
      * of 11101111 11111111 = 0xEFFF.
      * 
      * @return boolean
      */
-	@Override
+    @Override
     public boolean isMCSiteLocal() {
-		return (InetAddress.bytesToInt(ipaddress, 0) >>> 16) == 0xEFFF;
-	}
+        return (InetAddress.bytesToInt(ipaddress, 0) >>> 16) == 0xEFFF;
+    }
 
-	/**
+    /**
      * Answers true if the address is a organization-local address. The valid
      * range for IPv4 org-local addresses is: 239.192.0.0 to 239.195.255.255
      * Hence masks of 11101111 11000000 to 11101111 11000011 are valid. 0xEFC0
      * to 0xEFC3
      * 
-     * @return boolean
+     * @return true if org local address, false otherwise
      */
-	@Override
+    @Override
     public boolean isMCOrgLocal() {
-		int prefix = InetAddress.bytesToInt(ipaddress, 0) >>> 16;
-		return prefix >= 0xEFC0 && prefix <= 0xEFC3;
-	}
-
-	/**
-	 * Returns a String representation of the IP address.
-	 * 
-	 * @return String
-	 * 
-	 */
-	@Override
+        int prefix = InetAddress.bytesToInt(ipaddress, 0) >>> 16;
+        return prefix >= 0xEFC0 && prefix <= 0xEFC3;
+    }
+
+    /**
+     * Returns a String representation of the IP address.
+     * 
+     * @return Host address
+     */
+    @Override
     public String getHostAddress() {
-		String hostAddress = "";
-		for (int i = 0; i < 4; i++) {
-			hostAddress += ipaddress[i] & 255;
-			if (i != 3) {
-                hostAddress += ".";
+        String hostAddress = ""; //$NON-NLS-1$
+        for (int i = 0; i < 4; i++) {
+            hostAddress += ipaddress[i] & 255;
+            if (i != 3) {
+                hostAddress += "."; //$NON-NLS-1$
             }
-		}
-		return hostAddress;
-	}
-
-	/**
-	 * Overrides the basic hashcode function.
-	 * 
-	 * @return String
-	 * 
-	 */
-	@Override
+        }
+        return hostAddress;
+    }
+
+    /**
+     * Overrides the basic hashcode function.
+     * 
+     * @return the hash code
+     */
+    @Override
     public int hashCode() {
-		return InetAddress.bytesToInt(ipaddress, 0);
-	}
+        return InetAddress.bytesToInt(ipaddress, 0);
+    }
 
-	/**
-	 * Returns true if obj is of the same type as the IPv4 address and they have
-	 * the same IP address, false otherwise.
-	 * 
-	 * @return String
-	 * 
-	 */
-	@Override
+    /**
+     * Returns true if obj is of the same type as the IPv4 address and they have
+     * the same IP address, false otherwise.
+     * 
+     * @return true if equal and false otherwise
+     */
+    @Override
     public boolean equals(Object obj) {
-		return super.equals(obj);
-	}
-
-	private Object writeReplace() throws ObjectStreamException {
-		return new InetAddress(ipaddress, hostName);
-	}
+        return super.equals(obj);
+    }
 
+    private Object writeReplace() throws ObjectStreamException {
+        return new InetAddress(ipaddress, hostName);
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Inet6Address.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Inet6Address.java?view=diff&rev=493040&r1=493039&r2=493040
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Inet6Address.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Inet6Address.java Fri Jan  5 06:44:04 2007
@@ -24,459 +24,463 @@
 import java.util.Enumeration;
 
 import org.apache.harmony.luni.util.Inet6Util;
+import org.apache.harmony.luni.util.Msg;
 
 public final class Inet6Address extends InetAddress {
 
-	private static final long serialVersionUID = 6880410070516793377L;
+    private static final long serialVersionUID = 6880410070516793377L;
 
-	static final byte[] any_bytes = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
-	static final byte[] localhost_bytes = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1};
-	static final InetAddress ANY = new Inet6Address(any_bytes);
-	static final InetAddress LOOPBACK = new Inet6Address(localhost_bytes, "localhost"); 
-
-	int scope_id;
-
-	boolean scope_id_set;
-
-	boolean scope_ifname_set;
-
-	String ifname;
-	
-	/*
-	 * scoped interface.
-	 */
-	transient NetworkInterface scopedIf;
-
-	Inet6Address(byte address[]) {
-		ipaddress = address;
-		scope_id = 0;
-	}
-
-	Inet6Address(byte address[], String name) {
-		hostName = name;
-		ipaddress = address;
-		scope_id = 0;
-	}
-
-	/**
-	 * Constructs an InetAddress, representing the <code>address</code> and
-	 * <code>hostName</code> and <code>scope_id</code>
-	 * 
-	 * @param address
-	 *            network address
-	 * @param name
-	 *            Name associated with the address
-	 * @param scope_id
-	 *            The scope id for link or site local addresses
-	 */
-	Inet6Address(byte address[], String name, int scope_id) {
-		hostName = name;
-		ipaddress = address;
-		this.scope_id = scope_id;
-		if (scope_id != 0) {
-			scope_id_set = true;
-		}
-	}
-
-	/**
-	 * Constructs an IPv6 address according to the given <code>host</code>,
-	 * <code>addr</code> and <code>scope_id</code>.
-	 * 
-	 * @param host
-	 *            hostname associated with the address
-	 * @param addr
-	 *            network address
-	 * @param scope_id
-	 *            the scope id for link or site local addresses
-	 * @return an Inet6Address instance
-	 * @throws UnknownHostException
-	 *             if the address is null or of invalid length
-	 */
-	public static Inet6Address getByAddress(String host, byte[] addr,
-			int scope_id) throws UnknownHostException {
-		if (null == addr || 16 != addr.length) {
-			throw new UnknownHostException("Illegal ipv6 address");
-		}
-		if(scope_id < 0){
-			scope_id = 0;
-		}
-		return new Inet6Address(addr, host, scope_id);
-	}
-	
-	/**
-	 * Constructs an IPv6 address according to the given <code>host</code>,
-	 * <code>addr</code> and <code>nif</code>. <code>scope_id</code> is
-	 * set according to the given <code>nif</code> and the
-	 * <code>addr<code> type(e.g. site local or link local).
-	 * 
-	 * @param host
-	 *            host name associated with the address
-	 * @param addr
-	 *            network address
-	 * @param nif
-	 *            the Network Interface that this address is associated with.
-	 * @return an Inet6Address instance
-	 * @throws UnknownHostException
-	 *             if the address is null or of invalid length, or the
-	 *             interface doesn't have a numeric scope id for the given
-	 *             address type.
-	 */
-	public static Inet6Address getByAddress(String host, byte[] addr,
-			NetworkInterface nif) throws UnknownHostException {
-		Inet6Address address = Inet6Address.getByAddress(host, addr, 0);
-		
-		// if nif is null, nothing needs to be set.
-		if(null == nif){
-			return address;
-		}
-		
-		// find the first address which matches the type addr,
-		// then set the scope_id, ifname and scopedIf.
-		Enumeration<InetAddress> addressList = nif.getInetAddresses();
-		while (addressList.hasMoreElements()) {
-			InetAddress ia = addressList.nextElement();
-			if (ia.getAddress().length == 16) {
-				Inet6Address v6ia = (Inet6Address) ia;
-				boolean isSameType = v6ia.compareLocalType(address);
-				if (isSameType) {
-					address.scope_id_set = true;
-					address.scope_id = v6ia.scope_id;
-					address.scope_ifname_set = true;
-					address.ifname = nif.getName();
-					address.scopedIf = nif;
-					break;
-				}
-			}
-		}
-		// if no address matches the type of addr, throws an UnknownHostException.
-		if (!address.scope_id_set) {
-			throw new UnknownHostException(
-					"Scope id is not found for the given address");
-		}
-		return address;
-	}
-	
-
-	/**
-	 * Returns true if one of following cases is true:
-	 * 1. both addresses are site local;
-	 * 2. both addresses are link local;
-	 * 3. ia is neither site local nor link local;
-	 */
-	private boolean compareLocalType(Inet6Address ia) {
-		if (ia.isSiteLocalAddress() && isSiteLocalAddress()) {
-			return true;
-		}
-		if (ia.isLinkLocalAddress() && isLinkLocalAddress()) {
-			return true;
-		}
-		if( !ia.isSiteLocalAddress() && !ia.isLinkLocalAddress()){
-			return true;
-		}
-		return false;
-	}
-	
-	/**
-	 * Constructs an InetAddress, representing the <code>address</code> and
-	 * <code>hostName</code> and <code>scope_id</code>
-	 * 
-	 * @param address
-	 *            network address
-	 * @param scope_id
-	 *            The scope id for link or site local addresses
-	 */
-	Inet6Address(byte address[], int scope_id) {
-		ipaddress = address;
-		this.scope_id = scope_id;
-		if (scope_id != 0) {
-			scope_id_set = true;
-		}
-	}
-
-	/**
-	 * Answer true if the InetAddress is an IP multicast address.
-	 * 
-	 * Valid IPv6 multicast address have the binary prefixed with 11111111 or FF
-	 * (hex).
-	 * 
-	 * @return boolean true, if the address is in the multicast group, false
-	 *         otherwise
-	 */
-	@Override
-    public boolean isMulticastAddress() {
+    static final byte[] any_bytes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+            0, 0 };
+
+    static final byte[] localhost_bytes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+            0, 0, 0, 1 };
+
+    static final InetAddress ANY = new Inet6Address(any_bytes);
+
+    static final InetAddress LOOPBACK = new Inet6Address(localhost_bytes,
+            "localhost"); //$NON-NLS-1$
+
+    int scope_id;
+
+    boolean scope_id_set;
+
+    boolean scope_ifname_set;
+
+    String ifname;
+
+    /*
+     * scoped interface.
+     */
+    transient NetworkInterface scopedIf;
+
+    Inet6Address(byte address[]) {
+        ipaddress = address;
+        scope_id = 0;
+    }
+
+    Inet6Address(byte address[], String name) {
+        hostName = name;
+        ipaddress = address;
+        scope_id = 0;
+    }
+
+    /**
+     * Constructs an InetAddress, representing the <code>address</code> and
+     * <code>hostName</code> and <code>scope_id</code>
+     * 
+     * @param address
+     *            network address
+     * @param name
+     *            Name associated with the address
+     * @param scope_id
+     *            The scope id for link or site local addresses
+     */
+    Inet6Address(byte address[], String name, int scope_id) {
+        hostName = name;
+        ipaddress = address;
+        this.scope_id = scope_id;
+        if (scope_id != 0) {
+            scope_id_set = true;
+        }
+    }
+
+    /**
+     * Constructs an IPv6 address according to the given <code>host</code>,
+     * <code>addr</code> and <code>scope_id</code>.
+     * 
+     * @param host
+     *            hostname associated with the address
+     * @param addr
+     *            network address
+     * @param scope_id
+     *            the scope id for link or site local addresses
+     * @return an Inet6Address instance
+     * @throws UnknownHostException
+     *             if the address is null or of invalid length
+     */
+    public static Inet6Address getByAddress(String host, byte[] addr,
+            int scope_id) throws UnknownHostException {
+        if (null == addr || 16 != addr.length) {
+            // KA020=Illegal IPv6 address
+            throw new UnknownHostException(Msg.getString("KA020")); //$NON-NLS-1$
+        }
+        if (scope_id < 0) {
+            scope_id = 0;
+        }
+        return new Inet6Address(addr, host, scope_id);
+    }
+
+    /**
+     * Constructs an IPv6 address according to the given <code>host</code>,
+     * <code>addr</code> and <code>nif</code>. <code>scope_id</code> is
+     * set according to the given <code>nif</code> and the
+     * <code>addr<code> type(e.g. site local or link local).
+     * 
+     * @param host
+     *            host name associated with the address
+     * @param addr
+     *            network address
+     * @param nif
+     *            the Network Interface that this address is associated with.
+     * @return an Inet6Address instance
+     * @throws UnknownHostException
+     *             if the address is null or of invalid length, or the
+     *             interface doesn't have a numeric scope id for the given
+     *             address type.
+     */
+    public static Inet6Address getByAddress(String host, byte[] addr,
+            NetworkInterface nif) throws UnknownHostException {
+
+        Inet6Address address = Inet6Address.getByAddress(host, addr, 0);
+
+        // if nif is null, nothing needs to be set.
+        if (null == nif) {
+            return address;
+        }
+
+        // find the first address which matches the type addr,
+        // then set the scope_id, ifname and scopedIf.
+        Enumeration<InetAddress> addressList = nif.getInetAddresses();
+        while (addressList.hasMoreElements()) {
+            InetAddress ia = addressList.nextElement();
+            if (ia.getAddress().length == 16) {
+                Inet6Address v6ia = (Inet6Address) ia;
+                boolean isSameType = v6ia.compareLocalType(address);
+                if (isSameType) {
+                    address.scope_id_set = true;
+                    address.scope_id = v6ia.scope_id;
+                    address.scope_ifname_set = true;
+                    address.ifname = nif.getName();
+                    address.scopedIf = nif;
+                    break;
+                }
+            }
+        }
+        // if no address matches the type of addr, throws an
+        // UnknownHostException.
+        if (!address.scope_id_set) {
+            // KA021=Scope id is not found for the given address
+            throw new UnknownHostException(Msg.getString("KA021")); //$NON-NLS-1$
+        }
+        return address;
+    }
+
+    /**
+     * Returns true if one of following cases is true: 1. both addresses are
+     * site local; 2. both addresses are link local; 3. ia is neither site local
+     * nor link local;
+     */
+    private boolean compareLocalType(Inet6Address ia) {
+        if (ia.isSiteLocalAddress() && isSiteLocalAddress()) {
+            return true;
+        }
+        if (ia.isLinkLocalAddress() && isLinkLocalAddress()) {
+            return true;
+        }
+        if (!ia.isSiteLocalAddress() && !ia.isLinkLocalAddress()) {
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * Constructs an InetAddress, representing the <code>address</code> and
+     * <code>hostName</code> and <code>scope_id</code>
+     * 
+     * @param address
+     *            network address
+     * @param scope_id
+     *            The scope id for link or site local addresses
+     */
+    Inet6Address(byte address[], int scope_id) {
+        ipaddress = address;
+        this.scope_id = scope_id;
+        if (scope_id != 0) {
+            scope_id_set = true;
+        }
+    }
 
-		// Multicast addresses are prefixed with 11111111 (255)
-		return ipaddress[0] == -1;
-	}
-
-	/**
-	 * Answer true if the InetAddress is the unspecified address "::".
-	 * 
-	 * @return boolean true, if the address is in the multicast group, false
-	 *         otherwise
-	 */
-	@Override
+    /**
+     * Answer true if the InetAddress is an IP multicast address.
+     * 
+     * Valid IPv6 multicast address have the binary prefixed with 11111111 or FF
+     * (hex).
+     * 
+     * @return boolean true, if the address is in the multicast group, false
+     *         otherwise
+     */
+    @Override
+    public boolean isMulticastAddress() {
+        // Multicast addresses are prefixed with 11111111 (255)
+        return ipaddress[0] == -1;
+    }
+
+    /**
+     * Answer true if the InetAddress is the unspecified address "::".
+     * 
+     * @return boolean true, if the address is in the multicast group, false
+     *         otherwise
+     */
+    @Override
     public boolean isAnyLocalAddress() {
-		for (int i = 0; i < ipaddress.length; i++) {
-			if (ipaddress[i] != 0) {
+        for (int i = 0; i < ipaddress.length; i++) {
+            if (ipaddress[i] != 0) {
                 return false;
             }
-		}
-		return true;
-	}
-
-	/**
-	 * Answer true if the InetAddress is the loopback address
-	 * 
-	 * The valid IPv6 loopback address is ::1
-	 * 
-	 * @return boolean true if the address is the loopback, false otherwise
-	 */
-	@Override
+        }
+        return true;
+    }
+
+    /**
+     * Answer true if the InetAddress is the loopback address
+     * 
+     * The valid IPv6 loopback address is ::1
+     * 
+     * @return boolean true if the address is the loopback, false otherwise
+     */
+    @Override
     public boolean isLoopbackAddress() {
 
-		// The last word must be 1
-		if (ipaddress[15] != 1) {
-			return false;
-		}
-
-		// All other words must be 0
-		for (int i = 0; i < 15; i++) {
-			if (ipaddress[i] != 0) {
-				return false;
-			}
-		}
-
-		return true;
-	}
-
-	/**
-	 * Answer true if the InetAddress is a link-local address.
-	 * 
-	 * A valid IPv6 link-local address is prefixed with 1111111010
-	 * 
-	 * @return boolean true, if it is a link-local address, false otherwise
-	 */
-	@Override
+        // The last word must be 1
+        if (ipaddress[15] != 1) {
+            return false;
+        }
+
+        // All other words must be 0
+        for (int i = 0; i < 15; i++) {
+            if (ipaddress[i] != 0) {
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+    /**
+     * Answer true if the InetAddress is a link-local address.
+     * 
+     * A valid IPv6 link-local address is prefixed with 1111111010
+     * 
+     * @return boolean true, if it is a link-local address, false otherwise
+     */
+    @Override
     public boolean isLinkLocalAddress() {
 
-		// the first 10 bits need to be 1111111010 (1018)
-		return (ipaddress[0] == -2) && ((ipaddress[1] & 255) >>> 6) == 2;
-	}
-
-	/**
-	 * Answer true if the InetAddress is a site-local address.
-	 * 
-	 * A valid IPv6 site-local address is prefixed with 1111111011
-	 * 
-	 * @return boolean true, if it is a site-local address, false otherwise
-	 */
-	@Override
+        // the first 10 bits need to be 1111111010 (1018)
+        return (ipaddress[0] == -2) && ((ipaddress[1] & 255) >>> 6) == 2;
+    }
+
+    /**
+     * Answer true if the InetAddress is a site-local address.
+     * 
+     * A valid IPv6 site-local address is prefixed with 1111111011
+     * 
+     * @return boolean true, if it is a site-local address, false otherwise
+     */
+    @Override
     public boolean isSiteLocalAddress() {
 
-		// the first 10 bits need to be 1111111011 (1019)
-		return (ipaddress[0] == -2) && ((ipaddress[1] & 255) >>> 6) == 3;
-	}
-
-	/**
-	 * Answer true if the InetAddress is a global multicast address.
-	 * 
-	 * A valid IPv6 global multicast address is 11111111xxxx1110 (i.e. FF0E)
-	 * 
-	 * @return boolean true, if it is a global multicast address, false
-	 *         otherwise
-	 */
-	@Override
+        // the first 10 bits need to be 1111111011 (1019)
+        return (ipaddress[0] == -2) && ((ipaddress[1] & 255) >>> 6) == 3;
+    }
+
+    /**
+     * Answer true if the InetAddress is a global multicast address.
+     * 
+     * A valid IPv6 global multicast address is 11111111xxxx1110 (i.e. FF0E)
+     * 
+     * @return boolean true, if it is a global multicast address, false
+     *         otherwise
+     */
+    @Override
     public boolean isMCGlobal() {
-
-		// the first byte should be 0xFF and the lower 4 bits
-		// of the second byte should be 0xE
-		return (ipaddress[0] == -1) && (ipaddress[1] & 15) == 14;
-	}
-
-	/**
-	 * Answer true if the InetAddress is a node-local multicast address.
-	 * 
-	 * A valid IPv6 node-local multicast address is prefixed with
-	 * 11111111xxxx0001
-	 * 
-	 * @return boolean true, if it is a node-local multicast address, false
-	 *         otherwise
-	 */
-	@Override
+        // the first byte should be 0xFF and the lower 4 bits
+        // of the second byte should be 0xE
+        return (ipaddress[0] == -1) && (ipaddress[1] & 15) == 14;
+    }
+
+    /**
+     * Answer true if the InetAddress is a node-local multicast address.
+     * 
+     * A valid IPv6 node-local multicast address is prefixed with
+     * 11111111xxxx0001
+     * 
+     * @return boolean true, if it is a node-local multicast address, false
+     *         otherwise
+     */
+    @Override
     public boolean isMCNodeLocal() {
-
-		// the first byte should be 0xFF and the lower 4 bits
-		// of the second byte should be 0x1
-		return (ipaddress[0] == -1) && (ipaddress[1] & 15) == 1;
-
-	}
-
-	/**
-	 * Answer true if the InetAddress is a link-local multicast address.
-	 * 
-	 * A valid IPv6 link-local multicast address is prefixed with
-	 * 11111111xxxx0010
-	 * 
-	 * @return boolean true, if it is a link-local multicast address, false
-	 *         otherwise
-	 */
-	@Override
+        // the first byte should be 0xFF and the lower 4 bits
+        // of the second byte should be 0x1
+        return (ipaddress[0] == -1) && (ipaddress[1] & 15) == 1;
+    }
+
+    /**
+     * Answer true if the InetAddress is a link-local multicast address.
+     * 
+     * A valid IPv6 link-local multicast address is prefixed with
+     * 11111111xxxx0010
+     * 
+     * @return boolean true, if it is a link-local multicast address, false
+     *         otherwise
+     */
+    @Override
     public boolean isMCLinkLocal() {
-
-		// the first byte should be 0xFF and the lower 4 bits
-		// of the second byte should be 0x2
-		return (ipaddress[0] == -1) && (ipaddress[1] & 15) == 2;
-
-	}
-
-	/**
-	 * Answer true if the InetAddress is a site-local multicast address.
-	 * 
-	 * A valid IPv6 site-local multicast address is prefixed with
-	 * 11111111xxxx0101
-	 * 
-	 * @return boolean true, if it is a site-local multicast address, false
-	 *         otherwise
-	 */
-	@Override
+        // the first byte should be 0xFF and the lower 4 bits
+        // of the second byte should be 0x2
+        return (ipaddress[0] == -1) && (ipaddress[1] & 15) == 2;
+    }
+
+    /**
+     * Answer true if the InetAddress is a site-local multicast address.
+     * 
+     * A valid IPv6 site-local multicast address is prefixed with
+     * 11111111xxxx0101
+     * 
+     * @return boolean true, if it is a site-local multicast address, false
+     *         otherwise
+     */
+    @Override
     public boolean isMCSiteLocal() {
-
-		// the first byte should be 0xFF and the lower 4 bits
-		// of the second byte should be 0x5
-		return (ipaddress[0] == -1) && (ipaddress[1] & 15) == 5;
-
-	}
-
-	/**
-	 * Answer true if the InetAddress is a org-local multicast address.
-	 * 
-	 * A valid IPv6 org-local multicast address is prefixed with
-	 * 11111111xxxx1000
-	 * 
-	 * @return boolean true, if it is a org-local multicast address, false
-	 *         otherwise
-	 */
-	@Override
+        // the first byte should be 0xFF and the lower 4 bits
+        // of the second byte should be 0x5
+        return (ipaddress[0] == -1) && (ipaddress[1] & 15) == 5;
+    }
+
+    /**
+     * Answer true if the InetAddress is a org-local multicast address.
+     * 
+     * A valid IPv6 org-local multicast address is prefixed with
+     * 11111111xxxx1000
+     * 
+     * @return boolean true, if it is a org-local multicast address, false
+     *         otherwise
+     */
+    @Override
     public boolean isMCOrgLocal() {
+        // the first byte should be 0xFF and the lower 4 bits
+        // of the second byte should be 0x8
+        return (ipaddress[0] == -1) && (ipaddress[1] & 15) == 8;
+    }
 
-		// the first byte should be 0xFF and the lower 4 bits
-		// of the second byte should be 0x8
-		return (ipaddress[0] == -1) && (ipaddress[1] & 15) == 8;
-	}
-
-	@Override
+    @Override
     public String getHostAddress() {
-		return Inet6Util.createIPAddrStringFromByteArray(ipaddress);
-	}
-	
-	/**
-	 * Returns the <code>scope id</code> of this address if it is associated
-	 * with an interface. Otherwise returns zero.
-	 * 
-	 * @return the scope_id.
-	 */
-	public int getScopeId() {
-		if(scope_id_set){
-			return scope_id;
-		}
-		return 0;
-	}
-
-	/**
-	 * Returns the network interface if this address is instanced with a scoped
-	 * network interface. Otherwise returns null.
-	 * 
-	 * @return the scoped network interface.
-	 */
-	public NetworkInterface getScopedInterface() {
-		if(scope_ifname_set){
-			return scopedIf;
-		}
-		return null;
-	}
-	
-	@Override
+        return Inet6Util.createIPAddrStringFromByteArray(ipaddress);
+    }
+
+    /**
+     * Returns the <code>scope id</code> of this address if it is associated
+     * with an interface. Otherwise returns zero.
+     * 
+     * @return the scope_id.
+     */
+    public int getScopeId() {
+        if (scope_id_set) {
+            return scope_id;
+        }
+        return 0;
+    }
+
+    /**
+     * Returns the network interface if this address is instanced with a scoped
+     * network interface. Otherwise returns null.
+     * 
+     * @return the scoped network interface.
+     */
+    public NetworkInterface getScopedInterface() {
+        if (scope_ifname_set) {
+            return scopedIf;
+        }
+        return null;
+    }
+
+    /**
+     * Returns the hashcode of the receiver.
+     * 
+     * @return the hashcode
+     */
+    @Override
     public int hashCode() {
-		/* Returns the low order int as the hash code */
-		return bytesToInt(ipaddress, 12);
-	}
-
-	/**
-	 * Returns true if obj is of the same type as the IPv6 address and they have
-	 * the same IP address, false otherwise. the scope id does not seem to be
-	 * part of the comparison
-	 * 
-	 * @return String
-	 * 
-	 */
-	@Override
+        /* Returns the low order int as the hash code */
+        return bytesToInt(ipaddress, 12);
+    }
+
+    /**
+     * Returns true if obj is of the same type as the IPv6 address and they have
+     * the same IP address, false otherwise. the scope id does not seem to be
+     * part of the comparison
+     * 
+     * @return String
+     * 
+     */
+    @Override
     public boolean equals(Object obj) {
-		return super.equals(obj);
-	}
+        return super.equals(obj);
+    }
 
-	/**
-	 * An IPv4 compatible address is prefixed with 96 bits of 0's. The last
-	 * 32-bits are varied corresponding with the 32-bit IPv4 address space.
-	 */
-	public boolean isIPv4CompatibleAddress() {
-		for (int i = 0; i < 12; i++) {
-			if (ipaddress[i] != 0) {
-				return false;
-			}
-		}
-		return true;
-	}
-
-	private static final ObjectStreamField[] serialPersistentFields = {
-			new ObjectStreamField("ipaddress", new byte[0].getClass()),
-			new ObjectStreamField("scope_id", Integer.TYPE),
-			new ObjectStreamField("scope_id_set", Boolean.TYPE),
-            new ObjectStreamField("scope_ifname_set", Boolean.TYPE),
-            new ObjectStreamField("ifname", String.class),};
-
-	private void writeObject(ObjectOutputStream stream) throws IOException {
-		ObjectOutputStream.PutField fields = stream.putFields();
-		if (ipaddress == null) {
-			fields.put("ipaddress", null);
-		} else {
-			fields.put("ipaddress", ipaddress);
-		}
-
-		fields.put("scope_id", scope_id);
-		fields.put("scope_id_set", scope_id_set);
-        fields.put("scope_ifname_set", scope_ifname_set);
-        fields.put("ifname", ifname);
-		stream.writeFields();
-	}
-
-	private void readObject(ObjectInputStream stream) throws IOException,
-			ClassNotFoundException {
-		ObjectInputStream.GetField fields = stream.readFields();
-		ipaddress = (byte[]) fields.get("ipaddress", null);
-		scope_id = fields.get("scope_id", 0);
-		scope_id_set = fields.get("scope_id_set", false);
-        ifname = (String)fields.get("ifname", null);
-        scope_ifname_set = fields.get("scope_ifname_set", false);
-        if (scope_ifname_set && null != ifname){
+    /**
+     * An IPv4 compatible address is prefixed with 96 bits of 0's. The last
+     * 32-bits are varied corresponding with the 32-bit IPv4 address space.
+     */
+    public boolean isIPv4CompatibleAddress() {
+        for (int i = 0; i < 12; i++) {
+            if (ipaddress[i] != 0) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    private static final ObjectStreamField[] serialPersistentFields = {
+            new ObjectStreamField("ipaddress", new byte[0].getClass()), //$NON-NLS-1$
+            new ObjectStreamField("scope_id", Integer.TYPE), //$NON-NLS-1$
+            new ObjectStreamField("scope_id_set", Boolean.TYPE), //$NON-NLS-1$
+            new ObjectStreamField("scope_ifname_set", Boolean.TYPE), //$NON-NLS-1$
+            new ObjectStreamField("ifname", String.class), }; //$NON-NLS-1$
+
+    private void writeObject(ObjectOutputStream stream) throws IOException {
+        ObjectOutputStream.PutField fields = stream.putFields();
+        if (ipaddress == null) {
+            fields.put("ipaddress", null); //$NON-NLS-1$
+        } else {
+            fields.put("ipaddress", ipaddress); //$NON-NLS-1$
+        }
+
+        fields.put("scope_id", scope_id); //$NON-NLS-1$
+        fields.put("scope_id_set", scope_id_set); //$NON-NLS-1$
+        fields.put("scope_ifname_set", scope_ifname_set); //$NON-NLS-1$
+        fields.put("ifname", ifname); //$NON-NLS-1$
+        stream.writeFields();
+    }
+
+    private void readObject(ObjectInputStream stream) throws IOException,
+            ClassNotFoundException {
+        ObjectInputStream.GetField fields = stream.readFields();
+        ipaddress = (byte[]) fields.get("ipaddress", null); //$NON-NLS-1$
+        scope_id = fields.get("scope_id", 0); //$NON-NLS-1$
+        scope_id_set = fields.get("scope_id_set", false); //$NON-NLS-1$
+        ifname = (String) fields.get("ifname", null); //$NON-NLS-1$
+        scope_ifname_set = fields.get("scope_ifname_set", false); //$NON-NLS-1$
+        if (scope_ifname_set && null != ifname) {
             scopedIf = NetworkInterface.getByName(ifname);
         }
-	}
+    }
 
-	/**
-	 * Answers a string containing a concise, human-readable description of the
-	 * address.
-	 * 
-	 * @return String the description, as host/address
-	 */
-	@Override
+    /**
+     * Answers a string containing a concise, human-readable description of the
+     * address.
+     * 
+     * @return String the description, as host/address
+     */
+    @Override
     public String toString() {
-		if (ifname != null) {
-			return super.toString() + "%" + ifname;
-		}
-		if (scope_id != 0) {
-			return super.toString() + "%" + scope_id;
-		}
-		return super.toString();
-	}
+        if (ifname != null) {
+            return super.toString() + "%" + ifname; //$NON-NLS-1$
+        }
+        if (scope_id != 0) {
+            return super.toString() + "%" + scope_id; //$NON-NLS-1$
+        }
+        return super.toString();
+    }
 }



Mime
View raw message