Commit f6d49f66 by Michael Koch Committed by Michael Koch

Authenticator.java, [...]: Fixed javadocs, coding style and argument names all over.

2004-04-20  Michael Koch  <konqueror@gmx.de>

	* java/net/Authenticator.java,
	java/net/BindException.java,
	java/net/ConnectException.java,
	java/net/ContentHandler.java,
	java/net/ContentHandlerFactory.java,
	java/net/DatagramPacket.java,
	java/net/DatagramSocket.java,
	java/net/DatagramSocketImpl.java,
	java/net/DatagramSocketImplFactory.java,
	java/net/FileNameMap.java,
	java/net/HttpURLConnection.java,
	java/net/Inet4Address.java,
	java/net/Inet6Address.java,
	java/net/InetAddress.java,
	java/net/InetSocketAddress.java,
	java/net/JarURLConnection.java,
	java/net/MalformedURLException.java,
	java/net/MulticastSocket.java,
	java/net/NetPermission.java,
	java/net/NetworkInterface.java,
	java/net/NoRouteToHostException.java,
	java/net/PasswordAuthentication.java,
	java/net/PortUnreachableException.java,
	java/net/ProtocolException.java,
	java/net/ServerSocket.java,
	java/net/Socket.java,
	java/net/SocketAddress.java,
	java/net/SocketException.java,
	java/net/SocketImpl.java,
	java/net/SocketImplFactory.java,
	java/net/SocketOptions.java,
	java/net/SocketPermission.java,
	java/net/SocketTimeoutException.java,
	java/net/URI.java,
	java/net/URISyntaxException.java,
	java/net/URL.java,
	java/net/URLClassLoader.java,
	java/net/URLConnection.java,
	java/net/URLDecoder.java,
	java/net/URLEncoder.java,
	java/net/URLStreamHandler.java,
	java/net/URLStreamHandlerFactory.java,
	java/net/UnknownHostException.java,
	java/net/UnknownServiceException.java:
	Fixed javadocs, coding style and argument names all over.

