harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r493040 [5/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/JarURLConnection.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/JarURLConnection.java?view=diff&rev=493040&r1=493039&r2=493040
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/JarURLConnection.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/JarURLConnection.java Fri Jan  5 06:44:04 2007
@@ -17,7 +17,6 @@
 
 package java.net;
 
-
 import java.io.IOException;
 import java.security.cert.Certificate;
 import java.util.jar.Attributes;
@@ -31,147 +30,149 @@
  * where "!/" is called a seperator.
  */
 public abstract class JarURLConnection extends URLConnection {
-	// the location of the seperator
-	protected URLConnection jarFileURLConnection;
 
-	private String entryName;
+    // the location of the separator
+    protected URLConnection jarFileURLConnection;
+
+    private String entryName;
 
-	private URL fileURL;
+    private URL fileURL;
 
-	// the file component of the URL
-	private String file;
-
-	/**
-	 * Contructs an instance of <code>JarURLConnection</code>.
-	 * 
-	 * @param url
-	 *            java.net.URL the URL that contains the location to connect to
-	 */
-	protected JarURLConnection(URL url) throws MalformedURLException {
-		super(url);
-		file = url.getFile();
-		int sepIdx;
-		// Support embedded jar URLs by using lastIndexOf()
-		if ((sepIdx = file.lastIndexOf("!/")) < 0) {
-			throw new MalformedURLException();
-		}
-		if (file.length() == sepIdx + 2) {
-			return;
-		}
-		entryName = file.substring(sepIdx + 2, file.length());
-		if (null != url.getRef()) {
-			entryName += "#" + url.getRef();
-		}
-	}
-
-	/**
-	 * Answers the attributes of the JarEntry referenced by this
-	 * <code>JarURLConnection</code>.
-	 * 
-	 * @return java.util.jar.Attributes the attributes of the the JarEntry
-	 * @exception java.io.IOException
-	 *                thrown if an IO exception occurs while retrieving the
-	 *                JarEntry
-	 */
-	public Attributes getAttributes() throws java.io.IOException {
-		JarEntry jEntry = getJarEntry();
-		return (jEntry == null) ? null : jEntry.getAttributes();
-	}
-
-	/**
-	 * Answers the Certificates of the JarEntry referenced by this
-	 * <code>URLConnection</code>. This method will return null until the
-	 * InputStream has been completely verified
-	 * 
-	 * @return Certificate[] the Certificates of the JarEntry.
-	 * @exception java.io.IOException
-	 *                thrown if there is an IO exception occurs while getting
-	 *                the JarEntry.
-	 */
-	public Certificate[] getCertificates() throws java.io.IOException {
-		JarEntry jEntry = getJarEntry();
-		if (jEntry == null)
-			return null;
-
-		return jEntry.getCertificates();
-
-	}
-
-	/**
-	 * Answers the JarEntry name of the entry referenced by this
-	 * <code>URLConnection</code>.
-	 * 
-	 * @return java.lang.String the JarEntry name
-	 */
-	public String getEntryName() {
-		return entryName;
-	}
-
-	/**
-	 * Answers the JarEntry of the entry referenced by this
-	 * <code>URLConnection</code>.
-	 * 
-	 * @return java.util.jar.JarEntry the JarEntry referenced
-	 */
-	public JarEntry getJarEntry() throws IOException {
-		if (!connected) {
-			connect();
-		}
-		if (entryName == null) {
-			return null;
-		}
-		// The entry must exist since the connect succeeded
-		return getJarFile().getJarEntry(entryName);
-	}
-
-	/**
-	 * Answers the Manifest associated with the Jar URL
-	 * 
-	 * @return java.util.jar.Manifest The JarFile's Manifest
-	 */
-	public Manifest getManifest() throws java.io.IOException {
-		return getJarFile().getManifest();
-	}
-
-	/**
-	 * Answers the the JarFile referenced by this <code>URLConnection</code>.
-	 * 
-	 * @return java.util.jar.JarFile the JarFile
-	 * @exception java.io.IOException
-	 *                thrown if an IO exception occurs while retrieving the Jar
-	 *                file
-	 */
-	public abstract JarFile getJarFile() throws java.io.IOException;
-
-	/**
-	 * Answers the URL of the JarFile referenced by this
-	 * <code>URLConnection</code>.
-	 * 
-	 * @return java.net.URL the URL of the JarFile.
-	 */
-	public URL getJarFileURL() {
-		if (fileURL != null)
-			return fileURL;
-		try {
-			// Support embedded jar URLs by using lastIndexOf()
-			return fileURL = new URL(url.getFile().substring(0,
-					url.getFile().lastIndexOf("!/")));
-		} catch (MalformedURLException e) {
-			return null;
-		}
-	}
-
-	/**
-	 * Answers the main Attributes of the JarFile referenced by this
-	 * <code>URLConnection</code>.
-	 * 
-	 * @return java.util.jar.Attributes the Attributes of the the JarFile
-	 * @exception java.io.IOException
-	 *                thrown if an IO exception occurs while retrieving the
-	 *                JarFile
-	 */
-	public Attributes getMainAttributes() throws java.io.IOException {
-		Manifest m = getJarFile().getManifest();
-		return (m == null) ? null : m.getMainAttributes();
-	}
+    // the file component of the URL
+    private String file;
+
+    /**
+     * Contructs an instance of <code>JarURLConnection</code>.
+     * 
+     * @param url
+     *            java.net.URL the URL that contains the location to connect to
+     */
+    protected JarURLConnection(URL url) throws MalformedURLException {
+        super(url);
+        file = url.getFile();
+        int sepIdx;
+        // Support embedded jar URLs by using lastIndexOf()
+        if ((sepIdx = file.lastIndexOf("!/")) < 0) { //$NON-NLS-1$
+            throw new MalformedURLException();
+        }
+        if (file.length() == sepIdx + 2) {
+            return;
+        }
+        entryName = file.substring(sepIdx + 2, file.length());
+        if (null != url.getRef()) {
+            entryName += "#" + url.getRef(); //$NON-NLS-1$
+        }
+    }
+
+    /**
+     * Answers the attributes of the JarEntry referenced by this
+     * <code>JarURLConnection</code>.
+     * 
+     * @return java.util.jar.Attributes the attributes of the the JarEntry
+     * @exception java.io.IOException
+     *                thrown if an IO exception occurs while retrieving the
+     *                JarEntry
+     */
+    public Attributes getAttributes() throws java.io.IOException {
+        JarEntry jEntry = getJarEntry();
+        return (jEntry == null) ? null : jEntry.getAttributes();
+    }
+
+    /**
+     * Answers the Certificates of the JarEntry referenced by this
+     * <code>URLConnection</code>. This method will return null until the
+     * InputStream has been completely verified
+     * 
+     * @return Certificate[] the Certificates of the JarEntry.
+     * @exception java.io.IOException
+     *                thrown if there is an IO exception occurs while getting
+     *                the JarEntry.
+     */
+    public Certificate[] getCertificates() throws java.io.IOException {
+        JarEntry jEntry = getJarEntry();
+        if (jEntry == null) {
+            return null;
+        }
+
+        return jEntry.getCertificates();
+    }
+
+    /**
+     * Answers the JarEntry name of the entry referenced by this
+     * <code>URLConnection</code>.
+     * 
+     * @return java.lang.String the JarEntry name
+     */
+    public String getEntryName() {
+        return entryName;
+    }
+
+    /**
+     * Answers the JarEntry of the entry referenced by this
+     * <code>URLConnection</code>.
+     * 
+     * @return java.util.jar.JarEntry the JarEntry referenced
+     */
+    public JarEntry getJarEntry() throws IOException {
+        if (!connected) {
+            connect();
+        }
+        if (entryName == null) {
+            return null;
+        }
+        // The entry must exist since the connect succeeded
+        return getJarFile().getJarEntry(entryName);
+    }
+
+    /**
+     * Answers the Manifest associated with the Jar URL
+     * 
+     * @return java.util.jar.Manifest The JarFile's Manifest
+     */
+    public Manifest getManifest() throws java.io.IOException {
+        return getJarFile().getManifest();
+    }
+
+    /**
+     * Answers the the JarFile referenced by this <code>URLConnection</code>.
+     * 
+     * @return java.util.jar.JarFile the JarFile
+     * @exception java.io.IOException
+     *                thrown if an IO exception occurs while retrieving the Jar
+     *                file
+     */
+    public abstract JarFile getJarFile() throws java.io.IOException;
+
+    /**
+     * Answers the URL of the JarFile referenced by this
+     * <code>URLConnection</code>.
+     * 
+     * @return java.net.URL the URL of the JarFile.
+     */
+    public URL getJarFileURL() {
+        if (fileURL != null) {
+            return fileURL;
+        }
+        try {
+            // Support embedded jar URLs by using lastIndexOf()
+            return fileURL = new URL(url.getFile().substring(0,
+                    url.getFile().lastIndexOf("!/"))); //$NON-NLS-1$
+        } catch (MalformedURLException e) {
+            return null;
+        }
+    }
+
+    /**
+     * Answers the main Attributes of the JarFile referenced by this
+     * <code>URLConnection</code>.
+     * 
+     * @return java.util.jar.Attributes the Attributes of the the JarFile
+     * @exception java.io.IOException
+     *                thrown if an IO exception occurs while retrieving the
+     *                JarFile
+     */
+    public Attributes getMainAttributes() throws java.io.IOException {
+        Manifest m = getJarFile().getManifest();
+        return (m == null) ? null : m.getMainAttributes();
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/MalformedURLException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/MalformedURLException.java?view=diff&rev=493040&r1=493039&r2=493040
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/MalformedURLException.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/MalformedURLException.java Fri Jan  5 06:44:04 2007
@@ -15,10 +15,8 @@
  *  limitations under the License.
  */
 
-
 package java.net;
 
-
 import java.io.IOException;
 
 /**
@@ -32,20 +30,20 @@
     private static final long serialVersionUID = -182787522200415866L;
 
     /**
-	 * Constructs a new instance of this class with its walkback filled in.
-	 */
-	public MalformedURLException() {
-		super();
-	}
+     * Constructs a new instance of this class with its walkback filled in.
+     */
+    public MalformedURLException() {
+        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 MalformedURLException(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 MalformedURLException(String detailMessage) {
+        super(detailMessage);
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/MulticastSocket.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/MulticastSocket.java?view=diff&rev=493040&r1=493039&r2=493040
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/MulticastSocket.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/MulticastSocket.java Fri Jan  5 06:44:04 2007
@@ -17,7 +17,6 @@
 
 package java.net;
 
-
 import java.io.IOException;
 import java.util.Enumeration;
 
@@ -32,600 +31,594 @@
  */
 public class MulticastSocket extends DatagramSocket {
 
-	final static int SO_REUSEPORT = 512;
+    final static int SO_REUSEPORT = 512;
 
-	private InetAddress interfaceSet;
+    private InetAddress interfaceSet;
 
-	/**
-	 * Constructs a multicast socket, bound to any available port on the
-	 * localhost.
-	 * 
-	 * @throws IOException
-	 *             if a problem occurs creating or binding the socket
-	 */
-	public MulticastSocket() throws IOException {
-		super();
+    /**
+     * Constructs a multicast socket, bound to any available port on the
+     * localhost.
+     * 
+     * @throws IOException
+     *             if a problem occurs creating or binding the socket
+     */
+    public MulticastSocket() throws IOException {
+        super();
         setReuseAddress(true);
-	}
+    }
 
-	/**
-	 * Answers a multicast socket, bound to the nominated port on the localhost.
-	 * 
-	 * @param aPort
-	 *            the port to bind on the localhost
-	 * 
-	 * @throws IOException
-	 *             if a problem occurs creating or binding the socket
-	 */
-	public MulticastSocket(int aPort) throws IOException {
-		super(aPort);
+    /**
+     * Answers a multicast socket, bound to the nominated port on the localhost.
+     * 
+     * @param aPort
+     *            the port to bind on the localhost
+     * 
+     * @throws IOException
+     *             if a problem occurs creating or binding the socket
+     */
+    public MulticastSocket(int aPort) throws IOException {
+        super(aPort);
         setReuseAddress(true);
-	}
+    }
 
-	/**
-	 * Answer the network address used by the socket. This is useful on
-	 * multi-homed machines.
-	 * 
-	 * @return java.net.InetAddress the network address
-	 * @exception java.net.SocketException
-	 *                The exception thrown while getting the address
-	 */
-	public InetAddress getInterface() throws SocketException {
-		checkClosedAndBind(false);
-		if (interfaceSet == null) {
-			InetAddress ipvXaddress = (InetAddress) impl
-					.getOption(SocketOptions.IP_MULTICAST_IF);
-			if (ipvXaddress.isAnyLocalAddress()) {
-				// the address was not set at the IPV4 level so check the IPV6
-				// level
-				NetworkInterface theInterface = getNetworkInterface();
-				if (theInterface != null) {
-					Enumeration<InetAddress> addresses = theInterface.getInetAddresses();
-					if (addresses != null) {
-						while (addresses.hasMoreElements()) {
-							InetAddress nextAddress = addresses.nextElement();
+    /**
+     * Answer the network address used by the socket. This is useful on
+     * multi-homed machines.
+     * 
+     * @return java.net.InetAddress the network address
+     * @exception java.net.SocketException
+     *                The exception thrown while getting the address
+     */
+    public InetAddress getInterface() throws SocketException {
+        checkClosedAndBind(false);
+        if (interfaceSet == null) {
+            InetAddress ipvXaddress = (InetAddress) impl
+                    .getOption(SocketOptions.IP_MULTICAST_IF);
+            if (ipvXaddress.isAnyLocalAddress()) {
+                // the address was not set at the IPV4 level so check the IPV6
+                // level
+                NetworkInterface theInterface = getNetworkInterface();
+                if (theInterface != null) {
+                    Enumeration<InetAddress> addresses = theInterface
+                            .getInetAddresses();
+                    if (addresses != null) {
+                        while (addresses.hasMoreElements()) {
+                            InetAddress nextAddress = addresses.nextElement();
                             if (nextAddress instanceof Inet6Address) {
                                 return nextAddress;
                             }
-						}
-					}
-				}
-			}
-			return ipvXaddress;
-		}
-		return interfaceSet;
-	}
-
-	/**
-	 * Answer the network interface used by the socket. This is useful on
-	 * multi-homed machines.
-	 * 
-	 * @return java.net.NetworkInterface the network address
-	 * @exception java.net.SocketException
-	 *                The exception thrown while getting the address
-	 * 
-	 * @since 1.4
-	 */
-	public NetworkInterface getNetworkInterface() throws SocketException {
-		checkClosedAndBind(false);
-
-		// check if it is set at the IPV6 level. If so then use that. Otherwise
-		// do it at the IPV4 level
-		Integer theIndex = Integer.valueOf(0);
-		try {
-			theIndex = (Integer) impl.getOption(SocketOptions.IP_MULTICAST_IF2);
-		} catch (SocketException e) {
-			// we may get an exception if IPV6 is not enabled.
-		}
-
-		if (theIndex.intValue() != 0) {
-			Enumeration<NetworkInterface> theInterfaces = NetworkInterface.getNetworkInterfaces();
-			while (theInterfaces.hasMoreElements()) {
-				NetworkInterface nextInterface = theInterfaces.nextElement();
+                        }
+                    }
+                }
+            }
+            return ipvXaddress;
+        }
+        return interfaceSet;
+    }
+
+    /**
+     * Answer the network interface used by the socket. This is useful on
+     * multi-homed machines.
+     * 
+     * @return java.net.NetworkInterface the network address
+     * @exception java.net.SocketException
+     *                The exception thrown while getting the address
+     * 
+     * @since 1.4
+     */
+    public NetworkInterface getNetworkInterface() throws SocketException {
+        checkClosedAndBind(false);
+
+        // check if it is set at the IPV6 level. If so then use that. Otherwise
+        // do it at the IPV4 level
+        Integer theIndex = Integer.valueOf(0);
+        try {
+            theIndex = (Integer) impl.getOption(SocketOptions.IP_MULTICAST_IF2);
+        } catch (SocketException e) {
+            // we may get an exception if IPV6 is not enabled.
+        }
+
+        if (theIndex.intValue() != 0) {
+            Enumeration<NetworkInterface> theInterfaces = NetworkInterface
+                    .getNetworkInterfaces();
+            while (theInterfaces.hasMoreElements()) {
+                NetworkInterface nextInterface = theInterfaces.nextElement();
                 if (nextInterface.getIndex() == theIndex.intValue()) {
                     return nextInterface;
                 }
-			}
-		}
+            }
+        }
 
-		// ok it was not set at the IPV6 level so try at the IPV4 level
-		InetAddress theAddress = (InetAddress) impl
-				.getOption(SocketOptions.IP_MULTICAST_IF);
-		if (theAddress != null) {
-			if (!theAddress.isAnyLocalAddress()) {
-				return NetworkInterface.getByInetAddress(theAddress);
-			}
-			
-			// not set as we got the any address so return a dummy network
-			// interface with only the any address. We do this to be
-			// compatible
-			InetAddress theAddresses[] = new InetAddress[1];
-			if ((Socket.preferIPv4Stack() == false)
-					&& (InetAddress.preferIPv6Addresses() == true)) {
-				theAddresses[0] = Inet6Address.ANY;
-			} else {
-				theAddresses[0] = InetAddress.ANY;
-			}
-			return new NetworkInterface(null, null, theAddresses,
-					NetworkInterface.UNSET_INTERFACE_INDEX);
-		}
-
-		// ok not set at all so return null
-		return null;
-	}
-
-	/**
-	 * Answer the time-to-live (TTL) for multicast packets sent on this socket.
-	 * 
-	 * @return java.net.InetAddress
-	 * @exception IOException
-	 *                The exception description.
-	 */
-	public int getTimeToLive() throws IOException {
-		checkClosedAndBind(false);
-		return impl.getTimeToLive();
-	}
-
-	/**
-	 * Answer the time-to-live (TTL) for multicast packets sent on this socket.
-	 * 
-	 * @return java.net.InetAddress
-	 * @exception IOException
-	 *                The exception description.
-	 * @deprecated Replaced by getTimeToLive
-	 * @see #getTimeToLive()
-	 */
-	@SuppressWarnings("deprecation")
+        // ok it was not set at the IPV6 level so try at the IPV4 level
+        InetAddress theAddress = (InetAddress) impl
+                .getOption(SocketOptions.IP_MULTICAST_IF);
+        if (theAddress != null) {
+            if (!theAddress.isAnyLocalAddress()) {
+                return NetworkInterface.getByInetAddress(theAddress);
+            }
+
+            // not set as we got the any address so return a dummy network
+            // interface with only the any address. We do this to be
+            // compatible
+            InetAddress theAddresses[] = new InetAddress[1];
+            if ((Socket.preferIPv4Stack() == false)
+                    && (InetAddress.preferIPv6Addresses() == true)) {
+                theAddresses[0] = Inet6Address.ANY;
+            } else {
+                theAddresses[0] = InetAddress.ANY;
+            }
+            return new NetworkInterface(null, null, theAddresses,
+                    NetworkInterface.UNSET_INTERFACE_INDEX);
+        }
+
+        // ok not set at all so return null
+        return null;
+    }
+
+    /**
+     * Answer the time-to-live (TTL) for multicast packets sent on this socket.
+     * 
+     * @return java.net.InetAddress
+     * @exception IOException
+     *                The exception description.
+     */
+    public int getTimeToLive() throws IOException {
+        checkClosedAndBind(false);
+        return impl.getTimeToLive();
+    }
+
+    /**
+     * Answer the time-to-live (TTL) for multicast packets sent on this socket.
+     * 
+     * @return java.net.InetAddress
+     * @exception IOException
+     *                The exception description.
+     * @deprecated Replaced by getTimeToLive
+     * @see #getTimeToLive()
+     */
+    @SuppressWarnings("deprecation")
     @Deprecated
     public byte getTTL() throws IOException {
-		checkClosedAndBind(false);
-		return impl.getTTL();
-	}
+        checkClosedAndBind(false);
+        return impl.getTTL();
+    }
 
-	@Override
+    @Override
     boolean isMulticastSocket() {
-		return true;
-	}
+        return true;
+    }
 
-	/**
-	 * Add this socket to the multicast group. A socket must joint a group
-	 * before data may be received. A socket may be a member of multiple groups
-	 * but may join any group once.
-	 * 
-	 * @param groupAddr
-	 *            the multicast group to be joined
-	 * @exception IOException
-	 *                may be thrown while joining a group
-	 */
-	public void joinGroup(InetAddress groupAddr) throws IOException {
-		checkClosedAndBind(false);
-		if (!groupAddr.isMulticastAddress()) {
-            throw new IOException(Msg.getString("K0039"));
+    /**
+     * Add this socket to the multicast group. A socket must joint a group
+     * before data may be received. A socket may be a member of multiple groups
+     * but may join any group once.
+     * 
+     * @param groupAddr
+     *            the multicast group to be joined
+     * @exception IOException
+     *                may be thrown while joining a group
+     */
+    public void joinGroup(InetAddress groupAddr) throws IOException {
+        checkClosedAndBind(false);
+        if (!groupAddr.isMulticastAddress()) {
+            throw new IOException(Msg.getString("K0039")); //$NON-NLS-1$
         }
-		SecurityManager security = System.getSecurityManager();
-		if (security != null) {
+        SecurityManager security = System.getSecurityManager();
+        if (security != null) {
             security.checkMulticast(groupAddr);
         }
-		impl.join(groupAddr);
-	}
+        impl.join(groupAddr);
+    }
+
+    /**
+     * Add this socket to the multicast group. A socket must join a group before
+     * data may be received. A socket may be a member of multiple groups but may
+     * join any group once.
+     * 
+     * @param groupAddress
+     *            the multicast group to be joined
+     * @param netInterface
+     *            the network interface on which the addresses should be dropped
+     * @exception IOException
+     *                will be thrown if address is not a multicast address
+     * @exception java.lang.SecurityException
+     *                will be thrown if caller is not authorized to join group
+     * @exception java.lang.IllegalArgumentException
+     *                will be through if groupAddr is null
+     * 
+     * @since 1.4
+     */
+    public void joinGroup(SocketAddress groupAddress,
+            NetworkInterface netInterface) throws IOException {
+        checkClosedAndBind(false);
+        if (null == groupAddress) {
+            throw new IllegalArgumentException(Msg.getString("K0318")); //$NON-NLS-1$
+        }
+
+        if ((netInterface != null) && (netInterface.getFirstAddress() == null)) {
+            // this is ok if we could set it at the
+            throw new SocketException(Msg.getString("K0335")); //$NON-NLS-1$
+        }
+
+        if (!(groupAddress instanceof InetSocketAddress)) {
+            throw new IllegalArgumentException(Msg.getString(
+                    "K0316", groupAddress.getClass())); //$NON-NLS-1$
+        }
+
+        InetAddress groupAddr = ((InetSocketAddress) groupAddress).getAddress();
+
+        if (groupAddr == null) {
+            throw new SocketException(Msg.getString("K0331")); //$NON-NLS-1$
+        }
+
+        if (!groupAddr.isMulticastAddress()) {
+            throw new IOException(Msg.getString("K0039")); //$NON-NLS-1$
+        }
+
+        SecurityManager security = System.getSecurityManager();
+        if (security != null) {
+            security.checkMulticast(groupAddr);
+        }
+        impl.joinGroup(groupAddress, netInterface);
+    }
+
+    /**
+     * Remove the socket from the multicast group.
+     * 
+     * @param groupAddr
+     *            the multicast group to be left
+     * @exception IOException
+     *                will be thrown if address is not a multicast address
+     * @exception java.lang.SecurityException
+     *                will be thrown if caller is not authorized to join group
+     * @exception java.lang.IllegalArgumentException
+     *                will be through if groupAddr is null
+     */
+    public void leaveGroup(InetAddress groupAddr) throws IOException {
+        checkClosedAndBind(false);
+        if (!groupAddr.isMulticastAddress()) {
+            throw new IOException(Msg.getString("K003a")); //$NON-NLS-1$
+        }
+        SecurityManager security = System.getSecurityManager();
+        if (security != null) {
+            security.checkMulticast(groupAddr);
+        }
+        impl.leave(groupAddr);
+    }
+
+    /**
+     * Remove the socket from the multicast group.
+     * 
+     * @param groupAddress
+     *            the multicast group to be left
+     * @param netInterface
+     *            the network interface on which the addresses should be dropped
+     * @exception IOException
+     *                will be thrown if address is not a multicast address
+     * @exception java.lang.SecurityException
+     *                will be thrown if caller is not authorized to join group
+     * @exception java.lang.IllegalArgumentException
+     *                will be through if groupAddr is null
+     * 
+     * @since 1.4
+     */
+    public void leaveGroup(SocketAddress groupAddress,
+            NetworkInterface netInterface) throws IOException {
+        checkClosedAndBind(false);
+        if (null == groupAddress) {
+            throw new IllegalArgumentException(Msg.getString("K0318")); //$NON-NLS-1$
+        }
+
+        if ((netInterface != null) && (netInterface.getFirstAddress() == null)) {
+            // this is ok if we could set it at the
+            throw new SocketException(Msg.getString("K0335")); //$NON-NLS-1$
+        }
+
+        if (!(groupAddress instanceof InetSocketAddress)) {
+            throw new IllegalArgumentException(Msg.getString(
+                    "K0316", groupAddress.getClass())); //$NON-NLS-1$
+        }
+
+        InetAddress groupAddr = ((InetSocketAddress) groupAddress).getAddress();
+
+        if (groupAddr == null) {
+            throw new SocketException(Msg.getString("K0331")); //$NON-NLS-1$
+        }
 
-	/**
-	 * Add this socket to the multicast group. A socket must join a group before
-	 * data may be received. A socket may be a member of multiple groups but may
-	 * join any group once.
-	 * 
-	 * @param groupAddress
-	 *            the multicast group to be joined
-	 * @param netInterface
-	 *            the network interface on which the addresses should be dropped
-	 * @exception IOException
-	 *                will be thrown if address is not a multicast address
-	 * @exception java.lang.SecurityException
-	 *                will be thrown if caller is not authorized to join group
-	 * @exception java.lang.IllegalArgumentException
-	 *                will be through if groupAddr is null
-	 * 
-	 * @since 1.4
-	 */
-	public void joinGroup(SocketAddress groupAddress,
-			NetworkInterface netInterface) throws IOException {
-		checkClosedAndBind(false);
-		if (null == groupAddress) {
-			throw new IllegalArgumentException(Msg.getString("K0318"));
-		}
-
-		if ((netInterface != null) && (netInterface.getFirstAddress() == null)) {
-			// this is ok if we could set it at the
-			throw new SocketException(Msg.getString("K0335"));
-		}
-
-		if (groupAddress instanceof InetSocketAddress) {
-			InetAddress groupAddr = ((InetSocketAddress) groupAddress)
-					.getAddress();
-
-			if (groupAddr == null) {
-				throw new SocketException(Msg.getString(
-						"K0331")); //$NON-NLS-1$
-			}
-
-			if (!groupAddr.isMulticastAddress()) {
-				throw new IOException(Msg.getString("K0039"));
-			}
-
-			SecurityManager security = System.getSecurityManager();
-			if (security != null) {
-				security.checkMulticast(groupAddr);
-			}
-			impl.joinGroup(groupAddress, netInterface);
-		} else {
-			throw new IllegalArgumentException(Msg.getString(
-					"K0316", groupAddress.getClass())); //$NON-NLS-1$
-		}
-	}
-
-	/**
-	 * Remove the socket from the multicast group.
-	 * 
-	 * @param groupAddr
-	 *            the multicast group to be left
-	 * @exception IOException
-	 *                will be thrown if address is not a multicast address
-	 * @exception java.lang.SecurityException
-	 *                will be thrown if caller is not authorized to join group
-	 * @exception java.lang.IllegalArgumentException
-	 *                will be through if groupAddr is null
-	 */
-	public void leaveGroup(InetAddress groupAddr) throws IOException {
-		checkClosedAndBind(false);
-		if (!groupAddr.isMulticastAddress()) {
-            throw new IOException(Msg.getString("K003a"));
+        if (!groupAddr.isMulticastAddress()) {
+            throw new IOException(Msg.getString("K003a")); //$NON-NLS-1$
         }
-		SecurityManager security = System.getSecurityManager();
-		if (security != null) {
+        SecurityManager security = System.getSecurityManager();
+        if (security != null) {
             security.checkMulticast(groupAddr);
         }
-		impl.leave(groupAddr);
-	}
+        impl.leaveGroup(groupAddress, netInterface);
+    }
 
-	/**
-	 * Remove the socket from the multicast group.
-	 * 
-	 * @param groupAddress
-	 *            the multicast group to be left
-	 * @param netInterface
-	 *            the network interface on which the addresses should be dropped
-	 * @exception IOException
-	 *                will be thrown if address is not a multicast address
-	 * @exception java.lang.SecurityException
-	 *                will be thrown if caller is not authorized to join group
-	 * @exception java.lang.IllegalArgumentException
-	 *                will be through if groupAddr is null
-	 * 
-	 * @since 1.4
-	 */
-	public void leaveGroup(SocketAddress groupAddress,
-			NetworkInterface netInterface) throws IOException {
-		checkClosedAndBind(false);
-		if (null == groupAddress) {
-			throw new IllegalArgumentException(Msg.getString("K0318"));
-		}
-
-		if ((netInterface != null) && (netInterface.getFirstAddress() == null)) {
-			// this is ok if we could set it at the
-			throw new SocketException(Msg.getString("K0335"));
-		}
-
-		if (groupAddress instanceof InetSocketAddress) {
-			InetAddress groupAddr = ((InetSocketAddress) groupAddress)
-					.getAddress();
-
-			if (groupAddr == null) {
-				throw new SocketException(Msg.getString(
-						"K0331")); //$NON-NLS-1$
-			}
-
-			if (!groupAddr.isMulticastAddress()) {
-				throw new IOException(Msg.getString("K003a"));
-			}
-			SecurityManager security = System.getSecurityManager();
-			if (security != null) {
-				security.checkMulticast(groupAddr);
-			}
-			impl.leaveGroup(groupAddress, netInterface);
-		} else {
-			throw new IllegalArgumentException(Msg.getString(
-					"K0316", groupAddress.getClass())); //$NON-NLS-1$
-		}
-	}
-
-	/**
-	 * Send the packet on this socket. The packet must satisfy the security
-	 * policy before it may be sent.
-	 * 
-	 * @param pack
-	 *            the DatagramPacket to send
-	 * @param ttl
-	 *            the TTL setting for this transmission, overriding the socket
-	 *            default
-	 * 
-	 * @exception IOException
-	 *                If a send error occurs.
-	 * 
-	 * @deprecated use MulticastSocket#setTimeToLive
-	 */
-	@SuppressWarnings("deprecation")
+    /**
+     * Send the packet on this socket. The packet must satisfy the security
+     * policy before it may be sent.
+     * 
+     * @param pack
+     *            the DatagramPacket to send
+     * @param ttl
+     *            the TTL setting for this transmission, overriding the socket
+     *            default
+     * 
+     * @exception IOException
+     *                If a send error occurs.
+     * 
+     * @deprecated use MulticastSocket#setTimeToLive
+     */
+    @SuppressWarnings("deprecation")
     @Deprecated
     public void send(DatagramPacket pack, byte ttl) throws IOException {
-		checkClosedAndBind(false);
-		InetAddress packAddr = pack.getAddress();
-		SecurityManager security = System.getSecurityManager();
-		if (security != null) {
-			if (packAddr.isMulticastAddress()) {
+        checkClosedAndBind(false);
+        InetAddress packAddr = pack.getAddress();
+        SecurityManager security = System.getSecurityManager();
+        if (security != null) {
+            if (packAddr.isMulticastAddress()) {
                 security.checkMulticast(packAddr, ttl);
             } else {
                 security.checkConnect(packAddr.getHostName(), pack.getPort());
             }
-		}
-		int currTTL = getTimeToLive();
-		if (packAddr.isMulticastAddress() && (byte) currTTL != ttl) {
-			try {
-				setTimeToLive(ttl & 0xff);
-				impl.send(pack);
-			} finally {
-				setTimeToLive(currTTL);
-			}
-		} else {
-			impl.send(pack);
-		}
-	}
-
-	/**
-	 * Set the network address used by the socket. This is useful on multi-homed
-	 * machines.
-	 * 
-	 * @param addr
-	 *            java.net.InetAddress the interface network address
-	 * @exception java.net.SocketException
-	 *                the exception may be thrown while setting the address
-	 */
-	public void setInterface(InetAddress addr) throws SocketException {
-		checkClosedAndBind(false);
-		if (addr == null) {
+        }
+        int currTTL = getTimeToLive();
+        if (packAddr.isMulticastAddress() && (byte) currTTL != ttl) {
+            try {
+                setTimeToLive(ttl & 0xff);
+                impl.send(pack);
+            } finally {
+                setTimeToLive(currTTL);
+            }
+        } else {
+            impl.send(pack);
+        }
+    }
+
+    /**
+     * Set the network address used by the socket. This is useful on multi-homed
+     * machines.
+     * 
+     * @param addr
+     *            java.net.InetAddress the interface network address
+     * @exception java.net.SocketException
+     *                the exception may be thrown while setting the address
+     */
+    public void setInterface(InetAddress addr) throws SocketException {
+        checkClosedAndBind(false);
+        if (addr == null) {
             throw new NullPointerException();
         }
-		if (addr.isAnyLocalAddress()) {
-			impl.setOption(SocketOptions.IP_MULTICAST_IF, InetAddress.ANY);
-		} else if (addr instanceof Inet4Address) {
-			impl.setOption(SocketOptions.IP_MULTICAST_IF, addr);
-			// keep the address used to do the set as we must return the same
-			// value and for IPv6 we may not be able to get it back uniquely
-			interfaceSet = addr;
-		}
+        if (addr.isAnyLocalAddress()) {
+            impl.setOption(SocketOptions.IP_MULTICAST_IF, InetAddress.ANY);
+        } else if (addr instanceof Inet4Address) {
+            impl.setOption(SocketOptions.IP_MULTICAST_IF, addr);
+            // keep the address used to do the set as we must return the same
+            // value and for IPv6 we may not be able to get it back uniquely
+            interfaceSet = addr;
+        }
 
-		/*
+        /*
          * now we should also make sure this works for IPV6 get the network
          * interface for the address and set the interface using its index
          * however if IPV6 is not enabled then we may get an exception. if IPV6
          * is not enabled
          */
-		NetworkInterface theInterface = NetworkInterface.getByInetAddress(addr);
-		if ((theInterface != null) && (theInterface.getIndex() != 0)) {
-			try {
-				impl.setOption(SocketOptions.IP_MULTICAST_IF2, Integer.valueOf(
-						theInterface.getIndex()));
-			} catch (SocketException e) {
-			}
-		} else if (addr.isAnyLocalAddress()) {
-			try {
-				impl.setOption(SocketOptions.IP_MULTICAST_IF2, Integer.valueOf(0));
-			} catch (SocketException e) {
-			}
-		} else if (addr instanceof Inet6Address) {
-			throw new SocketException(Msg.getString("K0338"));
-		}
-	}
-
-	/**
-	 * Set the network interface used by the socket. This is useful on
-	 * multi-homed machines.
-	 * 
-	 * @param netInterface
-	 *            NetworkInterface the interface to be used
-	 * @exception java.net.SocketException
-	 *                the exception may be thrown while setting the address
-	 * 
-	 * @since 1.4
-	 */
-	public void setNetworkInterface(NetworkInterface netInterface)
-			throws SocketException {
-		checkClosedAndBind(false);
-		if (netInterface != null) {
-			InetAddress firstAddress = netInterface.getFirstAddress();
-			if (firstAddress != null) {
-				if (netInterface.getIndex() == NetworkInterface.UNSET_INTERFACE_INDEX) {
-					// set the address using IP_MULTICAST_IF to make sure this
-					// works for both IPV4 and IPV6
-					impl.setOption(SocketOptions.IP_MULTICAST_IF,
-							InetAddress.ANY);
-
-					try {
-						// we have the index so now we pass set the interface
-						// using IP_MULTICAST_IF2. This is what
-						// is used to set the interface on systems which support
-						// IPV6
-						impl
-								.setOption(
-										SocketOptions.IP_MULTICAST_IF2,
-										    Integer.valueOf(
-												NetworkInterface.NO_INTERFACE_INDEX));
-					} catch (SocketException e) {
-						// for now just do this, -- could be narrowed?
-					}
-				}
-
-				/*
-                 * Now try to set using IPV4 way. However, if interface passed
-                 * in has no IP addresses associated with it then we cannot do
-                 * it. first we have to make sure there is an IPV4 address that
-                 * we can use to call set interface otherwise we will not set it
+        NetworkInterface theInterface = NetworkInterface.getByInetAddress(addr);
+        if ((theInterface != null) && (theInterface.getIndex() != 0)) {
+            try {
+                impl.setOption(SocketOptions.IP_MULTICAST_IF2, Integer
+                        .valueOf(theInterface.getIndex()));
+            } catch (SocketException e) {
+                // Ignored
+            }
+        } else if (addr.isAnyLocalAddress()) {
+            try {
+                impl.setOption(SocketOptions.IP_MULTICAST_IF2, Integer
+                        .valueOf(0));
+            } catch (SocketException e) {
+                // Ignored
+            }
+        } else if (addr instanceof Inet6Address) {
+            throw new SocketException(Msg.getString("K0338")); //$NON-NLS-1$
+        }
+    }
+
+    /**
+     * Set the network interface used by the socket. This is useful on
+     * multi-homed machines.
+     * 
+     * @param netInterface
+     *            NetworkInterface the interface to be used
+     * @exception java.net.SocketException
+     *                the exception may be thrown while setting the address
+     * 
+     * @since 1.4
+     */
+    public void setNetworkInterface(NetworkInterface netInterface)
+            throws SocketException {
+
+        checkClosedAndBind(false);
+
+        if (netInterface == null) {
+            // throw a socket exception indicating that we do not support this
+            throw new SocketException(Msg.getString("K0334")); //$NON-NLS-1$
+        }
+
+        InetAddress firstAddress = netInterface.getFirstAddress();
+        if (firstAddress == null) {
+            // this is ok if we could set it at the
+            throw new SocketException(Msg.getString("K0335")); //$NON-NLS-1$
+        }
+
+        if (netInterface.getIndex() == NetworkInterface.UNSET_INTERFACE_INDEX) {
+            // set the address using IP_MULTICAST_IF to make sure this
+            // works for both IPV4 and IPV6
+            impl.setOption(SocketOptions.IP_MULTICAST_IF, InetAddress.ANY);
+
+            try {
+                // we have the index so now we pass set the interface
+                // using IP_MULTICAST_IF2. This is what is used to set
+                // the interface on systems which support IPV6
+                impl.setOption(SocketOptions.IP_MULTICAST_IF2, Integer
+                        .valueOf(NetworkInterface.NO_INTERFACE_INDEX));
+            } catch (SocketException e) {
+                // for now just do this, -- could be narrowed?
+            }
+        }
+
+        /*
+         * Now try to set using IPV4 way. However, if interface passed in has no
+         * IP addresses associated with it then we cannot do it. first we have
+         * to make sure there is an IPV4 address that we can use to call set
+         * interface otherwise we will not set it
+         */
+        Enumeration<InetAddress> theAddresses = netInterface.getInetAddresses();
+        boolean found = false;
+        firstAddress = null;
+        while ((theAddresses.hasMoreElements()) && (found != true)) {
+            InetAddress theAddress = theAddresses.nextElement();
+            if (theAddress instanceof Inet4Address) {
+                firstAddress = theAddress;
+                found = true;
+            }
+        }
+        if (netInterface.getIndex() == NetworkInterface.NO_INTERFACE_INDEX) {
+            // the system does not support IPV6 and does not provide
+            // indexes for the network interfaces. Just pass in the
+            // first address for the network interface
+            if (firstAddress != null) {
+                impl.setOption(SocketOptions.IP_MULTICAST_IF, firstAddress);
+            } else {
+                /*
+                 * we should never get here as there should not be any network
+                 * interfaces which have no IPV4 address and which does not have
+                 * the network interface index not set correctly
                  */
-				Enumeration<InetAddress> theAddresses = netInterface.getInetAddresses();
-				boolean found = false;
-				firstAddress = null;
-				while ((theAddresses.hasMoreElements()) && (found != true)) {
-					InetAddress theAddress = theAddresses.nextElement();
-                    if (theAddress instanceof Inet4Address) {
-                        firstAddress = theAddress;
-                        found = true;
-                    }
-				}
-				if (netInterface.getIndex() == NetworkInterface.NO_INTERFACE_INDEX) {
-					// the system does not support IPV6 and does not provide
-					// indexes for the network interfaces. Just pass in the first
-					// address for the network interface
-					if (firstAddress != null) {
-						impl.setOption(SocketOptions.IP_MULTICAST_IF,
-								firstAddress);
-					} else {
-						/*
-                         * we should never get here as there should not be any
-                         * network interfaces which have no IPV4 address and
-                         * which does not have the network interface index not
-                         * set correctly
-                         */
-						throw new SocketException(Msg.getString("K0335"));
-					}
-				} else {
-					// set the address using IP_MULTICAST_IF to make sure this
-					// works for both IPV4 and IPV6
-					if (firstAddress != null) {
-						impl.setOption(SocketOptions.IP_MULTICAST_IF,
-								firstAddress);
-					}
-
-					try {
-						// we have the index so now we pass set the interface
-						// using IP_MULTICAST_IF2. This is what
-						// is used to set the interface on systems which support
-						// IPV6
-						impl.setOption(SocketOptions.IP_MULTICAST_IF2,
-								Integer.valueOf(netInterface.getIndex()));
-					} catch (SocketException e) {
-						// for now just do this -- could be narrowed?
-					}
-				}
-			} else {
-				// this is ok if we could set it at the
-				throw new SocketException(Msg.getString("K0335"));
-			}
-		} else {
-			// throw a socket exception indicating that we do not support this
-			throw new SocketException(Msg.getString("K0334"));
-		}
-		interfaceSet = null;
-	}
-
-	/**
-	 * Set the time-to-live (TTL) for multicast packets sent on this socket.
-	 * 
-	 * @param ttl
-	 *            the time-to-live, 0<ttl<= 255
-	 * @exception IOException
-	 *                The exception thrown while setting the TTL
-	 */
-	public void setTimeToLive(int ttl) throws IOException {
-		checkClosedAndBind(false);
-		if (0 <= ttl && ttl <= 255) {
-            impl.setTimeToLive(ttl);
+                throw new SocketException(Msg.getString("K0335")); //$NON-NLS-1$
+            }
         } else {
-            throw new IllegalArgumentException(Msg.getString("K003c"));
+            // set the address using IP_MULTICAST_IF to make sure this
+            // works for both IPV4 and IPV6
+            if (firstAddress != null) {
+                impl.setOption(SocketOptions.IP_MULTICAST_IF, firstAddress);
+            }
+
+            try {
+                // we have the index so now we pass set the interface
+                // using IP_MULTICAST_IF2. This is what is used to set
+                // the interface on systems which support IPV6
+                impl.setOption(SocketOptions.IP_MULTICAST_IF2, Integer
+                        .valueOf(netInterface.getIndex()));
+            } catch (SocketException e) {
+                // for now just do this -- could be narrowed?
+            }
         }
-	}
 
-	/**
-	 * Set the time-to-live (TTL) for multicast packets sent on this socket.
-	 * 
-	 * @param ttl
-	 *            the time-to-live, 0<ttl<= 255
-	 * @exception IOException
-	 *                The exception thrown while setting the TTL
-	 * @deprecated Replaced by setTimeToLive
-	 * @see #setTimeToLive(int)
-	 */
-	@SuppressWarnings("deprecation")
+        interfaceSet = null;
+    }
+
+    /**
+     * Set the time-to-live (TTL) for multicast packets sent on this socket.
+     * 
+     * @param ttl
+     *            the time-to-live, 0<=ttl<= 255
+     * @exception IOException
+     *                The exception thrown while setting the TTL
+     */
+    public void setTimeToLive(int ttl) throws IOException {
+        checkClosedAndBind(false);
+        if (ttl < 0 || ttl > 255) {
+            throw new IllegalArgumentException(Msg.getString("K003c")); //$NON-NLS-1$
+        }
+        impl.setTimeToLive(ttl);
+    }
+
+    /**
+     * Set the time-to-live (TTL) for multicast packets sent on this socket.
+     * 
+     * @param ttl
+     *            the time-to-live, 0<ttl<= 255
+     * @exception IOException
+     *                The exception thrown while setting the TTL
+     * @deprecated Replaced by setTimeToLive
+     * @see #setTimeToLive(int)
+     */
+    @SuppressWarnings("deprecation")
     @Deprecated
     public void setTTL(byte ttl) throws IOException {
-		checkClosedAndBind(false);
-		impl.setTTL(ttl);
-	}
+        checkClosedAndBind(false);
+        impl.setTTL(ttl);
+    }
 
-	@Override
+    @Override
     synchronized void createSocket(int aPort, InetAddress addr)
-			throws SocketException {
-		impl = factory != null ? factory.createDatagramSocketImpl()
-				: SocketImplProvider.getMulticastSocketImpl();
-		impl.create();
-		try {
-			// the required default options are now set in the VM where they
-			// should be
-			impl.bind(aPort, addr);
-			isBound = true;
-		} catch (SocketException e) {
-			close();
-			throw e;
-		}
-	}
-
-	/**
-	 * Constructs a MulticastSocket bound to the host/port specified by the
-	 * SocketAddress, or an unbound DatagramSocket if the SocketAddress is null.
-	 * 
-	 * @param localAddr
-	 *            the local machine address and port to bind to
-	 * 
-	 * @throws IllegalArgumentException
-	 *             if the SocketAddress is not supported
-	 * @throws IOException
-	 *             if a problem occurs creating or binding the socket
-	 * 
-	 * @since 1.4
-	 */
-	public MulticastSocket(SocketAddress localAddr) throws IOException {
-		super(localAddr);
+            throws SocketException {
+        impl = factory != null ? factory.createDatagramSocketImpl()
+                : SocketImplProvider.getMulticastSocketImpl();
+        impl.create();
+        try {
+            // the required default options are now set in the VM where they
+            // should be
+            impl.bind(aPort, addr);
+            isBound = true;
+        } catch (SocketException e) {
+            close();
+            throw e;
+        }
+    }
+
+    /**
+     * Constructs a MulticastSocket bound to the host/port specified by the
+     * SocketAddress, or an unbound DatagramSocket if the SocketAddress is null.
+     * 
+     * @param localAddr
+     *            the local machine address and port to bind to
+     * 
+     * @throws IllegalArgumentException
+     *             if the SocketAddress is not supported
+     * @throws IOException
+     *             if a problem occurs creating or binding the socket
+     * 
+     * @since 1.4
+     */
+    public MulticastSocket(SocketAddress localAddr) throws IOException {
+        super(localAddr);
         setReuseAddress(true);
-	}
+    }
 
-	/**
-	 * Get the state of the IP_MULTICAST_LOOP socket option.
-	 * 
-	 * @return <code>true</code> if the IP_MULTICAST_LOOP is enabled,
-	 *         <code>false</code> otherwise.
-	 * 
-	 * @throws SocketException
-	 *             if the socket is closed or the option is invalid.
-	 * 
-	 * @since 1.4
-	 */
-	public boolean getLoopbackMode() throws SocketException {
-		checkClosedAndBind(false);
-		return !((Boolean) impl.getOption(SocketOptions.IP_MULTICAST_LOOP))
-				.booleanValue();
-	}
-
-	/**
-	 * Set the IP_MULTICAST_LOOP socket option.
-	 * 
-	 * @param loop
-	 *            the socket IP_MULTICAST_LOOP option setting
-	 * 
-	 * @throws SocketException
-	 *             if the socket is closed or the option is invalid.
-	 * 
-	 * @since 1.4
-	 */
-	public void setLoopbackMode(boolean loop) throws SocketException {
-		checkClosedAndBind(false);
-		impl.setOption(SocketOptions.IP_MULTICAST_LOOP, loop ? Boolean.FALSE
-				: Boolean.TRUE);
-	}
+    /**
+     * Get the state of the IP_MULTICAST_LOOP socket option.
+     * 
+     * @return <code>true</code> if the IP_MULTICAST_LOOP is enabled,
+     *         <code>false</code> otherwise.
+     * 
+     * @throws SocketException
+     *             if the socket is closed or the option is invalid.
+     * 
+     * @since 1.4
+     */
+    public boolean getLoopbackMode() throws SocketException {
+        checkClosedAndBind(false);
+        return !((Boolean) impl.getOption(SocketOptions.IP_MULTICAST_LOOP))
+                .booleanValue();
+    }
+
+    /**
+     * Set the IP_MULTICAST_LOOP socket option.
+     * 
+     * @param loop
+     *            the socket IP_MULTICAST_LOOP option setting
+     * 
+     * @throws SocketException
+     *             if the socket is closed or the option is invalid.
+     * 
+     * @since 1.4
+     */
+    public void setLoopbackMode(boolean loop) throws SocketException {
+        checkClosedAndBind(false);
+        impl.setOption(SocketOptions.IP_MULTICAST_LOOP, loop ? Boolean.FALSE
+                : Boolean.TRUE);
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/NegCacheElement.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/NegCacheElement.java?view=diff&rev=493040&r1=493039&r2=493040
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/NegCacheElement.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/NegCacheElement.java Fri Jan  5 06:44:04 2007
@@ -16,41 +16,40 @@
 
 package java.net;
 
-
 /**
  * This class is used to hold information about failed name lookups
  */
 class NegCacheElement {
 
-	// we need the time to figure out when the entry is stale
-	long timeAdded = System.currentTimeMillis();
-
-	// holds the name of the host for which the lookup failed
-	String hostName;
-
-	/**
-	 * default constructor
-	 */
-	public NegCacheElement() {
-		super();
-	}
+    // we need the time to figure out when the entry is stale
+    long timeAdded = System.currentTimeMillis();
 
-	/**
-	 * Constructor used to set the hostname for the failed entry
-	 * 
-	 * @param hostName
-	 *            name of the host on which the lookup failed
-	 */
-	public NegCacheElement(String hostName) {
-		this.hostName = hostName;
-	}
+    // holds the name of the host for which the lookup failed
+    String hostName;
 
-	/**
-	 * Answers the hostname for the cache element
-	 * 
-	 * @return hostName name of the host on which the lookup failed
-	 */
-	String hostName() {
-		return hostName;
-	}
+    /**
+     * default constructor
+     */
+    public NegCacheElement() {
+        super();
+    }
+
+    /**
+     * Constructor used to set the hostname for the failed entry
+     * 
+     * @param hostName
+     *            name of the host on which the lookup failed
+     */
+    public NegCacheElement(String hostName) {
+        this.hostName = hostName;
+    }
+
+    /**
+     * Answers the hostname for the cache element
+     * 
+     * @return hostName name of the host on which the lookup failed
+     */
+    String hostName() {
+        return hostName;
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/NegativeCache.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/NegativeCache.java?view=diff&rev=493040&r1=493039&r2=493040
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/NegativeCache.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/NegativeCache.java Fri Jan  5 06:44:04 2007
@@ -16,7 +16,6 @@
 
 package java.net;
 
-
 import java.security.AccessController;
 import java.util.LinkedHashMap;
 import java.util.Map;
@@ -32,95 +31,96 @@
 
     static NegativeCache<String, NegCacheElement> negCache;
 
-	// maximum number of entries in the cache
-	static final int MAX_NEGATIVE_ENTRIES = 5;
+    // maximum number of entries in the cache
+    static final int MAX_NEGATIVE_ENTRIES = 5;
 
-	// the loading for the cache
-	static final float LOADING = 0.75F;
+    // the loading for the cache
+    static final float LOADING = 0.75F;
 
-	/**
-	 * Answers the hostname for the cache element
-	 * 
-	 * @return hostName name of the host on which the lookup failed
-	 */
-	NegativeCache(int initialCapacity, float loadFactor, boolean accessOrder) {
-		super(initialCapacity, loadFactor, accessOrder);
-	}
-
-	/**
-	 * Answers if we should remove the Eldest entry. We remove the eldest entry
-	 * if the size has grown beyond the maximum size allowed for the cache. We
-	 * create the LinkedHashMap such that this deletes the least recently used
-	 * entry
-	 * 
-	 * @param eldest
-	 *            the map entry which will be deleted if we return true
-	 */
-	@Override
+    /**
+     * Answers the hostname for the cache element
+     * 
+     * @return hostName name of the host on which the lookup failed
+     */
+    NegativeCache(int initialCapacity, float loadFactor, boolean accessOrder) {
+        super(initialCapacity, loadFactor, accessOrder);
+    }
+
+    /**
+     * Answers if we should remove the Eldest entry. We remove the eldest entry
+     * if the size has grown beyond the maximum size allowed for the cache. We
+     * create the LinkedHashMap such that this deletes the least recently used
+     * entry
+     * 
+     * @param eldest
+     *            the map entry which will be deleted if we return true
+     */
+    @Override
     protected boolean removeEldestEntry(Map.Entry<K, V> eldest) {
-		return size() > MAX_NEGATIVE_ENTRIES;
-	}
+        return size() > MAX_NEGATIVE_ENTRIES;
+    }
 
-	/**
-	 * Adds the host name and the corresponding name lookup fail message to the
-	 * cache
-	 * 
-	 * @param hostName
-	 *            the name of the host for which the lookup failed
-	 * @param failedMessage
-	 *            the message returned when we failed the lookup
-	 */
-	static void put(String hostName, String failedMessage) {
-		checkCacheExists();
-		negCache.put(hostName, new NegCacheElement(failedMessage));
-	}
-
-	/**
-	 * Answers the message that occurred when we failed to lookup the host if
-	 * such a failure is within the cache and the entry has not yet expired
-	 * 
-	 * @param hostName
-	 *            the name of the host for which we are looking for an entry
-	 * @return the message which was returned when the host failed to be looked
-	 *         up if there is still a valid entry within the cache
-	 */
-	static String getFailedMessage(String hostName) {
-		checkCacheExists();
-		NegCacheElement element = negCache.get(hostName);
-		if (element != null) {
-			// check if element is still valid
-			String ttlValue = AccessController.doPrivileged(
-                    new PriviAction<String>("networkaddress.cache.negative.ttl"));
-			int ttl = 10;
-			try {
-				if (ttlValue != null) {
+    /**
+     * Adds the host name and the corresponding name lookup fail message to the
+     * cache
+     * 
+     * @param hostName
+     *            the name of the host for which the lookup failed
+     * @param failedMessage
+     *            the message returned when we failed the lookup
+     */
+    static void put(String hostName, String failedMessage) {
+        checkCacheExists();
+        negCache.put(hostName, new NegCacheElement(failedMessage));
+    }
+
+    /**
+     * Answers the message that occurred when we failed to lookup the host if
+     * such a failure is within the cache and the entry has not yet expired
+     * 
+     * @param hostName
+     *            the name of the host for which we are looking for an entry
+     * @return the message which was returned when the host failed to be looked
+     *         up if there is still a valid entry within the cache
+     */
+    static String getFailedMessage(String hostName) {
+        checkCacheExists();
+        NegCacheElement element = negCache.get(hostName);
+        if (element != null) {
+            // check if element is still valid
+            String ttlValue = AccessController
+                    .doPrivileged(new PriviAction<String>(
+                            "networkaddress.cache.negative.ttl")); //$NON-NLS-1$
+            int ttl = 10;
+            try {
+                if (ttlValue != null) {
                     ttl = Integer.decode(ttlValue).intValue();
                 }
-			} catch (NumberFormatException e) {
-			}
-			if (ttl == 0) {
-				negCache.clear();
-				element = null;
-			} else if (ttl != -1) {
-				if (element.timeAdded + (ttl * 1000) < System
-						.currentTimeMillis()) {
-					// remove the element from the cache and return null
-					negCache.remove(hostName);
-					element = null;
-				}
-			}
-		}
-		if (element != null) {
-			return element.hostName();
-		}
-		return null;
-	}
-
-	/**
-	 * This method checks if we have created the cache and if not creates it
-	 */
-	static void checkCacheExists() {
-		if (negCache == null) {
+            } catch (NumberFormatException e) {
+            }
+            if (ttl == 0) {
+                negCache.clear();
+                element = null;
+            } else if (ttl != -1) {
+                if (element.timeAdded + (ttl * 1000) < System
+                        .currentTimeMillis()) {
+                    // remove the element from the cache and return null
+                    negCache.remove(hostName);
+                    element = null;
+                }
+            }
+        }
+        if (element != null) {
+            return element.hostName();
+        }
+        return null;
+    }
+
+    /**
+     * This method checks if we have created the cache and if not creates it
+     */
+    static void checkCacheExists() {
+        if (negCache == null) {
             /*
              * Create with the access order set so ordering is based on when the
              * entries were last accessed. We make the default cache size one
@@ -130,5 +130,5 @@
             negCache = new NegativeCache<String, NegCacheElement>(
                     MAX_NEGATIVE_ENTRIES + 1, LOADING, true);
         }
-	}
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/NetPermission.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/NetPermission.java?view=diff&rev=493040&r1=493039&r2=493040
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/NetPermission.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/NetPermission.java Fri Jan  5 06:44:04 2007
@@ -17,7 +17,6 @@
 
 package java.net;
 
-
 /**
  * This class represents permission to access network resources.
  * <p>
@@ -37,28 +36,28 @@
  */
 public final class NetPermission extends java.security.BasicPermission {
 
-	private static final long serialVersionUID = -8343910153355041693L;
+    private static final long serialVersionUID = -8343910153355041693L;
 
-	/**
-	 * Creates an instance of this class with the given name.
-	 * 
-	 * @param name
-	 *            String the name of the new permission.
-	 */
-	public NetPermission(String name) {
-		super(name);
-	}
+    /**
+     * Creates an instance of this class with the given name.
+     * 
+     * @param name
+     *            String the name of the new permission.
+     */
+    public NetPermission(String name) {
+        super(name);
+    }
 
-	/**
-	 * Creates an instance of this class with the given name and action list.
-	 * The action list is ignored.
-	 * 
-	 * @param name
-	 *            String the name of the new permission.
-	 * @param actions
-	 *            String ignored.
-	 */
-	public NetPermission(String name, String actions) {
-		super(name, actions);
-	}
+    /**
+     * Creates an instance of this class with the given name and action list.
+     * The action list is ignored.
+     * 
+     * @param name
+     *            String the name of the new permission.
+     * @param actions
+     *            String ignored.
+     */
+    public NetPermission(String name, String actions) {
+        super(name, actions);
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/NetworkInterface.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/NetworkInterface.java?view=diff&rev=493040&r1=493039&r2=493040
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/NetworkInterface.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/NetworkInterface.java Fri Jan  5 06:44:04 2007
@@ -172,7 +172,8 @@
             }
         }
 
-        Enumeration<InetAddress> theAccessibleElements = accessibleAddresses.elements();
+        Enumeration<InetAddress> theAccessibleElements = accessibleAddresses
+                .elements();
         if (theAccessibleElements.hasMoreElements()) {
             return accessibleAddresses.elements();
         }
@@ -191,11 +192,10 @@
          * we should return the display name unless it is blank in this case
          * return the name so that something is displayed.
          */
-        if (!(displayName.equals(""))) {
+        if (!(displayName.equals(""))) { //$NON-NLS-1$
             return displayName;
         }
         return name;
-
     }
 
     /**
@@ -212,7 +212,7 @@
             throws SocketException {
 
         if (interfaceName == null) {
-            throw new NullPointerException(Msg.getString("K0330"));
+            throw new NullPointerException(Msg.getString("K0330")); //$NON-NLS-1$
         }
 
         /*
@@ -232,8 +232,8 @@
     }
 
     /**
-     * Answers the network interface which has the specified internet address bound
-     * to it, if one exists.
+     * Answers the network interface which has the specified internet address
+     * bound to it, if one exists.
      * 
      * @param address
      *            address of interest
@@ -249,13 +249,13 @@
             throws SocketException {
 
         if (address == null) {
-            throw new NullPointerException(Msg.getString("K0331"));
+            throw new NullPointerException(Msg.getString("K0331")); //$NON-NLS-1$
         }
 
         /*
          * get the list of interfaces, and then loop through the list. For each
-         * interface loop through the associated set of internet addresses and see
-         * if one matches. If so return that network interface
+         * interface loop through the associated set of internet addresses and
+         * see if one matches. If so return that network interface
          */
         Enumeration<NetworkInterface> interfaces = getNetworkInterfaces();
         if (interfaces != null) {
@@ -300,19 +300,20 @@
         }
 
         for (NetworkInterface netif : interfaces) {
-            // Ensure that current NetworkInterface is bound to at least 
+            // Ensure that current NetworkInterface is bound to at least
             // one InetAddress before processing
             if (netif.addresses != null) {
                 for (InetAddress addr : netif.addresses) {
                     if (16 == addr.ipaddress.length) {
-                        if (addr.isLinkLocalAddress() || addr.isSiteLocalAddress()) {
+                        if (addr.isLinkLocalAddress()
+                                || addr.isSiteLocalAddress()) {
                             ((Inet6Address) addr).scopedIf = netif;
                             ((Inet6Address) addr).ifname = netif.name;
                             ((Inet6Address) addr).scope_ifname_set = true;
                         }
                     }
                 }
-            }// end if 
+            }
         }
 
         return (new Vector<NetworkInterface>(Arrays.asList(interfaces)))
@@ -324,7 +325,8 @@
      * are equal. The object must be an instance of NetworkInterface with the
      * same name, displayName and list of network interfaces to be the same
      * 
-     * @param obj the object to compare
+     * @param obj
+     *            the object to compare
      * @return true if the specified object is equal to this NetworkInterfcae,
      *         false otherwise
      * 
@@ -349,11 +351,11 @@
                 return false;
             }
 
-            if (!(name.equals("")) && (!netif.getName().equals(name))) {
+            if (!(name.equals("")) && (!netif.getName().equals(name))) { //$NON-NLS-1$
                 return false;
             }
 
-            if ((name.equals("")) && (!netif.getName().equals(displayName))) {
+            if ((name.equals("")) && (!netif.getName().equals(displayName))) { //$NON-NLS-1$
                 return false;
             }
 
@@ -415,11 +417,11 @@
     @Override
     public String toString() {
         StringBuilder string = new StringBuilder(25);
-        string.append("[");
+        string.append("["); //$NON-NLS-1$
         string.append(name);
-        string.append("][");
+        string.append("]["); //$NON-NLS-1$
         string.append(displayName);
-        string.append("]");
+        string.append("]"); //$NON-NLS-1$
 
         /*
          * get the addresses through this call to make sure we only reveal those
@@ -429,12 +431,11 @@
         if (theAddresses != null) {
             while (theAddresses.hasMoreElements()) {
                 InetAddress nextAddress = theAddresses.nextElement();
-                string.append("[");
+                string.append("["); //$NON-NLS-1$
                 string.append(nextAddress.toString());
-                string.append("]");
+                string.append("]"); //$NON-NLS-1$
             }
         }
         return string.toString();
     }
-
 }

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/NoRouteToHostException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/NoRouteToHostException.java?view=diff&rev=493040&r1=493039&r2=493040
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/NoRouteToHostException.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/NoRouteToHostException.java Fri Jan  5 06:44:04 2007
@@ -17,7 +17,6 @@
 
 package java.net;
 
-
 /**
  * The NoRouteToHostException may be thrown when attempting to connect to a
  * remote machine and because of network fault or firewall, no route can be
@@ -28,20 +27,20 @@
     private static final long serialVersionUID = -1897550894873493790L;
 
     /**
-	 * Constructs a new instance of this class with its walkback filled in.
-	 */
-	public NoRouteToHostException() {
-		super();
-	}
+     * Constructs a new instance of this class with its walkback filled in.
+     */
+    public NoRouteToHostException() {
+        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 NoRouteToHostException(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 NoRouteToHostException(String detailMessage) {
+        super(detailMessage);
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/PasswordAuthentication.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/PasswordAuthentication.java?view=diff&rev=493040&r1=493039&r2=493040
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/PasswordAuthentication.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/PasswordAuthentication.java Fri Jan  5 06:44:04 2007
@@ -17,45 +17,44 @@
 
 package java.net;
 
-
 /**
  * This class is a data structure that contains the username and password.
  */
 public final class PasswordAuthentication {
-	
-	private String userName;
 
-	private char[] password;
+    private String userName;
+
+    private char[] password;
 
-	/**
-	 * Creates an instance of a password authentication with a username and
-	 * password.
-	 * 
-	 * @param userName
-	 *            java.lang.String the username
-	 * @param password
-	 *            char[] the password
-	 */
-	public PasswordAuthentication(String userName, char[] password) {
-		this.userName = userName;
-		this.password = password.clone();
-	}
+    /**
+     * Creates an instance of a password authentication with a username and
+     * password.
+     * 
+     * @param userName
+     *            java.lang.String the username
+     * @param password
+     *            char[] the password
+     */
+    public PasswordAuthentication(String userName, char[] password) {
+        this.userName = userName;
+        this.password = password.clone();
+    }
 
-	/**
-	 * Answers the reference of the password of this class.
-	 * 
-	 * @return char[] the reference of the password
-	 */
-	public char[] getPassword() {
-		return password.clone();
-	}
+    /**
+     * Answers the reference of the password of this class.
+     * 
+     * @return char[] the reference of the password
+     */
+    public char[] getPassword() {
+        return password.clone();
+    }
 
-	/**
-	 * Answers the username of this class.
-	 * 
-	 * @return java.lang.String the username of this class
-	 */
-	public String getUserName() {
-		return userName;
-	}
+    /**
+     * Answers the username of this class.
+     * 
+     * @return java.lang.String the username of this class
+     */
+    public String getUserName() {
+        return userName;
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/PortUnreachableException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/PortUnreachableException.java?view=diff&rev=493040&r1=493039&r2=493040
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/PortUnreachableException.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/PortUnreachableException.java Fri Jan  5 06:44:04 2007
@@ -17,25 +17,24 @@
 
 package java.net;
 
-
 public class PortUnreachableException extends SocketException {
 
     private static final long serialVersionUID = 8462541992376507323L;
 
     /**
-	 * Constructs a new instance of this class with its walkback filled in.
-	 */
-	public PortUnreachableException() {
-	}
+     * Constructs a new instance of this class with its walkback filled in.
+     */
+    public PortUnreachableException() {
+    }
 
-	/**
-	 * Constructs a new instance of this class with its walkback and message
-	 * filled in.
-	 * 
-	 * @param detailMessage
-	 *            String The detail message for the exception.
-	 */
-	public PortUnreachableException(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 PortUnreachableException(String detailMessage) {
+        super(detailMessage);
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/ProtocolException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/ProtocolException.java?view=diff&rev=493040&r1=493039&r2=493040
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/ProtocolException.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/ProtocolException.java Fri Jan  5 06:44:04 2007
@@ -17,7 +17,6 @@
 
 package java.net;
 
-
 /**
  * An attempt to connect to a socket of the wrong type (stream or nonstream)
  * will trigger this exception. An invalid operation applied on the protocol
@@ -30,20 +29,20 @@
     private static final long serialVersionUID = -6098449442062388080L;
 
     /**
-	 * Constructs a new instance of this class with its walkback filled in.
-	 */
-	public ProtocolException() {
-		super();
-	}
+     * Constructs a new instance of this class with its walkback filled in.
+     */
+    public ProtocolException() {
+        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 ProtocolException(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 ProtocolException(String detailMessage) {
+        super(detailMessage);
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Proxy.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Proxy.java?view=diff&rev=493040&r1=493039&r2=493040
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Proxy.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Proxy.java Fri Jan  5 06:44:04 2007
@@ -15,147 +15,147 @@
  */
 package java.net;
 
+import org.apache.harmony.luni.util.Msg;
+
 /**
- * <p>
  * This class is about proxy setting. A proxy contains <code>type</code>,
  * proxy host address information. There are three types of <code>Proxy</code>:
  * <li>Direct type proxy</li>
  * <li>HTTP type proxy</li>
  * <li>SOCKS type proxy</li>
- * </p>
- * <p>
+ * 
  * A <code>Proxy</code> instance is immutable.
- * </p>
+ * 
  */
 public class Proxy {
 
-	/**
-	 * Represents <code>Proxy.Type.DIRECT</code> type proxy setting. It tells
-	 * protocol handlers not to use any proxy.
-	 */
-	public static final Proxy NO_PROXY = new Proxy();
-
-	private Proxy.Type type;
-
-	private SocketAddress address;
-
-	/**
-	 * New a <code>Proxy</code> instance. SocketAddress must NOT be null when
-	 * <code>type</code> is either <code>Proxy.Type.HTTP</code> or
-	 * <code>Proxy.Type.SOCKS</code>. For <code>Proxy.Type.DIRECT</code>
-	 * type proxy, use <code>Proxy.NO_PROXY</code> directly instead of
-	 * constructing it.
-	 * 
-	 * @param type
-	 *            proxy type
-	 * @param sa
-	 *            proxy address
-	 * @throws IllegalArgumentException
-	 *             when <code>type</code> is <code>Proxy.Type.DIRECT</code>
-	 *             or SocketAddress is null.
-	 */
-	public Proxy(Proxy.Type type, SocketAddress sa) {
-		/*
-		 * Don't use DIRECT type to construct a proxy instance directly.
-		 * SocketAddress must NOT be null.
-		 */
-		if (type == Type.DIRECT || null == sa) {
-			throw new IllegalArgumentException(
-					"Illegal Proxy.Type or SocketAddress argument.");
-		}
-		this.type = type;
-		address = sa;
-	}
-
-	/*
-	 * Constructs a Proxy instance, which is Proxy.DIRECT type with null
-	 * SocketAddress. This constructor is used for NO_PROXY.
-	 */
-	private Proxy() {
-		type = Type.DIRECT;
-		address = null;
-	}
-
-	/**
-	 * Gets the proxy type.
-	 * 
-	 * @return the proxy type.
-	 */
-	public Proxy.Type type() {
-		return type;
-	}
-
-	/**
-	 * Gets the proxy address.
-	 * 
-	 * @return the proxy address for <code>HTTP</code> and <code>SOCKS</code>
-	 *         type proxy. Returns null for <code>DIRECT</code> type proxy.
-	 */
-	public SocketAddress address() {
-		return address;
-	}
-
-	/**
-	 * <p>
-	 * Representing string of the proxy. The string consists of
-	 * <code>type.toString()</code> and <code>address.toString()</code> if
-	 * <code>type</code> and <code>address</code> are not null.
-	 * </p>
-	 * 
-	 * @see java.lang.Object#equals(java.lang.Object)
-	 * @return representing string of the proxy.
-	 */
-	@Override
+    /**
+     * Represents <code>Proxy.Type.DIRECT</code> type proxy setting. It tells
+     * protocol handlers not to use any proxy.
+     */
+    public static final Proxy NO_PROXY = new Proxy();
+
+    private Proxy.Type type;
+
+    private SocketAddress address;
+
+    /**
+     * New a <code>Proxy</code> instance. SocketAddress must NOT be null when
+     * <code>type</code> is either <code>Proxy.Type.HTTP</code> or
+     * <code>Proxy.Type.SOCKS</code>. For <code>Proxy.Type.DIRECT</code>
+     * type proxy, use <code>Proxy.NO_PROXY</code> directly instead of
+     * constructing it.
+     * 
+     * @param type
+     *            proxy type
+     * @param sa
+     *            proxy address
+     * @throws IllegalArgumentException
+     *             when <code>type</code> is <code>Proxy.Type.DIRECT</code>
+     *             or SocketAddress is null.
+     */
+    public Proxy(Proxy.Type type, SocketAddress sa) {
+        /*
+         * Don't use DIRECT type to construct a proxy instance directly.
+         * SocketAddress must NOT be null.
+         */
+        if (type == Type.DIRECT || null == sa) {
+            // KA022=Illegal Proxy.Type or SocketAddress argument
+            throw new IllegalArgumentException(Msg.getString("KA022")); //$NON-NLS-1$
+        }
+        this.type = type;
+        address = sa;
+    }
+
+    /*
+     * Constructs a Proxy instance, which is Proxy.DIRECT type with null
+     * SocketAddress. This constructor is used for NO_PROXY.
+     */
+    private Proxy() {
+        type = Type.DIRECT;
+        address = null;
+    }
+
+    /**
+     * Gets the proxy type.
+     * 
+     * @return the proxy type.
+     */
+    public Proxy.Type type() {
+        return type;
+    }
+
+    /**
+     * Gets the proxy address.
+     * 
+     * @return the proxy address for <code>HTTP</code> and <code>SOCKS</code>
+     *         type proxy. Returns null for <code>DIRECT</code> type proxy.
+     */
+    public SocketAddress address() {
+        return address;
+    }
+
+    /**
+     * <p>
+     * Representing string of the proxy. The string consists of
+     * <code>type.toString()</code> and <code>address.toString()</code> if
+     * <code>type</code> and <code>address</code> are not null.
+     * </p>
+     * 
+     * @see java.lang.Object#equals(java.lang.Object)
+     * @return representing string of the proxy.
+     */
+    @Override
     public String toString() {
-		String proxyString = String.valueOf(type);
-		if (null != address) {
-			proxyString += "/" + address.toString();
-		}
-		return proxyString;
-	}
-
-	/**
-	 * <p>
-	 * Compare <code>obj</code> with current proxy. Returns false if the
-	 * <code>obj</code> is not a <code>Proxy</code> object. Returns true if
-	 * and only if the <code>obj</code> has the same <code>address</code>
-	 * and <code>type</code> value as current proxy.
-	 * </p>
-	 * 
-	 * @see java.lang.Object#equals(java.lang.Object)
-	 * @return true if <code>obj</code> represents the same proxy. Otherwise,
-	 *         returns false.
-	 */
-	@Override
+        String proxyString = String.valueOf(type);
+        if (null != address) {
+            proxyString += "/" + address.toString(); //$NON-NLS-1$
+        }
+        return proxyString;
+    }
+
+    /**
+     * <p>
+     * Compare <code>obj</code> with current proxy. Returns false if the
+     * <code>obj</code> is not a <code>Proxy</code> object. Returns true if
+     * and only if the <code>obj</code> has the same <code>address</code>
+     * and <code>type</code> value as current proxy.
+     * </p>
+     * 
+     * @see java.lang.Object#equals(java.lang.Object)
+     * @return true if <code>obj</code> represents the same proxy. Otherwise,
+     *         returns false.
+     */
+    @Override
     public final boolean equals(Object obj) {
-		if(this == obj){
-			return true;
-		}
-		if (!(obj instanceof Proxy)) {
-			return false;
-		}
-		Proxy another = (Proxy) obj;
-		// address is null when and only when it's NO_PROXY.
-		return (type == another.type) && address.equals(another.address);
-	}
-
-	/**
-	 * gets the hash code of <code>Proxy</code>.
-	 * 
-	 * @see java.lang.Object#hashCode()
-	 * @return the hash code of <code>Proxy</code>.
-	 */
-	@Override
+        if (this == obj) {
+            return true;
+        }
+        if (!(obj instanceof Proxy)) {
+            return false;
+        }
+        Proxy another = (Proxy) obj;
+        // address is null when and only when it's NO_PROXY.
+        return (type == another.type) && address.equals(another.address);
+    }
+
+    /**
+     * gets the hash code of <code>Proxy</code>.
+     * 
+     * @see java.lang.Object#hashCode()
+     * @return the hash code of <code>Proxy</code>.
+     */
+    @Override
     public final int hashCode() {
-		int ret = 0;
-		ret += type.hashCode();
-		if (null != address) {
-			ret += address.hashCode();
-		}
-		return ret;
-	}
+        int ret = 0;
+        ret += type.hashCode();
+        if (null != address) {
+            ret += address.hashCode();
+        }
+        return ret;
+    }
 
-	/**
+    /**
      * The proxy type, includes <code>DIRECT</code>, <code>HTTP</code> and
      * <code>SOCKS</code>.
      */



Mime
View raw message