From-SVN: r80900
parent cf6f7d55
2004-04-20 Michael Koch <konqueror@gmx.de> 2004-04-20 Michael Koch <konqueror@gmx.de>
* java/net/Authenticator.java,
java/net/BindException.java,
java/net/ConnectException.java,
java/net/ContentHandler.java,
java/net/ContentHandlerFactory.java,
java/net/DatagramPacket.java,
java/net/DatagramSocket.java,
java/net/DatagramSocketImpl.java,
java/net/DatagramSocketImplFactory.java,
java/net/FileNameMap.java,
java/net/HttpURLConnection.java,
java/net/Inet4Address.java,
java/net/Inet6Address.java,
java/net/InetAddress.java,
java/net/InetSocketAddress.java,
java/net/JarURLConnection.java,
java/net/MalformedURLException.java,
java/net/MulticastSocket.java,
java/net/NetPermission.java,
java/net/NetworkInterface.java,
java/net/NoRouteToHostException.java,
java/net/PasswordAuthentication.java,
java/net/PortUnreachableException.java,
java/net/ProtocolException.java,
java/net/ServerSocket.java,
java/net/Socket.java,
java/net/SocketAddress.java,
java/net/SocketException.java,
java/net/SocketImpl.java,
java/net/SocketImplFactory.java,
java/net/SocketOptions.java,
java/net/SocketPermission.java,
java/net/SocketTimeoutException.java,
java/net/URI.java,
java/net/URISyntaxException.java,
java/net/URL.java,
java/net/URLClassLoader.java,
java/net/URLConnection.java,
java/net/URLDecoder.java,
java/net/URLEncoder.java,
java/net/URLStreamHandler.java,
java/net/URLStreamHandlerFactory.java,
java/net/UnknownHostException.java,
java/net/UnknownServiceException.java:
Fixed javadocs, coding style and argument names all over.
2004-04-20 Michael Koch <konqueror@gmx.de>
* java/lang/Byte.java, * java/lang/Byte.java,
java/lang/CharSequence.java, java/lang/CharSequence.java,
java/lang/ClassLoader.java, java/lang/ClassLoader.java,
......
...@@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify ...@@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option) the Free Software Foundation; either version 2, or (at your option)
any later version. any later version.
GNU Classpath is distributed in the hope that it will be useful, but GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
...@@ -37,18 +37,19 @@ exception statement from your version. */ ...@@ -37,18 +37,19 @@ exception statement from your version. */
package java.net; package java.net;
/** /**
* This abstract class provides a model for obtaining authentication * This abstract class provides a model for obtaining authentication
* information (in the form of a username and password) required by * information (in the form of a username and password) required by
* some network operations (such as hitting a password protected * some network operations (such as hitting a password protected
* web site). * web site).
* <p> * <p>
* To make use of this feature, a programmer must create a subclass * To make use of this feature, a programmer must create a subclass
* that knows how to obtain the necessary info. An example * that knows how to obtain the necessary info. An example
* would be a class that popped up a dialog box to prompt the user. * would be a class that popped up a dialog box to prompt the user.
* After creating an instance of that subclass, the static * After creating an instance of that subclass, the static
* <code>setDefault</code> method of this class is called to set up * <code>setDefault</code> method of this class is called to set up
* that instance as the object to use on subsequent calls to obtain * that instance as the object to use on subsequent calls to obtain
* authorization. * authorization.
* *
* @since 1.2 * @since 1.2
...@@ -106,8 +107,8 @@ public abstract class Authenticator ...@@ -106,8 +107,8 @@ public abstract class Authenticator
*/ */
/** /**
* This method sets the default <code>Authenticator</code> object (an * This method sets the default <code>Authenticator</code> object (an
* instance of a subclass of <code>Authenticator</code>) to use when * instance of a subclass of <code>Authenticator</code>) to use when
* prompting the user for * prompting the user for
* information. Note that this method checks to see if the caller is * information. Note that this method checks to see if the caller is
* allowed to set this value (the "setDefaultAuthenticator" permission) * allowed to set this value (the "setDefaultAuthenticator" permission)
...@@ -115,9 +116,9 @@ public abstract class Authenticator ...@@ -115,9 +116,9 @@ public abstract class Authenticator
* *
* @param defAuth The new default <code>Authenticator</code> object to use * @param defAuth The new default <code>Authenticator</code> object to use
* *
* @exception SecurityException If the caller does not have permission * @exception SecurityException If the caller does not have permission
* to perform this operation * to perform this operation
*/ */
public static void setDefault(Authenticator defAuth) public static void setDefault(Authenticator defAuth)
{ {
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
...@@ -125,38 +126,40 @@ public abstract class Authenticator ...@@ -125,38 +126,40 @@ public abstract class Authenticator
sm.checkPermission(new NetPermission("setDefaultAuthenticator")); sm.checkPermission(new NetPermission("setDefaultAuthenticator"));
defaultAuthenticator = defAuth; defaultAuthenticator = defAuth;
} }
/** /**
* This method is called whenever a username and password for a given * This method is called whenever a username and password for a given
* network operation is required. First, a security check is made to see * network operation is required. First, a security check is made to see
* if the caller has the "requestPasswordAuthentication" * if the caller has the "requestPasswordAuthentication"
* permission. If not, the method thows an exception. If there is no * permission. If not, the method thows an exception. If there is no
* default <code>Authenticator</code> object, the method then returns * default <code>Authenticator</code> object, the method then returns
* <code>null</code>. Otherwise, the default authenticators's instance * <code>null</code>. Otherwise, the default authenticators's instance
* variables are initialized and it's <code>getPasswordAuthentication</code> * variables are initialized and it's <code>getPasswordAuthentication</code>
* method is called to get the actual authentication information to return. * method is called to get the actual authentication information to return.
* *
* @param addr The address requesting authentication * @param addr The address requesting authentication
* @param port The port requesting authentication * @param port The port requesting authentication
* @param protocol The protocol requesting authentication * @param protocol The protocol requesting authentication
* @param prompt The prompt to display to the user when requesting * @param prompt The prompt to display to the user when requesting
* authentication info * authentication info
* @param scheme The authentication scheme in use * @param scheme The authentication scheme in use
* *
* @return A <code>PasswordAuthentication</code> object with the user's * @return A <code>PasswordAuthentication</code> object with the user's
* authentication info. * authentication info.
* *
* @exception SecurityException If the caller does not have permission to * @exception SecurityException If the caller does not have permission to
* perform this operation * perform this operation
*/ */
public static PasswordAuthentication public static PasswordAuthentication requestPasswordAuthentication(InetAddress addr,
requestPasswordAuthentication(InetAddress addr, int port, String protocol, int port,
String prompt, String scheme) String protocol,
String prompt,
String scheme)
throws SecurityException throws SecurityException
{ {
return(requestPasswordAuthentication (null, addr, port, protocol, return requestPasswordAuthentication(null, addr, port, protocol, prompt,
prompt, scheme)); scheme);
} }
/** /**
...@@ -175,21 +178,24 @@ public abstract class Authenticator ...@@ -175,21 +178,24 @@ public abstract class Authenticator
* @param addr The address requesting authentication * @param addr The address requesting authentication
* @param port The port requesting authentication * @param port The port requesting authentication
* @param protocol The protocol requesting authentication * @param protocol The protocol requesting authentication
* @param prompt The prompt to display to the user when requesting * @param prompt The prompt to display to the user when requesting
* authentication info * authentication info
* @param scheme The authentication scheme in use * @param scheme The authentication scheme in use
* *
* @return A <code>PasswordAuthentication</code> object with the user's * @return A <code>PasswordAuthentication</code> object with the user's
* authentication info. * authentication info.
* *
* @exception SecurityException If the caller does not have permission to * @exception SecurityException If the caller does not have permission to
* perform this operation * perform this operation
* *
* @since 1.4 * @since 1.4
*/ */
public static PasswordAuthentication public static PasswordAuthentication requestPasswordAuthentication(String host,
requestPasswordAuthentication(String host, InetAddress addr, int port, InetAddress addr,
String protocol, String prompt, String scheme) int port,
String protocol,
String prompt,
String scheme)
throws SecurityException throws SecurityException
{ {
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
...@@ -197,7 +203,7 @@ public abstract class Authenticator ...@@ -197,7 +203,7 @@ public abstract class Authenticator
sm.checkPermission(new NetPermission("requestPasswordAuthentication")); sm.checkPermission(new NetPermission("requestPasswordAuthentication"));
if (defaultAuthenticator == null) if (defaultAuthenticator == null)
return(null); return null;
defaultAuthenticator.host = host; defaultAuthenticator.host = host;
defaultAuthenticator.addr = addr; defaultAuthenticator.addr = addr;
...@@ -206,7 +212,7 @@ public abstract class Authenticator ...@@ -206,7 +212,7 @@ public abstract class Authenticator
defaultAuthenticator.prompt = prompt; defaultAuthenticator.prompt = prompt;
defaultAuthenticator.scheme = scheme; defaultAuthenticator.scheme = scheme;
return(defaultAuthenticator.getPasswordAuthentication()); return defaultAuthenticator.getPasswordAuthentication();
} }
/* /*
...@@ -232,7 +238,7 @@ public abstract class Authenticator ...@@ -232,7 +238,7 @@ public abstract class Authenticator
*/ */
protected final InetAddress getRequestingSite() protected final InetAddress getRequestingSite()
{ {
return(addr); return addr;
} }
/** /**
...@@ -240,24 +246,24 @@ public abstract class Authenticator ...@@ -240,24 +246,24 @@ public abstract class Authenticator
* or <code>null</code> if not available. * or <code>null</code> if not available.
* *
* @return The name of the host requesting authentication, or * @return The name of the host requesting authentication, or
* </code>null</code> if it is not available. * <code>null</code> if it is not available.
* *
* @since 1.4 * @since 1.4
*/ */
protected final String getRequestingHost() protected final String getRequestingHost()
{ {
return(host); return host;
} }
/** /**
* This method returns the port of the site that is requesting * This method returns the port of the site that is requesting
* authentication. * authentication.
* *
* @return The requesting port * @return The requesting port
*/ */
protected final int getRequestingPort() protected final int getRequestingPort()
{ {
return(port); return port;
} }
/** /**
...@@ -268,18 +274,18 @@ public abstract class Authenticator ...@@ -268,18 +274,18 @@ public abstract class Authenticator
*/ */
protected final String getRequestingProtocol() protected final String getRequestingProtocol()
{ {
return(protocol); return protocol;
} }
/** /**
* Returns the prompt that should be used when requesting authentication * Returns the prompt that should be used when requesting authentication
* information from the user * information from the user
* *
* @return The user prompt * @return The user prompt
*/ */
protected final String getRequestingPrompt() protected final String getRequestingPrompt()
{ {
return(prompt); return prompt;
} }
/** /**
...@@ -289,7 +295,7 @@ public abstract class Authenticator ...@@ -289,7 +295,7 @@ public abstract class Authenticator
*/ */
protected final String getRequestingScheme() protected final String getRequestingScheme()
{ {
return(scheme); return scheme;
} }
/** /**
...@@ -302,8 +308,6 @@ public abstract class Authenticator ...@@ -302,8 +308,6 @@ public abstract class Authenticator
*/ */
protected PasswordAuthentication getPasswordAuthentication() protected PasswordAuthentication getPasswordAuthentication()
{ {
return(null); return null;
} }
} // class Authenticator } // class Authenticator
...@@ -37,6 +37,7 @@ exception statement from your version. */ ...@@ -37,6 +37,7 @@ exception statement from your version. */
package java.net; package java.net;
/** /**
* This exception indicates that an error occurred while attempting to bind * This exception indicates that an error occurred while attempting to bind
* socket to a particular port. * socket to a particular port.
......
...@@ -35,9 +35,9 @@ this exception to your version of the library, but you are not ...@@ -35,9 +35,9 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */ exception statement from your version. */
package java.net; package java.net;
/** /**
* This exception indicates that an error occurred while attempting to * This exception indicates that an error occurred while attempting to
* connect to a remote host. Often this indicates that the remote host * connect to a remote host. Often this indicates that the remote host
......
...@@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify ...@@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option) the Free Software Foundation; either version 2, or (at your option)
any later version. any later version.
GNU Classpath is distributed in the hope that it will be useful, but GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
...@@ -47,11 +47,11 @@ import java.io.IOException; ...@@ -47,11 +47,11 @@ import java.io.IOException;
/** /**
* This is an abstract class that is the superclass for classes that read * This is an abstract class that is the superclass for classes that read
* objects from URL's. Calling the <code>getContent()</code> method in the * objects from URL's. Calling the <code>getContent()</code> method in the
* <code>URL</code> class or the <code>URLConnection</code> class will cause * <code>URL</code> class or the <code>URLConnection</code> class will cause
* an instance of a subclass of <code>ContentHandler</code> to be created for * an instance of a subclass of <code>ContentHandler</code> to be created for
* the MIME type of the object being downloaded from the URL. Thus, this * the MIME type of the object being downloaded from the URL. Thus, this
* class is seldom needed by applications/applets directly, but only * class is seldom needed by applications/applets directly, but only
* indirectly through methods in other classes. * indirectly through methods in other classes.
* *
* @author Aaron M. Renn (arenn@urbanophile.com) * @author Aaron M. Renn (arenn@urbanophile.com)
...@@ -66,8 +66,8 @@ public abstract class ContentHandler ...@@ -66,8 +66,8 @@ public abstract class ContentHandler
/** /**
* Default, no-argument constructor. * Default, no-argument constructor.
*/ */
public ContentHandler() public ContentHandler()
{ {
} }
/* /*
...@@ -75,10 +75,10 @@ public abstract class ContentHandler ...@@ -75,10 +75,10 @@ public abstract class ContentHandler
*/ */
/** /**
* This method reads from the <code>InputStream</code> of the passed in URL * This method reads from the <code>InputStream</code> of the passed in URL
* connection and uses the data downloaded to create an <code>Object</code> * connection and uses the data downloaded to create an <code>Object</code>
* represening the content. For example, if the URL is pointing to a GIF * represening the content. For example, if the URL is pointing to a GIF
* file, this method might return an <code>Image</code> object. This method * file, this method might return an <code>Image</code> object. This method
* must be implemented by subclasses. * must be implemented by subclasses.
* *
* @param urlc A <code>URLConnection</code> object to read data from. * @param urlc A <code>URLConnection</code> object to read data from.
...@@ -87,16 +87,16 @@ public abstract class ContentHandler ...@@ -87,16 +87,16 @@ public abstract class ContentHandler
* *
* @exception IOException If an error occurs * @exception IOException If an error occurs
*/ */
public abstract Object getContent(URLConnection urlc) public abstract Object getContent(URLConnection urlc)
throws IOException; throws IOException;
/** /**
* This method reads from the <code>InputStream</code> of the passed in URL * This method reads from the <code>InputStream</code> of the passed in URL
* connection and uses the data downloaded to create an <code>Object</code> * connection and uses the data downloaded to create an <code>Object</code>
* represening the content. For example, if the URL is pointing to a GIF * represening the content. For example, if the URL is pointing to a GIF
* file, this method might return an <code>Image</code> object. This method * file, this method might return an <code>Image</code> object. This method
* must be implemented by subclasses. This method uses the list of * must be implemented by subclasses. This method uses the list of
* supplied classes as candidate types. If the data read doesn't match * supplied classes as candidate types. If the data read doesn't match
* any of the supplied type, <code>null</code> is returned. * any of the supplied type, <code>null</code> is returned.
* *
* @param urlc A <code>URLConnection</code> object to read data from. * @param urlc A <code>URLConnection</code> object to read data from.
...@@ -113,15 +113,14 @@ public abstract class ContentHandler ...@@ -113,15 +113,14 @@ public abstract class ContentHandler
public Object getContent(URLConnection urlc, Class[] classes) public Object getContent(URLConnection urlc, Class[] classes)
throws IOException throws IOException
{ {
Object obj = getContent (urlc); Object obj = getContent(urlc);
for (int i = 0; i < classes.length; i++) for (int i = 0; i < classes.length; i++)
{ {
if (classes [i].isInstance (obj)) if (classes[i].isInstance(obj))
return obj; return obj;
} }
return null; return null;
} }
} // class ContentHandler } // class ContentHandler
...@@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify ...@@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option) the Free Software Foundation; either version 2, or (at your option)
any later version. any later version.
GNU Classpath is distributed in the hope that it will be useful, but GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
...@@ -35,18 +35,17 @@ this exception to your version of the library, but you are not ...@@ -35,18 +35,17 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */ exception statement from your version. */
package java.net; package java.net;
/** /**
* Written using on-line Java Platform 1.2 API Specification, as well * Written using on-line Java Platform 1.2 API Specification, as well
* as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998). * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
* Status: Believed complete and correct. * Status: Believed complete and correct.
*/ */
/** /**
* This interface maps MIME types to <code>ContentHandler</code> objects. * This interface maps MIME types to <code>ContentHandler</code> objects.
* It consists of one method that, when passed a MIME type, returns a * It consists of one method that, when passed a MIME type, returns a
* handler for that type. * handler for that type.
* *
* @author Aaron M. Renn (arenn@urbanophile.com) * @author Aaron M. Renn (arenn@urbanophile.com)
...@@ -63,6 +62,4 @@ public interface ContentHandlerFactory ...@@ -63,6 +62,4 @@ public interface ContentHandlerFactory
* @return The <code>ContentHandler</code> for the passed in MIME type * @return The <code>ContentHandler</code> for the passed in MIME type
*/ */
ContentHandler createContentHandler(String mimeType); ContentHandler createContentHandler(String mimeType);
} // interface ContentHandlerFactory } // interface ContentHandlerFactory
...@@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify ...@@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option) the Free Software Foundation; either version 2, or (at your option)
any later version. any later version.
GNU Classpath is distributed in the hope that it will be useful, but GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
...@@ -37,6 +37,7 @@ exception statement from your version. */ ...@@ -37,6 +37,7 @@ exception statement from your version. */
package java.net; package java.net;
/* /*
* Written using on-line Java Platform 1.2 API Specification, as well * Written using on-line Java Platform 1.2 API Specification, as well
* as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998). * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
...@@ -86,7 +87,7 @@ public final class DatagramPacket ...@@ -86,7 +87,7 @@ public final class DatagramPacket
* The maximal length of the buffer. * The maximal length of the buffer.
*/ */
int maxlen; int maxlen;
/** /**
* The address to which the packet should be sent or from which it * The address to which the packet should be sent or from which it
* was received. * was received.
...@@ -134,14 +135,14 @@ public final class DatagramPacket ...@@ -134,14 +135,14 @@ public final class DatagramPacket
* *
* @param buf A buffer containing the data to send * @param buf A buffer containing the data to send
* @param offset The offset into the buffer to start writing from. * @param offset The offset into the buffer to start writing from.
* @param len The length of the buffer (must be &lt;= buf.length) * @param length The length of the buffer (must be &lt;= buf.length)
* @param addr The address to send to * @param address The address to send to
* @param port The port to send to * @param port The port to send to
* *
* @since 1.2 * @since 1.2
*/ */
public DatagramPacket(byte[] buf, int offset, int length, public DatagramPacket(byte[] buf, int offset, int length,
InetAddress address, int port) InetAddress address, int port)
{ {
setData(buf, offset, length); setData(buf, offset, length);
setAddress(address); setAddress(address);
...@@ -177,8 +178,7 @@ public final class DatagramPacket ...@@ -177,8 +178,7 @@ public final class DatagramPacket
* @since 1.4 * @since 1.4
*/ */
public DatagramPacket(byte[] buf, int offset, int length, public DatagramPacket(byte[] buf, int offset, int length,
SocketAddress address) SocketAddress address) throws SocketException
throws SocketException
{ {
if (! (address instanceof InetSocketAddress)) if (! (address instanceof InetSocketAddress))
throw new IllegalArgumentException("unsupported address type"); throw new IllegalArgumentException("unsupported address type");
...@@ -272,16 +272,16 @@ public final class DatagramPacket ...@@ -272,16 +272,16 @@ public final class DatagramPacket
/** /**
* This sets the address to which the data packet will be transmitted. * This sets the address to which the data packet will be transmitted.
* *
* @param addr The destination address * @param address The destination address
* *
* @since 1.1 * @since 1.1
*/ */
public synchronized void setAddress(InetAddress iaddr) public synchronized void setAddress(InetAddress address)
{ {
if (iaddr == null) if (address == null)
throw new NullPointerException("Null address"); throw new NullPointerException("Null address");
address = iaddr; this.address = address;
} }
/** /**
...@@ -291,12 +291,12 @@ public final class DatagramPacket ...@@ -291,12 +291,12 @@ public final class DatagramPacket
* *
* @since 1.1 * @since 1.1
*/ */
public synchronized void setPort(int iport) public synchronized void setPort(int port)
{ {
if (iport < 0 || iport > 65535) if (port < 0 || port > 65535)
throw new IllegalArgumentException("Invalid port: " + iport); throw new IllegalArgumentException("Invalid port: " + port);
port = iport; this.port = port;
} }
/** /**
...@@ -324,12 +324,12 @@ public final class DatagramPacket ...@@ -324,12 +324,12 @@ public final class DatagramPacket
* will be sent to/is coming from * will be sent to/is coming from
* *
* @return The socket address of the remote host * @return The socket address of the remote host
* *
* @since 1.4 * @since 1.4
*/ */
public SocketAddress getSocketAddress() public SocketAddress getSocketAddress()
{ {
return new InetSocketAddress (address, port); return new InetSocketAddress(address, port);
} }
/** /**
...@@ -360,7 +360,6 @@ public final class DatagramPacket ...@@ -360,7 +360,6 @@ public final class DatagramPacket
public synchronized void setData(byte[] buf, int offset, int length) public synchronized void setData(byte[] buf, int offset, int length)
{ {
// This form of setData must be used if offset is to be changed. // This form of setData must be used if offset is to be changed.
if (buf == null) if (buf == null)
throw new NullPointerException("Null buffer"); throw new NullPointerException("Null buffer");
if (offset < 0) if (offset < 0)
...@@ -372,7 +371,7 @@ public final class DatagramPacket ...@@ -372,7 +371,7 @@ public final class DatagramPacket
} }
/** /**
* Sets the length of the data in the buffer. * Sets the length of the data in the buffer.
* *
* @param length The new length. (Where len &lt;= buf.length) * @param length The new length. (Where len &lt;= buf.length)
* *
...@@ -387,7 +386,7 @@ public final class DatagramPacket ...@@ -387,7 +386,7 @@ public final class DatagramPacket
throw new IllegalArgumentException("Invalid length: " + length); throw new IllegalArgumentException("Invalid length: " + length);
if (offset + length > buffer.length) if (offset + length > buffer.length)
throw new IllegalArgumentException("Potential buffer overflow - offset: " throw new IllegalArgumentException("Potential buffer overflow - offset: "
+ offset + " length: " + length); + offset + " length: " + length);
this.length = length; this.length = length;
this.maxlen = length; this.maxlen = length;
......
/* DatagramSocketImpl.java -- Abstract class for UDP socket implementations /* DatagramSocketImpl.java -- Abstract class for UDP socket implementations
Copyright (C) 1998, 1999 2000, 2001, Copyright (C) 1998, 1999 2000, 2001,
2002, 2003 Free Software Foundation, Inc. 2002, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath. This file is part of GNU Classpath.
...@@ -36,11 +36,11 @@ this exception to your version of the library, but you are not ...@@ -36,11 +36,11 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */ exception statement from your version. */
package java.net; package java.net;
import java.io.IOException;
import java.io.FileDescriptor; import java.io.FileDescriptor;
import java.io.IOException;
/** /**
* This abstract class models a datagram socket implementation. An * This abstract class models a datagram socket implementation. An
...@@ -58,7 +58,6 @@ import java.io.FileDescriptor; ...@@ -58,7 +58,6 @@ import java.io.FileDescriptor;
*/ */
public abstract class DatagramSocketImpl implements SocketOptions public abstract class DatagramSocketImpl implements SocketOptions
{ {
/** /**
* The local port to which this socket is bound * The local port to which this socket is bound
*/ */
...@@ -103,7 +102,7 @@ public abstract class DatagramSocketImpl implements SocketOptions ...@@ -103,7 +102,7 @@ public abstract class DatagramSocketImpl implements SocketOptions
* Takes a peek at the next packet received in order to retrieve the * Takes a peek at the next packet received in order to retrieve the
* address of the sender * address of the sender
* *
* @param i The <code>InetAddress</code> to fill in with the information * @param i The <code>InetAddress</code> to fill in with the information
* about the sender if the next packet * about the sender if the next packet
* *
* @return The port number of the sender of the packet * @return The port number of the sender of the packet
...@@ -118,19 +117,19 @@ public abstract class DatagramSocketImpl implements SocketOptions ...@@ -118,19 +117,19 @@ public abstract class DatagramSocketImpl implements SocketOptions
/** /**
* Takes a peek at the next packet received. This packet is not consumed. * Takes a peek at the next packet received. This packet is not consumed.
* With the next peekData/receive operation this packet will be read again. * With the next peekData/receive operation this packet will be read again.
* *
* @param p The <code>DatagramPacket</code> to fill in with the data sent. * @param p The <code>DatagramPacket</code> to fill in with the data sent.
* *
* @return The port number of the sender of the packet. * @return The port number of the sender of the packet.
* *
* @exception IOException If an error occurs * @exception IOException If an error occurs
* @exception PortUnreachableException May be thrown if the socket is * @exception PortUnreachableException May be thrown if the socket is
* connected to a currently unreachable destination. Note, there is no * connected to a currently unreachable destination. Note, there is no
* guarantee that the exception will be thrown. * guarantee that the exception will be thrown.
* *
* @since 1.4 * @since 1.4
*/ */
protected abstract int peekData (DatagramPacket p) throws IOException; protected abstract int peekData(DatagramPacket p) throws IOException;
/** /**
* Transmits the specified packet of data to the network. The destination * Transmits the specified packet of data to the network. The destination
...@@ -169,17 +168,18 @@ public abstract class DatagramSocketImpl implements SocketOptions ...@@ -169,17 +168,18 @@ public abstract class DatagramSocketImpl implements SocketOptions
* *
* @since 1.4 * @since 1.4
*/ */
protected void connect (InetAddress address, int port) throws SocketException protected void connect(InetAddress address, int port)
throws SocketException
{ {
// This method has to be overwritten by real implementations // This method has to be overwritten by real implementations
} }
/** /**
* Disconnects the socket. * Disconnects the socket.
* *
* @since 1.4 * @since 1.4
*/ */
protected void disconnect () protected void disconnect()
{ {
// This method has to be overwritten by real implementations // This method has to be overwritten by real implementations
} }
...@@ -199,8 +199,11 @@ public abstract class DatagramSocketImpl implements SocketOptions ...@@ -199,8 +199,11 @@ public abstract class DatagramSocketImpl implements SocketOptions
* This method returns the current Time to Live (TTL) setting on this * This method returns the current Time to Live (TTL) setting on this
* socket. <b>Use <code>getTimeToLive()</code></b> instead. * socket. <b>Use <code>getTimeToLive()</code></b> instead.
* *
* @return the current time-to-live
*
* @exception IOException If an error occurs * @exception IOException If an error occurs
* @deprecated *
* @deprecated // FIXME: when ?
*/ */
protected abstract byte getTTL() throws IOException; protected abstract byte getTTL() throws IOException;
...@@ -218,6 +221,8 @@ public abstract class DatagramSocketImpl implements SocketOptions ...@@ -218,6 +221,8 @@ public abstract class DatagramSocketImpl implements SocketOptions
* This method returns the current Time to Live (TTL) setting on this * This method returns the current Time to Live (TTL) setting on this
* socket. * socket.
* *
* @return the current time-to-live
*
* @exception IOException If an error occurs * @exception IOException If an error occurs
*/ */
protected abstract int getTimeToLive() throws IOException; protected abstract int getTimeToLive() throws IOException;
...@@ -242,35 +247,37 @@ public abstract class DatagramSocketImpl implements SocketOptions ...@@ -242,35 +247,37 @@ public abstract class DatagramSocketImpl implements SocketOptions
/** /**
* Causes this socket to join the specified multicast group on a specified * Causes this socket to join the specified multicast group on a specified
* device * device
* *
* @param mcastaddr The address to leave * @param mcastaddr The address to leave
* @param netIf The specified network interface to join the group at * @param netIf The specified network interface to join the group at
* *
* @exception IOException If an error occurs * @exception IOException If an error occurs
* *
* @since 1.4 * @since 1.4
*/ */
protected abstract void joinGroup (SocketAddress mcastaddr, protected abstract void joinGroup(SocketAddress mcastaddr,
NetworkInterface netIf) NetworkInterface netIf)
throws IOException; throws IOException;
/** /**
* Leaves a multicast group * Leaves a multicast group
* *
* @param mcastaddr The address to join * @param mcastaddr The address to join
* @param netIf The specified network interface to leave the group at * @param netIf The specified network interface to leave the group at
* *
* @exception IOException If an error occurs * @exception IOException If an error occurs
* *
* @since 1.4 * @since 1.4
*/ */
protected abstract void leaveGroup (SocketAddress mcastaddr, protected abstract void leaveGroup(SocketAddress mcastaddr,
NetworkInterface netIf) NetworkInterface netIf)
throws IOException; throws IOException;
/** /**
* Returns the FileDescriptor for this socket * Returns the FileDescriptor for this socket
*
* @return the file descriptor associated with this socket
*/ */
protected FileDescriptor getFileDescriptor() protected FileDescriptor getFileDescriptor()
{ {
...@@ -279,6 +286,8 @@ public abstract class DatagramSocketImpl implements SocketOptions ...@@ -279,6 +286,8 @@ public abstract class DatagramSocketImpl implements SocketOptions
/** /**
* Returns the local port this socket is bound to * Returns the local port this socket is bound to
*
* @return the local port
*/ */
protected int getLocalPort() protected int getLocalPort()
{ {
......
...@@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify ...@@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option) the Free Software Foundation; either version 2, or (at your option)
any later version. any later version.
GNU Classpath is distributed in the hope that it will be useful, but GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
...@@ -37,12 +37,12 @@ exception statement from your version. */ ...@@ -37,12 +37,12 @@ exception statement from your version. */
package java.net; package java.net;
/** Written using on-line Java Platform 1.4 API Specification. /** Written using on-line Java Platform 1.4 API Specification.
* Status: Believed complete and correct. * Status: Believed complete and correct.
*/ */
/** /**
* This interface defines one method which returns a * This interface defines one method which returns a
* <code>DatagramSocketImpl</code> object. * <code>DatagramSocketImpl</code> object.
* This should not be needed by ordinary applications. * This should not be needed by ordinary applications.
* *
...@@ -57,5 +57,4 @@ public interface DatagramSocketImplFactory ...@@ -57,5 +57,4 @@ public interface DatagramSocketImplFactory
* @return A DatagramSocketImpl object * @return A DatagramSocketImpl object
*/ */
DatagramSocketImpl createDatagramSocketImpl(); DatagramSocketImpl createDatagramSocketImpl();
} // interface DatagramSocketImplFactory } // interface DatagramSocketImplFactory
...@@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify ...@@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option) the Free Software Foundation; either version 2, or (at your option)
any later version. any later version.
GNU Classpath is distributed in the hope that it will be useful, but GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
...@@ -35,15 +35,14 @@ this exception to your version of the library, but you are not ...@@ -35,15 +35,14 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */ exception statement from your version. */
package java.net; package java.net;
/** /**
* Written using on-line Java Platform 1.2 API Specification, as well * Written using on-line Java Platform 1.2 API Specification, as well
* as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998). * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
* Status: Believed complete and correct. * Status: Believed complete and correct.
*/ */
/** /**
* This interface has one method which, when passed a filename, returns * This interface has one method which, when passed a filename, returns
* the MIME type associated with that filename. * the MIME type associated with that filename.
...@@ -63,6 +62,4 @@ public interface FileNameMap ...@@ -63,6 +62,4 @@ public interface FileNameMap
* @return The MIME type for the filename passed in. * @return The MIME type for the filename passed in.
*/ */
String getContentTypeFor(String filename); String getContentTypeFor(String filename);
} // interface FileNameMap } // interface FileNameMap
...@@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify ...@@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option) the Free Software Foundation; either version 2, or (at your option)
any later version. any later version.
GNU Classpath is distributed in the hope that it will be useful, but GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
...@@ -35,12 +35,12 @@ this exception to your version of the library, but you are not ...@@ -35,12 +35,12 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */ exception statement from your version. */
package java.net; package java.net;
import java.io.ObjectStreamException; import java.io.ObjectStreamException;
import java.util.Arrays; import java.util.Arrays;
/** /**
* @author Michael Koch * @author Michael Koch
* @date August 3, 2002. * @date August 3, 2002.
...@@ -53,7 +53,6 @@ import java.util.Arrays; ...@@ -53,7 +53,6 @@ import java.util.Arrays;
* RFC 2365 (http://www.ietf.org/rfc/rfc2365.txt) * RFC 2365 (http://www.ietf.org/rfc/rfc2365.txt)
* Status: Believed complete and correct. * Status: Believed complete and correct.
*/ */
public final class Inet4Address extends InetAddress public final class Inet4Address extends InetAddress
{ {
static final long serialVersionUID = 3286316764910316507L; static final long serialVersionUID = 3286316764910316507L;
...@@ -61,20 +60,20 @@ public final class Inet4Address extends InetAddress ...@@ -61,20 +60,20 @@ public final class Inet4Address extends InetAddress
/** /**
* needed for serialization * needed for serialization
*/ */
private Object writeReplace () throws ObjectStreamException private Object writeReplace() throws ObjectStreamException
{ {
return new InetAddress (addr, hostName); return new InetAddress(addr, hostName);
} }
/** /**
* Creates a Inet4Address * Creates a Inet4Address
* *
* @param addr The IP address * @param addr The IP address
* @param host The Hostname * @param host The Hostname
*/ */
Inet4Address(byte[] addr, String host) Inet4Address(byte[] addr, String host)
{ {
super (addr, host); super(addr, host);
} }
/** /**
...@@ -82,37 +81,37 @@ public final class Inet4Address extends InetAddress ...@@ -82,37 +81,37 @@ public final class Inet4Address extends InetAddress
* *
* @since 1.1 * @since 1.1
*/ */
public boolean isMulticastAddress () public boolean isMulticastAddress()
{ {
return (addr [0] & 0xF0) == 0xE0; return (addr[0] & 0xF0) == 0xE0;
} }
/** /**
* Checks if this address is a loopback address * Checks if this address is a loopback address
*/ */
public boolean isLoopbackAddress () public boolean isLoopbackAddress()
{ {
return addr [0] == 0x7F; return addr[0] == 0x7F;
} }
/** /**
* Checks if this address is a wildcard address * Checks if this address is a wildcard address
* *
* @since 1.4 * @since 1.4
*/ */
public boolean isAnyLocalAddress () public boolean isAnyLocalAddress()
{ {
byte[] anylocal = { 0, 0, 0, 0 }; byte[] anylocal = { 0, 0, 0, 0 };
return Arrays.equals(addr, anylocal); return Arrays.equals(addr, anylocal);
} }
/** /**
* Checks if this address is a link local address * Checks if this address is a link local address
* *
* @since 1.4 * @since 1.4
*/ */
public boolean isLinkLocalAddress () public boolean isLinkLocalAddress()
{ {
// XXX: This seems to not exist with IPv4 addresses // XXX: This seems to not exist with IPv4 addresses
return false; return false;
...@@ -120,36 +119,36 @@ public final class Inet4Address extends InetAddress ...@@ -120,36 +119,36 @@ public final class Inet4Address extends InetAddress
/** /**
* Checks if this address is a site local address * Checks if this address is a site local address
* *
* @since 1.4 * @since 1.4
*/ */
public boolean isSiteLocalAddress () public boolean isSiteLocalAddress()
{ {
// 10.0.0.0/8 // 10.0.0.0/8
if (addr [0] == 0x0A) if (addr[0] == 0x0A)
return true; return true;
// XXX: Suns JDK 1.4.1 (on Linux) seems to have a bug here: // XXX: Suns JDK 1.4.1 (on Linux) seems to have a bug here:
// it says 172.16.0.0 - 172.255.255.255 are site local addresses // it says 172.16.0.0 - 172.255.255.255 are site local addresses
// //
// 172.16.0.0/12 // 172.16.0.0/12
if (addr [0] == 0xAC && (addr [1] & 0xF0) == 0x01) if (addr[0] == 0xAC && (addr[1] & 0xF0) == 0x01)
return true; return true;
// 192.168.0.0/16 // 192.168.0.0/16
if (addr [0] == 0xC0 && addr [1] == 0xA8) if (addr[0] == 0xC0 && addr[1] == 0xA8)
return true; return true;
// XXX: Do we need to check more addresses here ? // XXX: Do we need to check more addresses here ?
return false; return false;
} }
/** /**
* Checks if this multicast address has global scope * Checks if this multicast address has global scope
* *
* @since 1.4 * @since 1.4
*/ */
public boolean isMCGlobal () public boolean isMCGlobal()
{ {
// XXX: This seems to net exist with IPv4 addresses // XXX: This seems to net exist with IPv4 addresses
return false; return false;
...@@ -157,120 +156,118 @@ public final class Inet4Address extends InetAddress ...@@ -157,120 +156,118 @@ public final class Inet4Address extends InetAddress
/** /**
* Checks if this multicast address has node scope * Checks if this multicast address has node scope
* *
* @since 1.4 * @since 1.4
*/ */
public boolean isMCNodeLocal () public boolean isMCNodeLocal()
{ {
// XXX: This seems to net exist with IPv4 addresses // XXX: This seems to net exist with IPv4 addresses
return false; return false;
} }
/** /**
* Checks if this multicast address has link scope * Checks if this multicast address has link scope
* *
* @since 1.4 * @since 1.4
*/ */
public boolean isMCLinkLocal () public boolean isMCLinkLocal()
{ {
if (!isMulticastAddress ()) if (! isMulticastAddress())
return false; return false;
return (addr [0] == 0xE0) return (addr[0] == 0xE0) && (addr[1] == 0x00) && (addr[2] == 0x00);
&& (addr [1] == 0x00)
&& (addr [2] == 0x00);
} }
/** /**
* Checks if this multicast address has site scope * Checks if this multicast address has site scope
* *
* @since 1.4 * @since 1.4
*/ */
public boolean isMCSiteLocal () public boolean isMCSiteLocal()
{ {
// XXX: This seems to net exist with IPv4 addresses // XXX: This seems to net exist with IPv4 addresses
return false; return false;
} }
/** /**
* Checks if this multicast address has organization scope * Checks if this multicast address has organization scope
* *
* @since 1.4 * @since 1.4
*/ */
public boolean isMCOrgLocal () public boolean isMCOrgLocal()
{ {
// XXX: This seems to net exist with IPv4 addresses // XXX: This seems to net exist with IPv4 addresses
return false; return false;
} }
/** /**
* Returns the address of the current instance * Returns the address of the current instance
*/ */
public byte[] getAddress () public byte[] getAddress()
{ {
return addr; return addr;
} }
/** /**
* Returns the address as string * Returns the address as string
* *
* @since 1.0.2 * @since 1.0.2
*/ */
public String getHostAddress () public String getHostAddress()
{ {
StringBuffer sbuf = new StringBuffer (40); StringBuffer sbuf = new StringBuffer(40);
int len = addr.length; int len = addr.length;
int i = 0; int i = 0;
for ( ; ; ) for (;;)
{ {
sbuf.append (addr [i] & 0xFF); sbuf.append(addr[i] & 0xFF);
i++; i++;
if (i == len) if (i == len)
break; break;
sbuf.append ('.'); sbuf.append('.');
} }
return sbuf.toString (); return sbuf.toString();
} }
/** /**
* Computes the hashcode of the instance * Computes the hashcode of the instance
*/ */
public int hashCode () public int hashCode()
{ {
int hash = 0; int hash = 0;
int len = addr.length; int len = addr.length;
int i = len > 4 ? len - 4 : 0; int i = len > 4 ? len - 4 : 0;
for ( ; i < len; i++) for (; i < len; i++)
hash = (hash << 8) | (addr [i] & 0xFF); hash = (hash << 8) | (addr[i] & 0xFF);
return hash; return hash;
} }
/** /**
* Compare the current Inet4Address instance with obj * Compare the current Inet4Address instance with obj
* *
* @param obj Object to compare with * @param obj Object to compare with
*/ */
public boolean equals (Object obj) public boolean equals(Object obj)
{ {
if (! (obj instanceof InetAddress)) if (! (obj instanceof InetAddress))
return false; return false;
byte[] addr1 = addr; byte[] addr1 = addr;
byte[] addr2 = ((InetAddress) obj).addr; byte[] addr2 = ((InetAddress) obj).addr;
if (addr1.length != addr2.length) if (addr1.length != addr2.length)
return false; return false;
for (int i = addr1.length; --i >= 0; ) for (int i = addr1.length; --i >= 0;)
if (addr1 [i] != addr2 [i]) if (addr1[i] != addr2[i])
return false; return false;
return true; return true;
} }
} // class Inet4Address } // class Inet4Address
...@@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify ...@@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option) the Free Software Foundation; either version 2, or (at your option)
any later version. any later version.
GNU Classpath is distributed in the hope that it will be useful, but GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
...@@ -35,11 +35,11 @@ this exception to your version of the library, but you are not ...@@ -35,11 +35,11 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */ exception statement from your version. */
package java.net; package java.net;
import java.util.Arrays; import java.util.Arrays;
/** /**
* @author Michael Koch * @author Michael Koch
* @date August 3, 2002. * @date August 3, 2002.
...@@ -50,7 +50,6 @@ import java.util.Arrays; ...@@ -50,7 +50,6 @@ import java.util.Arrays;
* RFC 1884 (http://www.ietf.org/rfc/rfc1884.txt) * RFC 1884 (http://www.ietf.org/rfc/rfc1884.txt)
* Status: Believed complete and correct. * Status: Believed complete and correct.
*/ */
public final class Inet6Address extends InetAddress public final class Inet6Address extends InetAddress
{ {
static final long serialVersionUID = 6880410070516793377L; static final long serialVersionUID = 6880410070516793377L;
...@@ -59,213 +58,210 @@ public final class Inet6Address extends InetAddress ...@@ -59,213 +58,210 @@ public final class Inet6Address extends InetAddress
* Needed for serialization * Needed for serialization
*/ */
byte[] ipaddress; byte[] ipaddress;
/** /**
* Create an Inet6Address object * Create an Inet6Address object
* *
* @param addr The IP address * @param addr The IP address
* @param host The hostname * @param host The hostname
*/ */
Inet6Address (byte[] addr, String host) Inet6Address(byte[] addr, String host)
{ {
super (addr, host); super(addr, host);
this.ipaddress = addr; this.ipaddress = addr;
} }
/** /**
* Utility routine to check if the InetAddress is an IP multicast address * Utility routine to check if the InetAddress is an IP multicast address
* *
* @since 1.1 * @since 1.1
*/ */
public boolean isMulticastAddress () public boolean isMulticastAddress()
{ {
return ipaddress [0] == 0xFF; return ipaddress[0] == 0xFF;
} }
/** /**
* Utility routine to check if the InetAddress in a wildcard address * Utility routine to check if the InetAddress in a wildcard address
* *
* @since 1.4 * @since 1.4
*/ */
public boolean isAnyLocalAddress () public boolean isAnyLocalAddress()
{ {
byte[] anylocal = { 0, 0, 0, 0, 0, 0, 0, 0, byte[] anylocal = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
0, 0, 0, 0, 0, 0, 0, 0 };
return Arrays.equals(ipaddress, anylocal); return Arrays.equals(ipaddress, anylocal);
} }
/** /**
* Utility routine to check if the InetAddress is a loopback address * Utility routine to check if the InetAddress is a loopback address
* *
* @since 1.4 * @since 1.4
*/ */
public boolean isLoopbackAddress () public boolean isLoopbackAddress()
{ {
byte[] loopback = { 0, 0, 0, 0, 0, 0, 0, 0, byte[] loopback = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
0, 0, 0, 0, 0, 0, 0, 1 };
return Arrays.equals(ipaddress, loopback); return Arrays.equals(ipaddress, loopback);
} }
/** /**
* Utility routine to check if the InetAddress is an link local address * Utility routine to check if the InetAddress is an link local address
* *
* @since 1.4 * @since 1.4
*/ */
public boolean isLinkLocalAddress () public boolean isLinkLocalAddress()
{ {
return ipaddress [0] == 0xFA; return ipaddress[0] == 0xFA;
} }
/** /**
* Utility routine to check if the InetAddress is a site local address * Utility routine to check if the InetAddress is a site local address
* *
* @since 1.4 * @since 1.4
*/ */
public boolean isSiteLocalAddress () public boolean isSiteLocalAddress()
{ {
return ipaddress [0] == 0xFB; return ipaddress[0] == 0xFB;
} }
/** /**
* Utility routine to check if the multicast address has global scope * Utility routine to check if the multicast address has global scope
* *
* @since 1.4 * @since 1.4
*/ */
public boolean isMCGlobal () public boolean isMCGlobal()
{ {
if (!isMulticastAddress ()) if (! isMulticastAddress())
return false; return false;
return (ipaddress [1] & 0x0F) == 0xE; return (ipaddress[1] & 0x0F) == 0xE;
} }
/** /**
* Utility routine to check if the multicast address has node scope * Utility routine to check if the multicast address has node scope
* *
* @since 1.4 * @since 1.4
*/ */
public boolean isMCNodeLocal () public boolean isMCNodeLocal()
{ {
if (!isMulticastAddress ()) if (! isMulticastAddress())
return false; return false;
return (ipaddress [1] & 0x0F) == 0x1; return (ipaddress[1] & 0x0F) == 0x1;
} }
/** /**
* Utility routine to check if the multicast address has link scope * Utility routine to check if the multicast address has link scope
* *
* @since 1.4 * @since 1.4
*/ */
public boolean isMCLinkLocal () public boolean isMCLinkLocal()
{ {
if (!isMulticastAddress ()) if (! isMulticastAddress())
return false; return false;
return (ipaddress [1] & 0x0F) == 0x2; return (ipaddress[1] & 0x0F) == 0x2;
} }
/** /**
* Utility routine to check if the multicast address has site scope * Utility routine to check if the multicast address has site scope
* *
* @since 1.4 * @since 1.4
*/ */
public boolean isMCSiteLocal () public boolean isMCSiteLocal()
{ {
if (!isMulticastAddress ()) if (! isMulticastAddress())
return false; return false;
return (ipaddress [1] & 0x0F) == 0x5; return (ipaddress[1] & 0x0F) == 0x5;
} }
/** /**
* Utility routine to check if the multicast address has organization scope * Utility routine to check if the multicast address has organization scope
* *
* @since 1.4 * @since 1.4
*/ */
public boolean isMCOrgLocal () public boolean isMCOrgLocal()
{ {
if (!isMulticastAddress ()) if (! isMulticastAddress())
return false; return false;
return (ipaddress [1] & 0x0F) == 0x8; return (ipaddress[1] & 0x0F) == 0x8;
} }
/** /**
* Returns the raw IP address of this InetAddress object. The result is in * Returns the raw IP address of this InetAddress object. The result is in
* network byte order: the highest order byte of the address is i * network byte order: the highest order byte of the address is i
* n getAddress()[0] * n getAddress()[0]
*/ */
public byte[] getAddress () public byte[] getAddress()
{ {
return ipaddress; return ipaddress;
} }
/** /**
* Returns the IP address string in textual presentation * Returns the IP address string in textual presentation
*/ */
public String getHostAddress () public String getHostAddress()
{ {
StringBuffer sbuf = new StringBuffer (40); StringBuffer sbuf = new StringBuffer(40);
for (int i = 0; i < 16; i += 2) for (int i = 0; i < 16; i += 2)
{ {
int x = ((ipaddress [i] & 0xFF) << 8) | (ipaddress [i + 1] & 0xFF); int x = ((ipaddress[i] & 0xFF) << 8) | (ipaddress[i + 1] & 0xFF);
boolean empty = sbuf.length () == 0; boolean empty = sbuf.length() == 0;
if (empty) if (empty)
{ {
if (i > 0) if (i > 0)
sbuf.append ("::"); sbuf.append("::");
} }
else else
sbuf.append (':'); sbuf.append(':');
if (x != 0 || i >= 14) if (x != 0 || i >= 14)
sbuf.append (Integer.toHexString (x)); sbuf.append(Integer.toHexString(x));
} }
return sbuf.toString (); return sbuf.toString();
} }
/** /**
* Returns a hashcode for this IP address * Returns a hashcode for this IP address
*/ */
public int hashCode () public int hashCode()
{ {
return super.hashCode (); return super.hashCode();
} }
/** /**
* Compares this object against the specified object * Compares this object against the specified object
*/ */
public boolean equals (Object obj) public boolean equals(Object obj)
{ {
if (! (obj instanceof Inet6Address)) if (! (obj instanceof Inet6Address))
return false; return false;
Inet6Address tmp = (Inet6Address) obj; Inet6Address tmp = (Inet6Address) obj;
return super.equals (tmp) return super.equals(tmp) && this.ipaddress == tmp.ipaddress;
&& this.ipaddress == tmp.ipaddress;
} }
/** /**
* Utility routine to check if the InetAddress is an * Utility routine to check if the InetAddress is an
* IPv4 compatible IPv6 address * IPv4 compatible IPv6 address
* *
* @since 1.4 * @since 1.4
*/ */
public boolean isIPv4CompatibleAddress () public boolean isIPv4CompatibleAddress()
{ {
if (ipaddress [0] != 0x00 || ipaddress [1] != 0x00 || if (ipaddress[0] != 0x00 || ipaddress[1] != 0x00 || ipaddress[2] != 0x00
ipaddress [2] != 0x00 || ipaddress [3] != 0x00 || || ipaddress[3] != 0x00 || ipaddress[4] != 0x00
ipaddress [4] != 0x00 || ipaddress [5] != 0x00 || || ipaddress[5] != 0x00 || ipaddress[6] != 0x00
ipaddress [6] != 0x00 || ipaddress [7] != 0x00 || || ipaddress[7] != 0x00 || ipaddress[8] != 0x00
ipaddress [8] != 0x00 || ipaddress [9] != 0x00 || || ipaddress[9] != 0x00 || ipaddress[10] != 0x00
ipaddress [10] != 0x00 || ipaddress [11] != 0x00) || ipaddress[11] != 0x00)
return false; return false;
return true; return true;
......
/* InetSocketAddress.java -- /* InetSocketAddress.java --
Copyright (C) 2002 Free Software Foundation, Inc. Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath. This file is part of GNU Classpath.
...@@ -37,21 +37,21 @@ exception statement from your version. */ ...@@ -37,21 +37,21 @@ exception statement from your version. */
package java.net; package java.net;
/**
/**
* InetSocketAddress instances represent socket addresses * InetSocketAddress instances represent socket addresses
* in the java.nio package. They encapsulate a InetAddress and * in the java.nio package. They encapsulate a InetAddress and
* a port number. * a port number.
* *
* @since 1.4 * @since 1.4
*/ */
public class InetSocketAddress extends SocketAddress public class InetSocketAddress extends SocketAddress
{ {
/** /**
* Compatible with JDK 1.4+ * Compatible with JDK 1.4+
*/ */
private static final long serialVersionUID = 5076001401234631237L; private static final long serialVersionUID = 5076001401234631237L;
/** /**
* Name of host. * Name of host.
*/ */
...@@ -66,10 +66,10 @@ public class InetSocketAddress extends SocketAddress ...@@ -66,10 +66,10 @@ public class InetSocketAddress extends SocketAddress
* Port of host. * Port of host.
*/ */
private int port; private int port;
/** /**
* Constructs an InetSocketAddress instance. * Constructs an InetSocketAddress instance.
* *
* @param addr Address of the socket * @param addr Address of the socket
* @param port Port if the socket * @param port Port if the socket
* *
...@@ -79,34 +79,33 @@ public class InetSocketAddress extends SocketAddress ...@@ -79,34 +79,33 @@ public class InetSocketAddress extends SocketAddress
throws IllegalArgumentException throws IllegalArgumentException
{ {
if (port < 0 || port > 65535) if (port < 0 || port > 65535)
throw new IllegalArgumentException ("Bad port number: " + port); throw new IllegalArgumentException("Bad port number: " + port);
if (addr == null) if (addr == null)
addr = InetAddress.ANY_IF; addr = InetAddress.ANY_IF;
this.addr = addr; this.addr = addr;
this.port = port; this.port = port;
this.hostname = addr.getHostName (); this.hostname = addr.getHostName();
} }
/** /**
* Constructs an InetSocketAddress instance. * Constructs an InetSocketAddress instance.
* *
* @param port Port if the socket * @param port Port if the socket
* *
* @exception IllegalArgumentException If the port number is illegal * @exception IllegalArgumentException If the port number is illegal
*/ */
public InetSocketAddress(int port) public InetSocketAddress(int port) throws IllegalArgumentException
throws IllegalArgumentException
{ {
this ((InetAddress) null, port); this((InetAddress) null, port);
} }
/** /**
* Constructs an InetSocketAddress instance. * Constructs an InetSocketAddress instance.
* *
* @param addr Address of the socket * @param hostname The hostname for the socket address
* @param port Port if the socket * @param port The port for the socket address
* *
* @exception IllegalArgumentException If the port number is illegal * @exception IllegalArgumentException If the port number is illegal
*/ */
...@@ -114,49 +113,48 @@ public class InetSocketAddress extends SocketAddress ...@@ -114,49 +113,48 @@ public class InetSocketAddress extends SocketAddress
throws IllegalArgumentException throws IllegalArgumentException
{ {
if (hostname == null) if (hostname == null)
throw new IllegalArgumentException ("Null host name value"); throw new IllegalArgumentException("Null host name value");
if (port < 0 || port > 65535) if (port < 0 || port > 65535)
throw new IllegalArgumentException ("Bad port number: " + port); throw new IllegalArgumentException("Bad port number: " + port);
this.port = port; this.port = port;
this.hostname = hostname; this.hostname = hostname;
try try
{ {
this.addr = InetAddress.getByName(hostname); this.addr = InetAddress.getByName(hostname);
} }
catch (Exception e) // UnknownHostException, SecurityException catch (Exception e) // UnknownHostException, SecurityException
{ {
this.addr = null; this.addr = null;
} }
} }
/** /**
* Test if obj is a <code>InetSocketAddress</code> and * Test if obj is a <code>InetSocketAddress</code> and
* has the same address and port * has the same address and port
* *
* @param obj The obj to compare this address with. * @param obj The obj to compare this address with.
* *
* @return True if obj is equal. * @return True if obj is equal.
*/ */
public final boolean equals (Object obj) public final boolean equals(Object obj)
{ {
// InetSocketAddress objects are equal when addr and port are equal. // InetSocketAddress objects are equal when addr and port are equal.
// The hostname may differ. // The hostname may differ.
if (obj instanceof InetSocketAddress) if (obj instanceof InetSocketAddress)
{ {
InetSocketAddress sa = (InetSocketAddress) obj; InetSocketAddress sa = (InetSocketAddress) obj;
if (addr == null && sa.addr != null) if (addr == null && sa.addr != null)
return false; return false;
else if (addr == null && sa.addr == null) else if (addr == null && sa.addr == null)
return hostname.equals (sa.hostname) && sa.port == port; return hostname.equals(sa.hostname) && sa.port == port;
else else
return addr.equals (sa.addr) && sa.port == port; return addr.equals(sa.addr) && sa.port == port;
} }
return false; return false;
} }
...@@ -190,7 +188,7 @@ public class InetSocketAddress extends SocketAddress ...@@ -190,7 +188,7 @@ public class InetSocketAddress extends SocketAddress
{ {
return port; return port;
} }
/** /**
* Returns the hashcode of the <code>InetSocketAddress</code> * Returns the hashcode of the <code>InetSocketAddress</code>
* *
...@@ -210,7 +208,7 @@ public class InetSocketAddress extends SocketAddress ...@@ -210,7 +208,7 @@ public class InetSocketAddress extends SocketAddress
{ {
return addr == null; return addr == null;
} }
/** /**
* Returns the <code>InetSocketAddress</code> as string * Returns the <code>InetSocketAddress</code> as string
* *
......
...@@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify ...@@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option) the Free Software Foundation; either version 2, or (at your option)
any later version. any later version.
GNU Classpath is distributed in the hope that it will be useful, but GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
...@@ -35,24 +35,24 @@ this exception to your version of the library, but you are not ...@@ -35,24 +35,24 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */ exception statement from your version. */
package java.net; package java.net;
import java.io.IOException; import java.io.IOException;
import java.security.cert.Certificate;
import java.util.jar.Attributes; import java.util.jar.Attributes;
import java.util.jar.JarEntry; import java.util.jar.JarEntry;
import java.util.jar.JarFile; import java.util.jar.JarFile;
import java.util.jar.JarInputStream; import java.util.jar.JarInputStream;
import java.util.jar.Manifest; import java.util.jar.Manifest;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.security.cert.Certificate;
/** /**
* This abstract class represents a common superclass for implementations * This abstract class represents a common superclass for implementations
* of jar URL's. A jar URL is a special type of URL that allows JAR * of jar URL's. A jar URL is a special type of URL that allows JAR
* files on remote systems to be accessed. It has the form: * files on remote systems to be accessed. It has the form:
* <p> * <p>
* jar:<standard URL pointing to jar file>!/file/within/jarfile * jar:&lt;standard URL pointing to jar filei&gt;!/file/within/jarfile
* <p> for example: * <p> for example:
* <p> * <p>
* jar:http://www.urbanophile.com/java/foo.jar!/com/urbanophile/bar.class * jar:http://www.urbanophile.com/java/foo.jar!/com/urbanophile/bar.class
...@@ -96,30 +96,29 @@ public abstract class JarURLConnection extends URLConnection ...@@ -96,30 +96,29 @@ public abstract class JarURLConnection extends URLConnection
/** /**
* Creates a JarURLConnection from an URL object * Creates a JarURLConnection from an URL object
* *
* @param URL url The URL object for this connection. * @param url The URL object for this connection.
* *
* @exception MalformedURLException If url is invalid * @exception MalformedURLException If url is invalid
* *
* @specnote This constructor is protected since JDK 1.4 * @specnote This constructor is protected since JDK 1.4
*/ */
protected JarURLConnection (URL url) protected JarURLConnection(URL url) throws MalformedURLException
throws MalformedURLException
{ {
super (url); super(url);
if (!url.getProtocol().equals ("jar")) if (! url.getProtocol().equals("jar"))
throw new MalformedURLException (url + ": Not jar protocol."); throw new MalformedURLException(url + ": Not jar protocol.");
String spec = url.getFile(); String spec = url.getFile();
int bang = spec.indexOf ("!/"); int bang = spec.indexOf("!/");
if (bang == -1) if (bang == -1)
throw new MalformedURLException (url + ": No `!/' in spec."); throw new MalformedURLException(url + ": No `!/' in spec.");
// Extract the url for the jar itself. // Extract the url for the jar itself.
jarFileURL = new URL (spec.substring (0, bang)); jarFileURL = new URL(spec.substring(0, bang));
// Get the name of the entry, if any. // Get the name of the entry, if any.
entryName = spec.length() == (bang + 2) ? null : spec.substring (bang + 2); entryName = spec.length() == (bang + 2) ? null : spec.substring(bang + 2);
} }
/** /**
...@@ -128,7 +127,7 @@ public abstract class JarURLConnection extends URLConnection ...@@ -128,7 +127,7 @@ public abstract class JarURLConnection extends URLConnection
* *
* @return The remote URL * @return The remote URL
*/ */
public URL getJarFileURL () public URL getJarFileURL()
{ {
return jarFileURL; return jarFileURL;
} }
...@@ -140,19 +139,19 @@ public abstract class JarURLConnection extends URLConnection ...@@ -140,19 +139,19 @@ public abstract class JarURLConnection extends URLConnection
* *
* @return The entry name. * @return The entry name.
*/ */
public String getEntryName () public String getEntryName()
{ {
return entryName; return entryName;
} }
/** /**
* Returns the entry in this jar file specified by the URL. * Returns the entry in this jar file specified by the URL.
* *
* @return The jar entry * @return The jar entry
* *
* @exception IOException If an error occurs * @exception IOException If an error occurs
*/ */
public JarEntry getJarEntry () throws IOException public JarEntry getJarEntry() throws IOException
{ {
JarFile jarfile = null; JarFile jarfile = null;
...@@ -203,7 +202,7 @@ public abstract class JarURLConnection extends URLConnection ...@@ -203,7 +202,7 @@ public abstract class JarURLConnection extends URLConnection
* *
* @exception IOException If an error occurs * @exception IOException If an error occurs
*/ */
public abstract JarFile getJarFile () throws IOException; public abstract JarFile getJarFile() throws IOException;
/** /**
* Returns an array of Certificate objects for the jar file entry specified * Returns an array of Certificate objects for the jar file entry specified
...@@ -213,10 +212,10 @@ public abstract class JarURLConnection extends URLConnection ...@@ -213,10 +212,10 @@ public abstract class JarURLConnection extends URLConnection
* *
* @exception IOException If an error occurs * @exception IOException If an error occurs
*/ */
public Certificate[] getCertificates () throws IOException public Certificate[] getCertificates() throws IOException
{ {
JarEntry entry = getJarEntry(); JarEntry entry = getJarEntry();
return entry != null ? entry.getCertificates() : null; return entry != null ? entry.getCertificates() : null;
} }
...@@ -228,10 +227,10 @@ public abstract class JarURLConnection extends URLConnection ...@@ -228,10 +227,10 @@ public abstract class JarURLConnection extends URLConnection
* *
* @exception IOException If an error occurs * @exception IOException If an error occurs
*/ */
public Attributes getMainAttributes () throws IOException public Attributes getMainAttributes() throws IOException
{ {
Manifest manifest = getManifest(); Manifest manifest = getManifest();
return manifest != null ? manifest.getMainAttributes() : null; return manifest != null ? manifest.getMainAttributes() : null;
} }
...@@ -244,7 +243,7 @@ public abstract class JarURLConnection extends URLConnection ...@@ -244,7 +243,7 @@ public abstract class JarURLConnection extends URLConnection
* *
* @exception IOException If an error occurs * @exception IOException If an error occurs
*/ */
public Attributes getAttributes () throws IOException public Attributes getAttributes() throws IOException
{ {
JarEntry entry = getJarEntry(); JarEntry entry = getJarEntry();
...@@ -259,7 +258,7 @@ public abstract class JarURLConnection extends URLConnection ...@@ -259,7 +258,7 @@ public abstract class JarURLConnection extends URLConnection
* *
* @exception IOException If an error occurs * @exception IOException If an error occurs
*/ */
public Manifest getManifest () throws IOException public Manifest getManifest() throws IOException
{ {
JarFile file = getJarFile(); JarFile file = getJarFile();
......
...@@ -39,6 +39,7 @@ package java.net; ...@@ -39,6 +39,7 @@ package java.net;
import java.io.IOException; import java.io.IOException;
/** /**
* This exception indicates that a URL passed to an object was not in a * This exception indicates that a URL passed to an object was not in a
* valid format. * valid format.
......
...@@ -39,22 +39,23 @@ package java.net; ...@@ -39,22 +39,23 @@ package java.net;
import java.security.BasicPermission; import java.security.BasicPermission;
/** /**
* This class is used to model miscellaneous network permissions. It is * This class is used to model miscellaneous network permissions. It is
* a subclass of <code>BasicPermission</code>. This means that it models a * a subclass of <code>BasicPermission</code>. This means that it models a
* "boolean" permission. One that you either have or do not have. Thus * "boolean" permission. One that you either have or do not have. Thus
* there is no permitted action list associated with this object. * there is no permitted action list associated with this object.
* *
* The following permission names are defined for this class: * The following permission names are defined for this class:
* *
* <ul> * <ul>
* <li>setDefaultAuthenticator - Grants the ability to install a facility * <li>setDefaultAuthenticator - Grants the ability to install a facility
* to collect username and password information when requested by a * to collect username and password information when requested by a
* web site or proxy server. * web site or proxy server.</li>
* <li>requestPasswordAuthentication - Grants the ability to ask the * <li>requestPasswordAuthentication - Grants the ability to ask the
* authentication facility for the user's password. * authentication facility for the user's password.</li>
* <li>specifyStreamHandler - Grants the permission to specify the * <li>specifyStreamHandler - Grants the permission to specify the
* stream handler class used when loading from a URL. * stream handler class used when loading from a URL.</li>
* </ul> * </ul>
* *
* @author Aaron M. Renn (arenn@urbanophile.com) * @author Aaron M. Renn (arenn@urbanophile.com)
...@@ -75,8 +76,8 @@ public final class NetPermission extends BasicPermission ...@@ -75,8 +76,8 @@ public final class NetPermission extends BasicPermission
} }
/** /**
* Initializes a new instance of <code>NetPermission</code> with the * Initializes a new instance of <code>NetPermission</code> with the
* specified name and perms. Note that the perms field is irrelevant and is * specified name and perms. Note that the perms field is irrelevant and is
* ignored. This constructor should never need to be used. * ignored. This constructor should never need to be used.
* *
* @param name The name of this permission * @param name The name of this permission
......
...@@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify ...@@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option) the Free Software Foundation; either version 2, or (at your option)
any later version. any later version.
GNU Classpath is distributed in the hope that it will be useful, but GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
...@@ -41,6 +41,7 @@ import gnu.classpath.Configuration; ...@@ -41,6 +41,7 @@ import gnu.classpath.Configuration;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Vector; import java.util.Vector;
/** /**
* This class models a network interface on the host computer. A network * This class models a network interface on the host computer. A network
* interface contains a name (typically associated with a specific * interface contains a name (typically associated with a specific
...@@ -54,25 +55,22 @@ import java.util.Vector; ...@@ -54,25 +55,22 @@ import java.util.Vector;
public final class NetworkInterface public final class NetworkInterface
{ {
static static
{ {
if (Configuration.INIT_LOAD_LIBRARY) if (Configuration.INIT_LOAD_LIBRARY)
{ System.loadLibrary("javanet");
System.loadLibrary ("javanet"); }
}
}
private String name; private String name;
private Vector inetAddresses; private Vector inetAddresses;
private NetworkInterface (String name, InetAddress address) private NetworkInterface(String name, InetAddress address)
{ {
this.name = name; this.name = name;
this.inetAddresses = new Vector (1, 1); this.inetAddresses = new Vector(1, 1);
this.inetAddresses.add (address); this.inetAddresses.add(address);
} }
private native static Vector getRealNetworkInterfaces () private static native Vector getRealNetworkInterfaces()
throws SocketException; throws SocketException;
/** /**
...@@ -80,45 +78,45 @@ public final class NetworkInterface ...@@ -80,45 +78,45 @@ public final class NetworkInterface
* *
* @return The name of the interface. * @return The name of the interface.
*/ */
public String getName () public String getName()
{ {
return name; return name;
} }
/** /**
* Returns all available addresses of the network interface * Returns all available addresses of the network interface
* *
* If a @see SecurityManager is available all addresses are checked * If a @see SecurityManager is available all addresses are checked
* with @see SecurityManager::checkConnect() if they are available. * with @see SecurityManager::checkConnect() if they are available.
* Only <code>InetAddresses</code> are returned where the security manager * Only <code>InetAddresses</code> are returned where the security manager
* doesn't throw an exception. * doesn't throw an exception.
* *
* @return An enumeration of all addresses. * @return An enumeration of all addresses.
*/ */
public Enumeration getInetAddresses () public Enumeration getInetAddresses()
{ {
SecurityManager s = System.getSecurityManager (); SecurityManager s = System.getSecurityManager();
if (s == null) if (s == null)
return inetAddresses.elements (); return inetAddresses.elements();
Vector tmpInetAddresses = new Vector (1, 1); Vector tmpInetAddresses = new Vector(1, 1);
for (Enumeration addresses = inetAddresses.elements (); for (Enumeration addresses = inetAddresses.elements();
addresses.hasMoreElements (); ) addresses.hasMoreElements();)
{ {
InetAddress addr = (InetAddress) addresses.nextElement (); InetAddress addr = (InetAddress) addresses.nextElement();
try try
{ {
s.checkConnect (addr.getHostAddress (), 58000); s.checkConnect(addr.getHostAddress(), 58000);
tmpInetAddresses.add (addr); tmpInetAddresses.add(addr);
} }
catch (SecurityException e) catch (SecurityException e)
{ {
} }
} }
return tmpInetAddresses.elements (); return tmpInetAddresses.elements();
} }
/** /**
...@@ -126,7 +124,7 @@ public final class NetworkInterface ...@@ -126,7 +124,7 @@ public final class NetworkInterface
* *
* @return The display name of the interface * @return The display name of the interface
*/ */
public String getDisplayName () public String getDisplayName()
{ {
return name; return name;
} }
...@@ -139,21 +137,20 @@ public final class NetworkInterface ...@@ -139,21 +137,20 @@ public final class NetworkInterface
* @exception SocketException If an error occurs * @exception SocketException If an error occurs
* @exception NullPointerException If the specified name is null * @exception NullPointerException If the specified name is null
*/ */
public static NetworkInterface getByName (String name) public static NetworkInterface getByName(String name)
throws SocketException throws SocketException
{ {
Vector networkInterfaces = getRealNetworkInterfaces (); Vector networkInterfaces = getRealNetworkInterfaces();
for (Enumeration e = networkInterfaces.elements (); for (Enumeration e = networkInterfaces.elements(); e.hasMoreElements();)
e.hasMoreElements (); )
{ {
NetworkInterface tmp = (NetworkInterface) e.nextElement (); NetworkInterface tmp = (NetworkInterface) e.nextElement();
if (name.equals (tmp.getName ())) if (name.equals(tmp.getName()))
return tmp; return tmp;
} }
throw new SocketException ("no network interface with this name exists"); throw new SocketException("no network interface with this name exists");
} }
/** /**
...@@ -164,26 +161,25 @@ public final class NetworkInterface ...@@ -164,26 +161,25 @@ public final class NetworkInterface
* @exception SocketException If an error occurs * @exception SocketException If an error occurs
* @exception NullPointerException If the specified addess is null * @exception NullPointerException If the specified addess is null
*/ */
public static NetworkInterface getByInetAddress (InetAddress addr) public static NetworkInterface getByInetAddress(InetAddress addr)
throws SocketException throws SocketException
{ {
Vector networkInterfaces = getRealNetworkInterfaces (); Vector networkInterfaces = getRealNetworkInterfaces();
for (Enumeration interfaces = networkInterfaces.elements (); for (Enumeration interfaces = networkInterfaces.elements();
interfaces.hasMoreElements (); ) interfaces.hasMoreElements();)
{ {
NetworkInterface tmp = (NetworkInterface) interfaces.nextElement (); NetworkInterface tmp = (NetworkInterface) interfaces.nextElement();
for (Enumeration addresses = tmp.inetAddresses.elements (); for (Enumeration addresses = tmp.inetAddresses.elements();
addresses.hasMoreElements (); ) addresses.hasMoreElements();)
{ {
if (addr.equals ((InetAddress) addresses.nextElement ())) if (addr.equals((InetAddress) addresses.nextElement()))
return tmp; return tmp;
} }
} }
throw new SocketException ( throw new SocketException("no network interface is bound to such an IP address");
"no network interface is bound to such an IP address");
} }
/** /**
...@@ -191,8 +187,7 @@ public final class NetworkInterface ...@@ -191,8 +187,7 @@ public final class NetworkInterface
* *
* @exception SocketException If an error occurs * @exception SocketException If an error occurs
*/ */
public static Enumeration getNetworkInterfaces () public static Enumeration getNetworkInterfaces() throws SocketException
throws SocketException
{ {
Vector networkInterfaces = getRealNetworkInterfaces(); Vector networkInterfaces = getRealNetworkInterfaces();
...@@ -206,44 +201,43 @@ public final class NetworkInterface ...@@ -206,44 +201,43 @@ public final class NetworkInterface
* Checks if the current instance is equal to obj * Checks if the current instance is equal to obj
* *
* @param obj The object to compare with * @param obj The object to compare with
*/ */
public boolean equals (Object obj) public boolean equals(Object obj)
{ {
if (!(obj instanceof NetworkInterface)) if (! (obj instanceof NetworkInterface))
return false; return false;
NetworkInterface tmp = (NetworkInterface) obj; NetworkInterface tmp = (NetworkInterface) obj;
return (name.equals (tmp.name) return (name.equals(tmp.name) && inetAddresses.equals(tmp.inetAddresses));
&& inetAddresses.equals (tmp.inetAddresses));
} }
/** /**
* Returns the hashcode of the current instance * Returns the hashcode of the current instance
*/ */
public int hashCode () public int hashCode()
{ {
// FIXME: hash correctly // FIXME: hash correctly
return name.hashCode () + inetAddresses.hashCode (); return name.hashCode() + inetAddresses.hashCode();
} }
/** /**
* Returns a string representation of the interface * Returns a string representation of the interface
*/ */
public String toString () public String toString()
{ {
// FIXME: check if this is correct // FIXME: check if this is correct
String result; String result;
String separator = System.getProperty ("line.separator"); String separator = System.getProperty("line.separator");
result = "name: " + getDisplayName () + " (" + getName () + result =
") addresses:" + separator; "name: " + getDisplayName() + " (" + getName() + ") addresses:"
+ separator;
for (Enumeration e = inetAddresses.elements (); for (Enumeration e = inetAddresses.elements(); e.hasMoreElements();)
e.hasMoreElements (); )
{ {
InetAddress address = (InetAddress) e.nextElement (); InetAddress address = (InetAddress) e.nextElement();
result += address.toString () + ";" + separator; result += address.toString() + ";" + separator;
} }
return result; return result;
......
...@@ -35,9 +35,9 @@ this exception to your version of the library, but you are not ...@@ -35,9 +35,9 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */ exception statement from your version. */
package java.net; package java.net;
/** /**
* This exception indicates that there is no TCP/IP route to the requested * This exception indicates that there is no TCP/IP route to the requested
* host. This is often due to a misconfigured routing table. * host. This is often due to a misconfigured routing table.
......
...@@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify ...@@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option) the Free Software Foundation; either version 2, or (at your option)
any later version. any later version.
GNU Classpath is distributed in the hope that it will be useful, but GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
...@@ -37,6 +37,7 @@ exception statement from your version. */ ...@@ -37,6 +37,7 @@ exception statement from your version. */
package java.net; package java.net;
/** /**
* This class serves a container for username/password pairs. * This class serves a container for username/password pairs.
* *
...@@ -50,7 +51,7 @@ public final class PasswordAuthentication ...@@ -50,7 +51,7 @@ public final class PasswordAuthentication
*/ */
/** /**
* The username * The username
*/ */
private String username; private String username;
...@@ -66,7 +67,7 @@ public final class PasswordAuthentication ...@@ -66,7 +67,7 @@ public final class PasswordAuthentication
*/ */
/** /**
* Creates a new <code>PasswordAuthentication</code> object from the * Creates a new <code>PasswordAuthentication</code> object from the
* specified username and password. * specified username and password.
* *
* @param username The username for this object * @param username The username for this object
...@@ -91,9 +92,9 @@ public final class PasswordAuthentication ...@@ -91,9 +92,9 @@ public final class PasswordAuthentication
*/ */
public String getUserName() public String getUserName()
{ {
return(username); return (username);
} }
/** /**
* Returns the password associated with this object * Returns the password associated with this object
* *
...@@ -101,8 +102,6 @@ public final class PasswordAuthentication ...@@ -101,8 +102,6 @@ public final class PasswordAuthentication
*/ */
public char[] getPassword() public char[] getPassword()
{ {
return(password); return (password);
} }
} // class PasswordAuthentication } // class PasswordAuthentication
...@@ -37,6 +37,7 @@ exception statement from your version. */ ...@@ -37,6 +37,7 @@ exception statement from your version. */
package java.net; package java.net;
/** /**
* This exception signals that an ICMP port unreachable datagram has been * This exception signals that an ICMP port unreachable datagram has been
* received. * received.
...@@ -69,4 +70,3 @@ public class PortUnreachableException extends SocketException ...@@ -69,4 +70,3 @@ public class PortUnreachableException extends SocketException
super(message); super(message);
} }
} // class PortUnreachableException } // class PortUnreachableException
...@@ -39,6 +39,7 @@ package java.net; ...@@ -39,6 +39,7 @@ package java.net;
import java.io.IOException; import java.io.IOException;
/** /**
* This exception indicates that some sort of low level protocol * This exception indicates that some sort of low level protocol
* exception occurred. Look in the descriptive message (if any) for * exception occurred. Look in the descriptive message (if any) for
......
/* SocketAddress.java -- /* SocketAddress.java --
Copyright (C) 2002 Free Software Foundation, Inc. Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath. This file is part of GNU Classpath.
...@@ -39,7 +39,8 @@ package java.net; ...@@ -39,7 +39,8 @@ package java.net;
import java.io.Serializable; import java.io.Serializable;
/**
/**
* Abstract base class for InetSocketAddress. * Abstract base class for InetSocketAddress.
* InetSocketAddress is to my knowledge the only derived * InetSocketAddress is to my knowledge the only derived
* class. [Ronald] * class. [Ronald]
......
...@@ -39,6 +39,7 @@ package java.net; ...@@ -39,6 +39,7 @@ package java.net;
import java.io.IOException; import java.io.IOException;
/** /**
* This exception indicates that a generic error occurred related to an * This exception indicates that a generic error occurred related to an
* operation on a socket. Check the descriptive message (if any) for * operation on a socket. Check the descriptive message (if any) for
......
...@@ -36,14 +36,14 @@ this exception to your version of the library, but you are not ...@@ -36,14 +36,14 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */ exception statement from your version. */
package java.net; package java.net;
import java.io.FileDescriptor; import java.io.FileDescriptor;
import java.io.InputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
/* Written using on-line Java Platform 1.2 API Specification. /* Written using on-line Java Platform 1.2 API Specification.
* Believed complete and correct. * Believed complete and correct.
*/ */
...@@ -113,7 +113,8 @@ public abstract class SocketImpl implements SocketOptions ...@@ -113,7 +113,8 @@ public abstract class SocketImpl implements SocketOptions
* *
* @exception IOException If an error occurs * @exception IOException If an error occurs
*/ */
protected abstract void connect(String host, int port) throws IOException; protected abstract void connect(String host, int port)
throws IOException;
/** /**
* Connects to the remote address and port specified as arguments. * Connects to the remote address and port specified as arguments.
...@@ -153,7 +154,8 @@ public abstract class SocketImpl implements SocketOptions ...@@ -153,7 +154,8 @@ public abstract class SocketImpl implements SocketOptions
* *
* @exception IOException If an error occurs * @exception IOException If an error occurs
*/ */
protected abstract void bind(InetAddress host, int port) throws IOException; protected abstract void bind(InetAddress host, int port)
throws IOException;
/** /**
* Starts listening for connections on a socket. The backlog parameter * Starts listening for connections on a socket. The backlog parameter
...@@ -220,26 +222,38 @@ public abstract class SocketImpl implements SocketOptions ...@@ -220,26 +222,38 @@ public abstract class SocketImpl implements SocketOptions
* *
* @return A FileDescriptor for this socket. * @return A FileDescriptor for this socket.
*/ */
protected FileDescriptor getFileDescriptor() { return fd; } protected FileDescriptor getFileDescriptor()
{
return fd;
}
/** /**
* Returns the remote address this socket is connected to * Returns the remote address this socket is connected to
* *
* @return The remote address * @return The remote address
*/ */
protected InetAddress getInetAddress() { return address; } protected InetAddress getInetAddress()
{
return address;
}
/** /**
* Returns the remote port this socket is connected to * Returns the remote port this socket is connected to
* *
* @return The remote port * @return The remote port
*/ */
protected int getPort() { return port; } protected int getPort()
{
return port;
}
/** /**
* Returns true or false when this socket supports sending urgent data * Returns true or false when this socket supports sending urgent data
* or not. * or not.
* *
* @return true if the socket implementation supports sending urgent data,
* false otherwise
*
* @since 1.4 * @since 1.4
*/ */
protected boolean supportsUrgentData() protected boolean supportsUrgentData()
...@@ -248,7 +262,7 @@ public abstract class SocketImpl implements SocketOptions ...@@ -248,7 +262,7 @@ public abstract class SocketImpl implements SocketOptions
// sending urgend data. // sending urgend data.
return false; return false;
} }
/** /**
* Sends one byte of urgent data to the socket. * Sends one byte of urgent data to the socket.
* *
...@@ -258,15 +272,17 @@ public abstract class SocketImpl implements SocketOptions ...@@ -258,15 +272,17 @@ public abstract class SocketImpl implements SocketOptions
* *
* @since 1.4 * @since 1.4
*/ */
protected abstract void sendUrgentData(int data) protected abstract void sendUrgentData(int data) throws IOException;
throws IOException;
/** /**
* Returns the local port this socket is bound to * Returns the local port this socket is bound to
* *
* @return The local port * @return The local port
*/ */
protected int getLocalPort() { return localport; } protected int getLocalPort()
{
return localport;
}
/** /**
* Returns a <code>String</code> representing the remote host and port of * Returns a <code>String</code> representing the remote host and port of
...@@ -276,10 +292,9 @@ public abstract class SocketImpl implements SocketOptions ...@@ -276,10 +292,9 @@ public abstract class SocketImpl implements SocketOptions
*/ */
public String toString() public String toString()
{ {
return "[addr=" + ((address == null) ? "0.0.0.0/0.0.0.0" : return "[addr="
address.toString()) + ((address == null) ? "0.0.0.0/0.0.0.0" : address.toString())
+ ",port=" + port + ",port=" + port + ",localport=" + localport + "]";
+ ",localport=" + localport + "]";
} }
/** /**
...@@ -288,9 +303,9 @@ public abstract class SocketImpl implements SocketOptions ...@@ -288,9 +303,9 @@ public abstract class SocketImpl implements SocketOptions
* *
* @exception IOException if an error occurs * @exception IOException if an error occurs
*/ */
protected void shutdownInput () throws IOException protected void shutdownInput() throws IOException
{ {
throw new IOException ("Not implemented in this socket class"); throw new IOException("Not implemented in this socket class");
} }
/** /**
...@@ -299,8 +314,8 @@ public abstract class SocketImpl implements SocketOptions ...@@ -299,8 +314,8 @@ public abstract class SocketImpl implements SocketOptions
* *
* @exception IOException if an error occurs * @exception IOException if an error occurs
*/ */
protected void shutdownOutput () throws IOException protected void shutdownOutput() throws IOException
{ {
throw new IOException ("Not implemented in this socket class"); throw new IOException("Not implemented in this socket class");
} }
} }
...@@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify ...@@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option) the Free Software Foundation; either version 2, or (at your option)
any later version. any later version.
GNU Classpath is distributed in the hope that it will be useful, but GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
...@@ -35,13 +35,12 @@ this exception to your version of the library, but you are not ...@@ -35,13 +35,12 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */ exception statement from your version. */
package java.net; package java.net;
/** Written using on-line Java Platform 1.2 API Specification. /** Written using on-line Java Platform 1.2 API Specification.
* Status: Believed complete and correct. * Status: Believed complete and correct.
*/ */
/** /**
* This interface defines one method which returns a <code>SocketImpl</code> * This interface defines one method which returns a <code>SocketImpl</code>
* object. This should not be needed by ordinary applications. * object. This should not be needed by ordinary applications.
...@@ -57,6 +56,4 @@ public interface SocketImplFactory ...@@ -57,6 +56,4 @@ public interface SocketImplFactory
* @return A <code>SocketImpl</code> object * @return A <code>SocketImpl</code> object
*/ */
SocketImpl createSocketImpl(); SocketImpl createSocketImpl();
} // interface SocketImplFactory } // interface SocketImplFactory
/* SocketOptions.java -- Implements options for sockets (duh!) /* SocketOptions.java -- Implements options for sockets (duh!)
Copyright (C) 1998, 1999, 2000, 2001, Copyright (C) 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc. 2002, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath. This file is part of GNU Classpath.
...@@ -8,7 +8,7 @@ GNU Classpath is free software; you can redistribute it and/or modify ...@@ -8,7 +8,7 @@ GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option) the Free Software Foundation; either version 2, or (at your option)
any later version. any later version.
GNU Classpath is distributed in the hope that it will be useful, but GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
...@@ -38,15 +38,15 @@ exception statement from your version. */ ...@@ -38,15 +38,15 @@ exception statement from your version. */
package java.net; package java.net;
/** /**
* Written using on-line Java Platform 1.2 API Specification. * Written using on-line Java Platform 1.2 API Specification.
* Status: Believed complete and correct. * Status: Believed complete and correct.
*/ */
/** /**
* This interface is used by <code>SocketImpl</code> and * This interface is used by <code>SocketImpl</code> and
* <code>DatagramSocketImpl</code> to implement options * <code>DatagramSocketImpl</code> to implement options
* on sockets. * on sockets.
* *
* @since 1.2 * @since 1.2
* *
...@@ -163,6 +163,4 @@ public interface SocketOptions ...@@ -163,6 +163,4 @@ public interface SocketOptions
* @exception SocketException If an error occurs * @exception SocketException If an error occurs
*/ */
Object getOption(int optionId) throws SocketException; Object getOption(int optionId) throws SocketException;
} // interface SocketOptions } // interface SocketOptions
...@@ -39,6 +39,7 @@ package java.net; ...@@ -39,6 +39,7 @@ package java.net;
import java.io.InterruptedIOException; import java.io.InterruptedIOException;
/** /**
* This exception signals that a socket read or accept timed out. * This exception signals that a socket read or accept timed out.
* *
......
...@@ -37,6 +37,7 @@ exception statement from your version. */ ...@@ -37,6 +37,7 @@ exception statement from your version. */
package java.net; package java.net;
/** /**
* This exception is thrown when a String cannot be parsed as a URI. * This exception is thrown when a String cannot be parsed as a URI.
* *
...@@ -137,7 +138,7 @@ public class URISyntaxException extends Exception ...@@ -137,7 +138,7 @@ public class URISyntaxException extends Exception
*/ */
public String getMessage() public String getMessage()
{ {
return super.getMessage() + (index >= 0 ? " at index " + index : "") return (super.getMessage() + (index >= 0 ? " at index " + index : "")
+ ": " + input; + ": " + input);
} }
} }
...@@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify ...@@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option) the Free Software Foundation; either version 2, or (at your option)
any later version. any later version.
GNU Classpath is distributed in the hope that it will be useful, but GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
...@@ -39,8 +39,9 @@ package java.net; ...@@ -39,8 +39,9 @@ package java.net;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
/** /**
* This utility class contains static methods that converts a * This utility class contains static methods that converts a
* string encoded in the x-www-form-urlencoded format to the original * string encoded in the x-www-form-urlencoded format to the original
* text. The x-www-form-urlencoded format replaces certain disallowed * text. The x-www-form-urlencoded format replaces certain disallowed
* characters with encoded equivalents. All upper case and lower case * characters with encoded equivalents. All upper case and lower case
...@@ -65,7 +66,7 @@ public class URLDecoder ...@@ -65,7 +66,7 @@ public class URLDecoder
/** /**
* Public contructor. Note that this class has only static methods. * Public contructor. Note that this class has only static methods.
*/ */
public URLDecoder () public URLDecoder()
{ {
} }
...@@ -84,12 +85,12 @@ public class URLDecoder ...@@ -84,12 +85,12 @@ public class URLDecoder
{ {
try try
{ {
return decode(s, "UTF-8"); return decode(s, "UTF-8");
} }
catch (UnsupportedEncodingException uee) catch (UnsupportedEncodingException uee)
{ {
// Should never happen since UTF-8 encoding should always be supported // Should never happen since UTF-8 encoding should always be supported
return s; return s;
} }
} }
...@@ -120,7 +121,7 @@ public class URLDecoder ...@@ -120,7 +121,7 @@ public class URLDecoder
{ {
// First convert all '+' characters to spaces. // First convert all '+' characters to spaces.
String str = s.replace('+', ' '); String str = s.replace('+', ' ');
// Then go through the whole string looking for byte encoded characters // Then go through the whole string looking for byte encoded characters
int i; int i;
int start = 0; int start = 0;
...@@ -134,12 +135,12 @@ public class URLDecoder ...@@ -134,12 +135,12 @@ public class URLDecoder
start = i; start = i;
// Get all consecutive encoded bytes // Get all consecutive encoded bytes
while ((i+2 < length) && (str.charAt(i) == '%')) while ((i + 2 < length) && (str.charAt(i) == '%'))
i += 3; i += 3;
// Decode all these bytes // Decode all these bytes
if ((bytes == null) || (bytes.length < ((i-start)/3))) if ((bytes == null) || (bytes.length < ((i - start) / 3)))
bytes = new byte[((i-start)/3)]; bytes = new byte[((i - start) / 3)];
int index = 0; int index = 0;
try try
...@@ -147,7 +148,7 @@ public class URLDecoder ...@@ -147,7 +148,7 @@ public class URLDecoder
while (start < i) while (start < i)
{ {
String sub = str.substring(start + 1, start + 3); String sub = str.substring(start + 1, start + 3);
bytes[index] = (byte)Integer.parseInt(sub, 16); bytes[index] = (byte) Integer.parseInt(sub, 16);
index++; index++;
start += 3; start += 3;
} }
...@@ -176,5 +177,4 @@ public class URLDecoder ...@@ -176,5 +177,4 @@ public class URLDecoder
return result.toString(); return result.toString();
} }
} // class URLDecoder } // class URLDecoder
...@@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify ...@@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option) the Free Software Foundation; either version 2, or (at your option)
any later version. any later version.
GNU Classpath is distributed in the hope that it will be useful, but GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
...@@ -39,29 +39,30 @@ package java.net; ...@@ -39,29 +39,30 @@ package java.net;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
/* /*
* Written using on-line Java Platform 1.2/1.4 API Specification, as well * Written using on-line Java Platform 1.2/1.4 API Specification, as well
* as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998). * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
* Status: Believed complete and correct. * Status: Believed complete and correct.
*/ */
/** /**
* This utility class contains static methods that converts a * This utility class contains static methods that converts a
* string into a fully encoded URL string in x-www-form-urlencoded * string into a fully encoded URL string in x-www-form-urlencoded
* format. This format replaces certain disallowed characters with * format. This format replaces certain disallowed characters with
* encoded equivalents. All upper case and lower case letters in the * encoded equivalents. All upper case and lower case letters in the
* US alphabet remain as is, the space character (' ') is replaced with * US alphabet remain as is, the space character (' ') is replaced with
* '+' sign, and all other characters are converted to a "%XX" format * '+' sign, and all other characters are converted to a "%XX" format
* where XX is the hexadecimal representation of that character in a * where XX is the hexadecimal representation of that character in a
* certain encoding (by default, the platform encoding, though the * certain encoding (by default, the platform encoding, though the
* standard is "UTF-8"). * standard is "UTF-8").
* <p> * <p>
* This method is very useful for encoding strings to be sent to CGI scripts * This method is very useful for encoding strings to be sent to CGI scripts
* *
* @author Aaron M. Renn (arenn@urbanophile.com) * @author Aaron M. Renn (arenn@urbanophile.com)
* @author Warren Levy <warrenl@cygnus.com> * @author Warren Levy <warrenl@cygnus.com>
* @author Mark Wielaard (mark@klomp.org) * @author Mark Wielaard (mark@klomp.org)
*/ */
public class URLEncoder public class URLEncoder
{ {
/** /**
...@@ -82,11 +83,11 @@ public class URLEncoder ...@@ -82,11 +83,11 @@ public class URLEncoder
{ {
// We default to 8859_1 for compatibility with the same // We default to 8859_1 for compatibility with the same
// default elsewhere in the library. // default elsewhere in the library.
return encode(s, System.getProperty("file.encoding", "8859_1")); return encode(s, System.getProperty("file.encoding", "8859_1"));
} }
catch (UnsupportedEncodingException uee) catch (UnsupportedEncodingException uee)
{ {
// Should never happen since default should always be supported // Should never happen since default should always be supported
return s; return s;
} }
} }
...@@ -114,42 +115,42 @@ public class URLEncoder ...@@ -114,42 +115,42 @@ public class URLEncoder
StringBuffer result = new StringBuffer(length); StringBuffer result = new StringBuffer(length);
while (true) while (true)
{ {
while ( i < length && isSafe(s.charAt(i)) ) while (i < length && isSafe(s.charAt(i)))
i++;
// Safe character can just be added
result.append(s.substring(start, i));
// Are we done?
if (i >= length)
return result.toString();
else if (s.charAt(i) == ' ')
{
result.append('+'); // Replace space char with plus symbol.
i++; i++;
}
else
{
// Get all unsafe characters
start = i;
char c;
while ( i < length && (c = s.charAt(i)) != ' ' && !isSafe(c) )
i++;
// Convert them to %XY encoded strings // Safe character can just be added
String unsafe = s.substring(start,i); result.append(s.substring(start, i));
byte bytes[] = unsafe.getBytes(encoding);
for (int j = 0; j < bytes.length; j++) // Are we done?
{ if (i >= length)
result.append('%'); return result.toString();
int val = bytes[j]; else if (s.charAt(i) == ' ')
result.append(hex.charAt((val & 0xf0) >> 4)); {
result.append(hex.charAt(val & 0x0f)); result.append('+'); // Replace space char with plus symbol.
} i++;
} }
start = i; else
} {
// Get all unsafe characters
start = i;
char c;
while (i < length && (c = s.charAt(i)) != ' ' && ! isSafe(c))
i++;
// Convert them to %XY encoded strings
String unsafe = s.substring(start, i);
byte[] bytes = unsafe.getBytes(encoding);
for (int j = 0; j < bytes.length; j++)
{
result.append('%');
int val = bytes[j];
result.append(hex.charAt((val & 0xf0) >> 4));
result.append(hex.charAt(val & 0x0f));
}
}
start = i;
}
} }
/** /**
...@@ -160,17 +161,18 @@ public class URLEncoder ...@@ -160,17 +161,18 @@ public class URLEncoder
*/ */
private static boolean isSafe(char c) private static boolean isSafe(char c)
{ {
return ((c >= 'a' && c <= 'z') || return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
(c >= 'A' && c <= 'Z') || || (c >= '0' && c <= '9') || c == '-' || c == '_' || c == '.'
(c >= '0' && c <= '9') || || c == '*');
c == '-' || c == '_' || c == '.' || c == '*');
} }
/** /**
* Private constructor that does nothing. Included to avoid a default * Private constructor that does nothing. Included to avoid a default
* public constructor being created by the compiler. * public constructor being created by the compiler.
*/ */
private URLEncoder() { } private URLEncoder()
{
}
/** /**
* Used to convert to hex. We don't use Integer.toHexString, since * Used to convert to hex. We don't use Integer.toHexString, since
...@@ -179,4 +181,4 @@ public class URLEncoder ...@@ -179,4 +181,4 @@ public class URLEncoder
* leading 0. * leading 0.
*/ */
private static final String hex = "0123456789ABCDEF"; private static final String hex = "0123456789ABCDEF";
} // class URLEncoder }
...@@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify ...@@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option) the Free Software Foundation; either version 2, or (at your option)
any later version. any later version.
GNU Classpath is distributed in the hope that it will be useful, but GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
...@@ -37,15 +37,15 @@ exception statement from your version. */ ...@@ -37,15 +37,15 @@ exception statement from your version. */
package java.net; package java.net;
/** /**
* Written using on-line Java Platform 1.2 API Specification, as well * Written using on-line Java Platform 1.2 API Specification, as well
* as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998). * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
* Status: Believed complete and correct. * Status: Believed complete and correct.
*/ */
/** /**
* This interface contains one method which maps the protocol portion of * This interface contains one method which maps the protocol portion of
* a URL (eg, "http" in "http://www.urbanophile.com/arenn/") to a * a URL (eg, "http" in "http://www.urbanophile.com/arenn/") to a
* <code>URLStreamHandler</code> object. * <code>URLStreamHandler</code> object.
* *
* @author Aaron M. Renn (arenn@urbanophile.com) * @author Aaron M. Renn (arenn@urbanophile.com)
...@@ -54,14 +54,12 @@ package java.net; ...@@ -54,14 +54,12 @@ package java.net;
public interface URLStreamHandlerFactory public interface URLStreamHandlerFactory
{ {
/** /**
* This method maps the protocol portion of a URL to a * This method maps the protocol portion of a URL to a
* <code>URLStreamHandler</code> object. * <code>URLStreamHandler</code> object.
* *
* @param protocol The protocol name to map ("http", "ftp", etc). * @param protocol The protocol name to map ("http", "ftp", etc).
* *
* @return The <code>URLStreamHandler</code> for the specified protocol * @return The <code>URLStreamHandler</code> for the specified protocol
*/ */
URLStreamHandler createURLStreamHandler (String protocol); URLStreamHandler createURLStreamHandler(String protocol);
} // interface URLStreamHandlerFactory } // interface URLStreamHandlerFactory
...@@ -39,6 +39,7 @@ package java.net; ...@@ -39,6 +39,7 @@ package java.net;
import java.io.IOException; import java.io.IOException;
/** /**
* This exception indicates that an attempt was made to reference a hostname * This exception indicates that an attempt was made to reference a hostname
* or IP address that is not valid. This could possibly indicate that a * or IP address that is not valid. This could possibly indicate that a
......
...@@ -39,6 +39,7 @@ package java.net; ...@@ -39,6 +39,7 @@ package java.net;
import java.io.IOException; import java.io.IOException;
/** /**
* Contrary to what you might think, this does not indicate that the * Contrary to what you might think, this does not indicate that the
* TCP/IP service name specified was invalid. Instead it indicates that * TCP/IP service name specified was invalid. Instead it indicates that
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment