Index: java/net/Authenticator.java =================================================================== RCS file: /cvsroot/classpath/classpath/java/net/Authenticator.java,v retrieving revision 1.11 diff -u -r1.11 Authenticator.java --- java/net/Authenticator.java 24 May 2003 04:37:18 -0000 1.11 +++ java/net/Authenticator.java 8 Apr 2004 16:24:06 -0000 @@ -7,7 +7,7 @@ it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -37,18 +37,19 @@ package java.net; + /** * This abstract class provides a model for obtaining authentication * information (in the form of a username and password) required by * some network operations (such as hitting a password protected * web site). *
- * 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
- * would be a class that popped up a dialog box to prompt the user.
- * After creating an instance of that subclass, the static
- * setDefault
method of this class is called to set up
- * that instance as the object to use on subsequent calls to obtain
+ * would be a class that popped up a dialog box to prompt the user.
+ * After creating an instance of that subclass, the static
+ * setDefault
method of this class is called to set up
+ * that instance as the object to use on subsequent calls to obtain
* authorization.
*
* @since 1.2
@@ -106,8 +107,8 @@
*/
/**
- * This method sets the default Authenticator
object (an
- * instance of a subclass of Authenticator
) to use when
+ * This method sets the default Authenticator
object (an
+ * instance of a subclass of Authenticator
) to use when
* prompting the user for
* information. Note that this method checks to see if the caller is
* allowed to set this value (the "setDefaultAuthenticator" permission)
@@ -115,9 +116,9 @@
*
* @param defAuth The new default Authenticator
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
- */
+ */
public static void setDefault(Authenticator defAuth)
{
SecurityManager sm = System.getSecurityManager();
@@ -125,38 +126,40 @@
sm.checkPermission(new NetPermission("setDefaultAuthenticator"));
defaultAuthenticator = defAuth;
- }
+ }
/**
* This method is called whenever a username and password for a given
* network operation is required. First, a security check is made to see
* if the caller has the "requestPasswordAuthentication"
* permission. If not, the method thows an exception. If there is no
- * default Authenticator
object, the method then returns
- * null
. Otherwise, the default authenticators's instance
+ * default Authenticator
object, the method then returns
+ * null
. Otherwise, the default authenticators's instance
* variables are initialized and it's getPasswordAuthentication
* method is called to get the actual authentication information to return.
*
* @param addr The address requesting authentication
* @param port The port 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
* @param scheme The authentication scheme in use
- *
- * @return A PasswordAuthentication
object with the user's
+ *
+ * @return A PasswordAuthentication
object with the user's
* 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
- */
- public static PasswordAuthentication
- requestPasswordAuthentication(InetAddress addr, int port, String protocol,
- String prompt, String scheme)
+ */
+ public static PasswordAuthentication requestPasswordAuthentication(InetAddress addr,
+ int port,
+ String protocol,
+ String prompt,
+ String scheme)
throws SecurityException
{
- return(requestPasswordAuthentication (null, addr, port, protocol,
- prompt, scheme));
+ return requestPasswordAuthentication(null, addr, port, protocol, prompt,
+ scheme);
}
/**
@@ -175,21 +178,24 @@
* @param addr The address requesting authentication
* @param port The port 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
* @param scheme The authentication scheme in use
*
- * @return A PasswordAuthentication
object with the user's
+ * @return A PasswordAuthentication
object with the user's
* 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
*
* @since 1.4
*/
- public static PasswordAuthentication
- requestPasswordAuthentication(String host, InetAddress addr, int port,
- String protocol, String prompt, String scheme)
+ public static PasswordAuthentication requestPasswordAuthentication(String host,
+ InetAddress addr,
+ int port,
+ String protocol,
+ String prompt,
+ String scheme)
throws SecurityException
{
SecurityManager sm = System.getSecurityManager();
@@ -197,7 +203,7 @@
sm.checkPermission(new NetPermission("requestPasswordAuthentication"));
if (defaultAuthenticator == null)
- return(null);
+ return null;
defaultAuthenticator.host = host;
defaultAuthenticator.addr = addr;
@@ -206,7 +212,7 @@
defaultAuthenticator.prompt = prompt;
defaultAuthenticator.scheme = scheme;
- return(defaultAuthenticator.getPasswordAuthentication());
+ return defaultAuthenticator.getPasswordAuthentication();
}
/*
@@ -232,7 +238,7 @@
*/
protected final InetAddress getRequestingSite()
{
- return(addr);
+ return addr;
}
/**
@@ -240,24 +246,24 @@
* or null
if not available.
*
* @return The name of the host requesting authentication, or
- * null if it is not available.
+ * null
if it is not available.
*
* @since 1.4
*/
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.
*
* @return The requesting port
*/
protected final int getRequestingPort()
{
- return(port);
+ return port;
}
/**
@@ -268,18 +274,18 @@
*/
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
- *
+ *
* @return The user prompt
*/
protected final String getRequestingPrompt()
{
- return(prompt);
+ return prompt;
}
/**
@@ -289,7 +295,7 @@
*/
protected final String getRequestingScheme()
{
- return(scheme);
+ return scheme;
}
/**
@@ -302,8 +308,6 @@
*/
protected PasswordAuthentication getPasswordAuthentication()
{
- return(null);
+ return null;
}
-
} // class Authenticator
-
Index: java/net/BindException.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/net/BindException.java,v
retrieving revision 1.9
diff -u -r1.9 BindException.java
--- java/net/BindException.java 27 Aug 2002 17:48:05 -0000 1.9
+++ java/net/BindException.java 8 Apr 2004 16:24:06 -0000
@@ -37,6 +37,7 @@
package java.net;
+
/**
* This exception indicates that an error occurred while attempting to bind
* socket to a particular port.
Index: java/net/ConnectException.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/net/ConnectException.java,v
retrieving revision 1.8
diff -u -r1.8 ConnectException.java
--- java/net/ConnectException.java 24 Feb 2002 04:25:16 -0000 1.8
+++ java/net/ConnectException.java 8 Apr 2004 16:24:06 -0000
@@ -35,8 +35,8 @@
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-
package java.net;
+
/**
* This exception indicates that an error occurred while attempting to
Index: java/net/DatagramPacket.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/net/DatagramPacket.java,v
retrieving revision 1.13
diff -u -r1.13 DatagramPacket.java
--- java/net/DatagramPacket.java 26 Dec 2003 22:27:03 -0000 1.13
+++ java/net/DatagramPacket.java 8 Apr 2004 16:24:06 -0000
@@ -7,7 +7,7 @@
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
-
+
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@@ -37,6 +37,7 @@
package java.net;
+
/*
* Written using on-line Java Platform 1.2 API Specification, as well
* as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
@@ -86,7 +87,7 @@
* The maximal length of the buffer.
*/
int maxlen;
-
+
/**
* The address to which the packet should be sent or from which it
* was received.
@@ -134,14 +135,14 @@
*
* @param buf A buffer containing the data to send
* @param offset The offset into the buffer to start writing from.
- * @param len The length of the buffer (must be <= buf.length)
- * @param addr The address to send to
+ * @param length The length of the buffer (must be <= buf.length)
+ * @param address The address to send to
* @param port The port to send to
*
* @since 1.2
*/
public DatagramPacket(byte[] buf, int offset, int length,
- InetAddress address, int port)
+ InetAddress address, int port)
{
setData(buf, offset, length);
setAddress(address);
@@ -177,8 +178,7 @@
* @since 1.4
*/
public DatagramPacket(byte[] buf, int offset, int length,
- SocketAddress address)
- throws SocketException
+ SocketAddress address) throws SocketException
{
if (! (address instanceof InetSocketAddress))
throw new IllegalArgumentException("unsupported address type");
@@ -272,16 +272,16 @@
/**
* 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
*/
- public synchronized void setAddress(InetAddress iaddr)
+ public synchronized void setAddress(InetAddress address)
{
- if (iaddr == null)
+ if (address == null)
throw new NullPointerException("Null address");
- address = iaddr;
+ this.address = address;
}
/**
@@ -291,12 +291,12 @@
*
* @since 1.1
*/
- public synchronized void setPort(int iport)
+ public synchronized void setPort(int port)
{
- if (iport < 0 || iport > 65535)
- throw new IllegalArgumentException("Invalid port: " + iport);
+ if (port < 0 || port > 65535)
+ throw new IllegalArgumentException("Invalid port: " + port);
- port = iport;
+ this.port = port;
}
/**
@@ -324,12 +324,12 @@
* will be sent to/is coming from
*
* @return The socket address of the remote host
- *
+ *
* @since 1.4
*/
public SocketAddress getSocketAddress()
{
- return new InetSocketAddress (address, port);
+ return new InetSocketAddress(address, port);
}
/**
@@ -360,7 +360,6 @@
public synchronized void setData(byte[] buf, int offset, int length)
{
// This form of setData must be used if offset is to be changed.
-
if (buf == null)
throw new NullPointerException("Null buffer");
if (offset < 0)
@@ -372,7 +371,7 @@
}
/**
- * 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 <= buf.length)
*
@@ -387,7 +386,7 @@
throw new IllegalArgumentException("Invalid length: " + length);
if (offset + length > buffer.length)
throw new IllegalArgumentException("Potential buffer overflow - offset: "
- + offset + " length: " + length);
+ + offset + " length: " + length);
this.length = length;
this.maxlen = length;
Index: java/net/DatagramSocket.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/net/DatagramSocket.java,v
retrieving revision 1.39
diff -u -r1.39 DatagramSocket.java
--- java/net/DatagramSocket.java 12 Feb 2004 16:38:11 -0000 1.39
+++ java/net/DatagramSocket.java 8 Apr 2004 16:24:06 -0000
@@ -7,7 +7,7 @@
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
-
+
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@@ -35,7 +35,6 @@
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-
package java.net;
import gnu.java.net.PlainDatagramSocketImpl;
@@ -44,24 +43,23 @@
import java.nio.channels.DatagramChannel;
import java.nio.channels.IllegalBlockingModeException;
+
/**
* Written using on-line Java Platform 1.2 API Specification, as well
* as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
* Status: Believed complete and correct.
*/
-
/**
- * This class models a connectionless datagram socket that sends
+ * This class models a connectionless datagram socket that sends
* individual packets of data across the network. In the TCP/IP world,
* this means UDP. Datagram packets do not have guaranteed delivery,
* or any guarantee about the order the data will be received on the
* remote host.
- *
+ *
* @author Aaron M. Renn (address@hidden)
* @author Warren Levy (address@hidden)
* @date May 3, 1999.
*/
-
public class DatagramSocket
{
/**
@@ -69,7 +67,7 @@
* variable is null, a default factory is used.
*/
private static DatagramSocketImplFactory factory;
-
+
/**
* This is the implementation object used by this socket.
*/
@@ -96,15 +94,15 @@
private boolean bound;
/**
- * Creates a DatagramSocket
from a specified
+ * Creates a DatagramSocket
from a specified
* DatagramSocketImpl
instance
*
- * @param impl The DatagramSocketImpl
the socket will be
+ * @param impl The DatagramSocketImpl
the socket will be
* created from
- *
+ *
* @since 1.4
*/
- protected DatagramSocket (DatagramSocketImpl impl)
+ protected DatagramSocket(DatagramSocketImpl impl)
{
if (impl == null)
throw new NullPointerException("impl may not be null");
@@ -115,7 +113,7 @@
}
/**
- * Initializes a new instance of DatagramSocket
that binds to
+ * Initializes a new instance of DatagramSocket
that binds to
* a random port and every address on the local machine.
*
* @exception SocketException If an error occurs.
@@ -128,7 +126,7 @@
}
/**
- * Initializes a new instance of DatagramSocket
that binds to
+ * Initializes a new instance of DatagramSocket
that binds to
* the specified port and every address on the local machine.
*
* @param port The local port number to bind to.
@@ -143,7 +141,7 @@
}
/**
- * Initializes a new instance of DatagramSocket
that binds to
+ * Initializes a new instance of DatagramSocket
that binds to
* the specified local port and address.
*
* @param port The local port number to bind to.
@@ -159,7 +157,7 @@
}
/**
- * Initializes a new instance of DatagramSocket
that binds to
+ * Initializes a new instance of DatagramSocket
that binds to
* the specified local port and address.
*
* @param address The local address and port number to bind to.
@@ -170,35 +168,36 @@
*
* @since 1.4
*/
- public DatagramSocket (SocketAddress address) throws SocketException
+ public DatagramSocket(SocketAddress address) throws SocketException
{
String propVal = System.getProperty("impl.prefix");
if (propVal == null || propVal.equals(""))
impl = new PlainDatagramSocketImpl();
else
try
- {
- impl = (DatagramSocketImpl) Class.forName
- ("java.net." + propVal + "DatagramSocketImpl").newInstance();
- }
+ {
+ impl =
+ (DatagramSocketImpl) Class.forName("java.net." + propVal
+ + "DatagramSocketImpl")
+ .newInstance();
+ }
catch (Exception e)
- {
- System.err.println("Could not instantiate class: java.net." +
- propVal + "DatagramSocketImpl");
+ {
+ System.err.println("Could not instantiate class: java.net."
+ + propVal + "DatagramSocketImpl");
impl = new PlainDatagramSocketImpl();
- }
+ }
if (address != null)
bind(address);
}
-
+
// This needs to be accessible from java.net.MulticastSocket
- DatagramSocketImpl getImpl()
- throws SocketException
+ DatagramSocketImpl getImpl() throws SocketException
{
try
{
- if (!implCreated)
+ if (! implCreated)
{
impl.create();
implCreated = true;
@@ -211,7 +210,7 @@
throw new SocketException(e.getMessage());
}
}
-
+
/**
* Closes this datagram socket.
*/
@@ -219,7 +218,7 @@
{
if (isClosed())
return;
-
+
try
{
getImpl().close();
@@ -247,10 +246,10 @@
}
/**
- * This method returns the remote address to which this socket is
+ * This method returns the remote address to which this socket is
* connected. If this socket is not connected, then this method will
* return null
.
- *
+ *
* @return The remote address.
*
* @since 1.2
@@ -264,7 +263,7 @@
* This method returns the remote port to which this socket is
* connected. If this socket is not connected, then this method will
* return -1.
- *
+ *
* @return The remote port.
*
* @since 1.2
@@ -276,7 +275,7 @@
/**
* Returns the local address this datagram socket is bound to.
- *
+ *
* @return The local address is the socket is bound or null
*
* @since 1.1
@@ -285,16 +284,17 @@
{
if (isClosed())
return null;
-
+
InetAddress localAddr;
-
+
try
{
- localAddr = (InetAddress) getImpl().getOption(SocketOptions.SO_BINDADDR);
+ localAddr =
+ (InetAddress) getImpl().getOption(SocketOptions.SO_BINDADDR);
SecurityManager s = System.getSecurityManager();
if (s != null)
- s.checkConnect (localAddr.getHostName(), -1);
+ s.checkConnect(localAddr.getHostName(), -1);
}
catch (SecurityException e)
{
@@ -303,7 +303,7 @@
catch (SocketException e)
{
// This cannot happen as we are bound.
- return null;
+ return null;
}
return localAddr;
@@ -318,7 +318,7 @@
{
if (isClosed())
return -1;
-
+
try
{
return getImpl().getLocalPort();
@@ -337,7 +337,7 @@
* @return The current timeout in milliseconds.
*
* @exception SocketException If an error occurs.
- *
+ *
* @since 1.1
*/
public synchronized int getSoTimeout() throws SocketException
@@ -347,7 +347,7 @@
Object buf = getImpl().getOption(SocketOptions.SO_TIMEOUT);
- if (buf instanceof Integer)
+ if (buf instanceof Integer)
return ((Integer) buf).intValue();
throw new SocketException("unexpected type");
@@ -368,7 +368,7 @@
{
if (isClosed())
throw new SocketException("socket is closed");
-
+
if (timeout < 0)
throw new IllegalArgumentException("Invalid timeout: " + timeout);
@@ -390,7 +390,7 @@
{
if (isClosed())
throw new SocketException("socket is closed");
-
+
Object buf = getImpl().getOption(SocketOptions.SO_SNDBUF);
if (buf instanceof Integer)
@@ -415,10 +415,10 @@
{
if (isClosed())
throw new SocketException("socket is closed");
-
+
if (size < 0)
throw new IllegalArgumentException("Buffer size is less than 0");
-
+
getImpl().setOption(SocketOptions.SO_SNDBUF, new Integer(size));
}
@@ -439,7 +439,7 @@
throw new SocketException("socket is closed");
Object buf = getImpl().getOption(SocketOptions.SO_RCVBUF);
-
+
if (buf instanceof Integer)
return ((Integer) buf).intValue();
@@ -455,7 +455,7 @@
*
* @exception SocketException If an error occurs.
* @exception IllegalArgumentException If size is 0 or negative.
- *
+ *
* @since 1.2
*/
public void setReceiveBufferSize(int size) throws SocketException
@@ -474,7 +474,7 @@
* When a datagram socket is connected, it will only send or receive
* packets to and from the host to which it is connected. A multicast
* socket that is connected may only send and not receive packets.
- *
+ *
* @param address The address to connect this socket to.
* @param port The port to connect this socket to.
*
@@ -488,10 +488,10 @@
public void connect(InetAddress address, int port)
{
if (address == null)
- throw new IllegalArgumentException ("Connect address may not be null");
+ throw new IllegalArgumentException("Connect address may not be null");
if ((port < 1) || (port > 65535))
- throw new IllegalArgumentException ("Port number is illegal: " + port);
+ throw new IllegalArgumentException("Port number is illegal: " + port);
SecurityManager sm = System.getSecurityManager();
if (sm != null)
@@ -499,13 +499,13 @@
try
{
- getImpl().connect (address, port);
- remoteAddress = address;
- remotePort = port;
+ getImpl().connect(address, port);
+ remoteAddress = address;
+ remotePort = port;
}
catch (SocketException e)
{
- // This means simply not connected or connect not implemented.
+ // This means simply not connected or connect not implemented.
}
}
@@ -513,12 +513,12 @@
* This method disconnects this socket from the address/port it was
* connected to. If the socket was not connected in the first place,
* this method does nothing.
- *
+ *
* @since 1.2
*/
public void disconnect()
{
- if (!isConnected())
+ if (! isConnected())
return;
try
@@ -559,22 +559,20 @@
{
if (isClosed())
throw new SocketException("socket is closed");
-
- if (remoteAddress != null
- && remoteAddress.isMulticastAddress())
+
+ if (remoteAddress != null && remoteAddress.isMulticastAddress())
throw new IOException
- ("Socket connected to a multicast address my not receive");
+ ("Socket connected to a multicast address my not receive");
- if (getChannel() != null
- && !getChannel().isBlocking ()
- && !((DatagramChannelImpl) getChannel()).isInChannelOperation())
- throw new IllegalBlockingModeException ();
+ if (getChannel() != null && ! getChannel().isBlocking()
+ && ! ((DatagramChannelImpl) getChannel()).isInChannelOperation())
+ throw new IllegalBlockingModeException();
getImpl().receive(p);
SecurityManager s = System.getSecurityManager();
- if (s != null && isConnected ())
- s.checkAccept (p.getAddress().getHostName (), p.getPort ());
+ if (s != null && isConnected())
+ s.checkAccept(p.getAddress().getHostName(), p.getPort());
}
/**
@@ -596,33 +594,31 @@
{
if (isClosed())
throw new SocketException("socket is closed");
-
+
// JDK1.2: Don't do security checks if socket is connected; see jdk1.2 api.
SecurityManager s = System.getSecurityManager();
- if (s != null && !isConnected ())
+ if (s != null && ! isConnected())
{
- InetAddress addr = p.getAddress();
- if (addr.isMulticastAddress())
- s.checkMulticast(addr);
- else
- s.checkConnect(addr.getHostAddress(), p.getPort());
+ InetAddress addr = p.getAddress();
+ if (addr.isMulticastAddress())
+ s.checkMulticast(addr);
+ else
+ s.checkConnect(addr.getHostAddress(), p.getPort());
}
- if (isConnected ())
+ if (isConnected())
{
- if (p.getAddress () != null && (remoteAddress != p.getAddress () ||
- remotePort != p.getPort ()))
- throw new IllegalArgumentException (
- "DatagramPacket address does not match remote address" );
+ if (p.getAddress() != null
+ && (remoteAddress != p.getAddress() || remotePort != p.getPort()))
+ throw new IllegalArgumentException
+ ("DatagramPacket address does not match remote address");
}
-
+
// FIXME: if this is a subclass of MulticastSocket,
// use getTimeToLive for TTL val.
-
- if (getChannel() != null
- && !getChannel().isBlocking ()
- && !((DatagramChannelImpl) getChannel()).isInChannelOperation())
- throw new IllegalBlockingModeException ();
+ if (getChannel() != null && ! getChannel().isBlocking()
+ && ! ((DatagramChannelImpl) getChannel()).isInChannelOperation())
+ throw new IllegalBlockingModeException();
getImpl().send(p);
}
@@ -639,12 +635,11 @@
*
* @since 1.4
*/
- public void bind (SocketAddress address)
- throws SocketException
+ public void bind(SocketAddress address) throws SocketException
{
if (isClosed())
throw new SocketException("socket is closed");
-
+
if (! (address instanceof InetSocketAddress))
throw new IllegalArgumentException("unsupported address type");
@@ -654,32 +649,32 @@
if (port < 0 || port > 65535)
throw new IllegalArgumentException("Invalid port: " + port);
- SecurityManager s = System.getSecurityManager ();
+ SecurityManager s = System.getSecurityManager();
if (s != null)
s.checkListen(port);
if (addr == null)
addr = InetAddress.ANY_IF;
-
+
try
{
- getImpl().bind(port, addr);
+ getImpl().bind(port, addr);
bound = true;
}
catch (SocketException exception)
{
- getImpl().close();
- throw exception;
+ getImpl().close();
+ throw exception;
}
catch (RuntimeException exception)
{
- getImpl().close();
- throw exception;
+ getImpl().close();
+ throw exception;
}
catch (Error error)
{
- getImpl().close();
- throw error;
+ getImpl().close();
+ throw error;
}
}
@@ -687,7 +682,7 @@
* Checks if the datagram socket is closed.
*
* @return True if socket is closed, false otherwise.
- *
+ *
* @since 1.4
*/
public boolean isClosed()
@@ -697,9 +692,9 @@
/**
* Returns the datagram channel assoziated with this datagram socket.
- *
+ *
* @return The associated DatagramChannel
object or null
- *
+ *
* @since 1.4
*/
public DatagramChannel getChannel()
@@ -717,23 +712,23 @@
*
* @since 1.4
*/
- public void connect (SocketAddress address) throws SocketException
+ public void connect(SocketAddress address) throws SocketException
{
if (isClosed())
throw new SocketException("socket is closed");
-
- if ( !(address instanceof InetSocketAddress) )
+
+ if (! (address instanceof InetSocketAddress))
throw new IllegalArgumentException("unsupported address type");
InetSocketAddress tmp = (InetSocketAddress) address;
connect(tmp.getAddress(), tmp.getPort());
}
-
+
/**
* Returns the binding state of the socket.
- *
+ *
* @return True if socket bound, false otherwise.
- *
+ *
* @since 1.4
*/
public boolean isBound()
@@ -743,9 +738,9 @@
/**
* Returns the connection state of the socket.
- *
+ *
* @return True if socket is connected, false otherwise.
- *
+ *
* @since 1.4
*/
public boolean isConnected()
@@ -756,32 +751,32 @@
/**
* Returns the SocketAddress of the host this socket is conneted to
* or null if this socket is not connected.
- *
+ *
* @return The socket address of the remote host if connected or null
- *
+ *
* @since 1.4
*/
public SocketAddress getRemoteSocketAddress()
{
- if (!isConnected ())
+ if (! isConnected())
return null;
- return new InetSocketAddress (remoteAddress, remotePort);
+ return new InetSocketAddress(remoteAddress, remotePort);
}
/**
* Returns the local SocketAddress this socket is bound to.
*
* @return The local SocketAddress or null if the socket is not bound.
- *
+ *
* @since 1.4
*/
public SocketAddress getLocalSocketAddress()
{
- if (!isBound())
+ if (! isBound())
return null;
-
- return new InetSocketAddress (getLocalAddress(), getLocalPort());
+
+ return new InetSocketAddress(getLocalAddress(), getLocalPort());
}
/**
@@ -798,7 +793,7 @@
if (isClosed())
throw new SocketException("socket is closed");
- getImpl().setOption (SocketOptions.SO_REUSEADDR, Boolean.valueOf(on));
+ getImpl().setOption(SocketOptions.SO_REUSEADDR, Boolean.valueOf(on));
}
/**
@@ -807,7 +802,7 @@
* @return True if SO_REUSEADDR is set on the socket, false otherwise.
*
* @exception SocketException If an error occurs.
- *
+ *
* @since 1.4
*/
public boolean getReuseAddress() throws SocketException
@@ -815,8 +810,8 @@
if (isClosed())
throw new SocketException("socket is closed");
- Object buf = getImpl().getOption (SocketOptions.SO_REUSEADDR);
-
+ Object buf = getImpl().getOption(SocketOptions.SO_REUSEADDR);
+
if (buf instanceof Boolean)
return ((Boolean) buf).booleanValue();
@@ -825,7 +820,7 @@
/**
* Enables/Disables SO_BROADCAST
- *
+ *
* @param enable True if SO_BROADCAST should be enabled, false otherwise.
*
* @exception SocketException If an error occurs
@@ -842,11 +837,11 @@
/**
* Checks if SO_BROADCAST is enabled
- *
+ *
* @return Whether SO_BROADCAST is set
*
* @exception SocketException If an error occurs
- *
+ *
* @since 1.4
*/
public boolean getBroadcast() throws SocketException
@@ -855,7 +850,7 @@
throw new SocketException("socket is closed");
Object buf = getImpl().getOption(SocketOptions.SO_BROADCAST);
-
+
if (buf instanceof Boolean)
return ((Boolean) buf).booleanValue();
@@ -871,11 +866,10 @@
* @exception IllegalArgumentException If tc value is illegal
*
* @see DatagramSocket#getTrafficClass()
- *
+ *
* @since 1.4
*/
- public void setTrafficClass(int tc)
- throws SocketException
+ public void setTrafficClass(int tc) throws SocketException
{
if (isClosed())
throw new SocketException("socket is closed");
@@ -883,25 +877,25 @@
if (tc < 0 || tc > 255)
throw new IllegalArgumentException();
- getImpl().setOption (SocketOptions.IP_TOS, new Integer (tc));
+ getImpl().setOption(SocketOptions.IP_TOS, new Integer(tc));
}
-
+
/**
* Returns the current traffic class
- *
+ *
* @return The current traffic class.
*
* @see DatagramSocket#setTrafficClass(int tc)
*
* @exception SocketException If an error occurs
- *
+ *
* @since 1.4
*/
public int getTrafficClass() throws SocketException
{
if (isClosed())
throw new SocketException("socket is closed");
-
+
Object buf = getImpl().getOption(SocketOptions.IP_TOS);
if (buf instanceof Integer)
@@ -909,7 +903,7 @@
throw new SocketException("unexpected type");
}
-
+
/**
* Sets the datagram socket implementation factory for the application
*
@@ -920,11 +914,11 @@
* @exception SecurityException If a security manager exists and its
* checkSetFactory method doesn't allow the operation
*/
- public static void setDatagramSocketImplFactory
- (DatagramSocketImplFactory fac) throws IOException
+ public static void setDatagramSocketImplFactory(DatagramSocketImplFactory fac)
+ throws IOException
{
if (factory != null)
- throw new SocketException ("DatagramSocketImplFactory already defined");
+ throw new SocketException("DatagramSocketImplFactory already defined");
SecurityManager sm = System.getSecurityManager();
if (sm != null)
Index: java/net/DatagramSocketImpl.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/net/DatagramSocketImpl.java,v
retrieving revision 1.20
diff -u -r1.20 DatagramSocketImpl.java
--- java/net/DatagramSocketImpl.java 7 Jun 2003 21:19:02 -0000 1.20
+++ java/net/DatagramSocketImpl.java 8 Apr 2004 16:24:06 -0000
@@ -1,5 +1,5 @@
/* 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.
This file is part of GNU Classpath.
@@ -36,11 +36,11 @@
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-
package java.net;
-import java.io.IOException;
import java.io.FileDescriptor;
+import java.io.IOException;
+
/**
* This abstract class models a datagram socket implementation. An
@@ -58,7 +58,6 @@
*/
public abstract class DatagramSocketImpl implements SocketOptions
{
-
/**
* The local port to which this socket is bound
*/
@@ -103,7 +102,7 @@
* Takes a peek at the next packet received in order to retrieve the
* address of the sender
*
- * @param i The InetAddress
to fill in with the information
+ * @param i The InetAddress
to fill in with the information
* about the sender if the next packet
*
* @return The port number of the sender of the packet
@@ -118,19 +117,19 @@
/**
* 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.
- *
+ *
* @param p The DatagramPacket
to fill in with the data sent.
*
* @return The port number of the sender of the packet.
- *
+ *
* @exception IOException If an error occurs
* @exception PortUnreachableException May be thrown if the socket is
* connected to a currently unreachable destination. Note, there is no
* guarantee that the exception will be thrown.
- *
+ *
* @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
@@ -169,17 +168,18 @@
*
* @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
}
/**
* Disconnects the socket.
- *
+ *
* @since 1.4
*/
- protected void disconnect ()
+ protected void disconnect()
{
// This method has to be overwritten by real implementations
}
@@ -199,8 +199,11 @@
* This method returns the current Time to Live (TTL) setting on this
* socket. Use getTimeToLive()
instead.
*
+ * @return the current time-to-live
+ *
* @exception IOException If an error occurs
- * @deprecated
+ *
+ * @deprecated // FIXME: when ?
*/
protected abstract byte getTTL() throws IOException;
@@ -218,6 +221,8 @@
* This method returns the current Time to Live (TTL) setting on this
* socket.
*
+ * @return the current time-to-live
+ *
* @exception IOException If an error occurs
*/
protected abstract int getTimeToLive() throws IOException;
@@ -242,35 +247,37 @@
/**
* Causes this socket to join the specified multicast group on a specified
- * device
- *
+ * device
+ *
* @param mcastaddr The address to leave
* @param netIf The specified network interface to join the group at
*
* @exception IOException If an error occurs
- *
+ *
* @since 1.4
*/
- protected abstract void joinGroup (SocketAddress mcastaddr,
- NetworkInterface netIf)
+ protected abstract void joinGroup(SocketAddress mcastaddr,
+ NetworkInterface netIf)
throws IOException;
/**
* Leaves a multicast group
- *
+ *
* @param mcastaddr The address to join
* @param netIf The specified network interface to leave the group at
*
* @exception IOException If an error occurs
- *
+ *
* @since 1.4
*/
- protected abstract void leaveGroup (SocketAddress mcastaddr,
- NetworkInterface netIf)
+ protected abstract void leaveGroup(SocketAddress mcastaddr,
+ NetworkInterface netIf)
throws IOException;
-
+
/**
* Returns the FileDescriptor for this socket
+ *
+ * @return the file descriptor associated with this socket
*/
protected FileDescriptor getFileDescriptor()
{
@@ -279,6 +286,8 @@
/**
* Returns the local port this socket is bound to
+ *
+ * @return the local port
*/
protected int getLocalPort()
{
Index: java/net/DatagramSocketImplFactory.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/net/DatagramSocketImplFactory.java,v
retrieving revision 1.3
diff -u -r1.3 DatagramSocketImplFactory.java
--- java/net/DatagramSocketImplFactory.java 12 Oct 2003 15:35:01 -0000 1.3
+++ java/net/DatagramSocketImplFactory.java 8 Apr 2004 16:24:06 -0000
@@ -7,7 +7,7 @@
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
-
+
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@@ -37,12 +37,12 @@
package java.net;
+
/** Written using on-line Java Platform 1.4 API Specification.
* Status: Believed complete and correct.
*/
-
/**
- * This interface defines one method which returns a
+ * This interface defines one method which returns a
* DatagramSocketImpl
object.
* This should not be needed by ordinary applications.
*
@@ -57,5 +57,4 @@
* @return A DatagramSocketImpl object
*/
DatagramSocketImpl createDatagramSocketImpl();
-
} // interface DatagramSocketImplFactory
Index: java/net/FileNameMap.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/net/FileNameMap.java,v
retrieving revision 1.11
diff -u -r1.11 FileNameMap.java
--- java/net/FileNameMap.java 12 Oct 2003 15:35:01 -0000 1.11
+++ java/net/FileNameMap.java 8 Apr 2004 16:24:06 -0000
@@ -7,7 +7,7 @@
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
-
+
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@@ -35,15 +35,14 @@
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-
package java.net;
+
/**
* Written using on-line Java Platform 1.2 API Specification, as well
* as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
* Status: Believed complete and correct.
*/
-
/**
* This interface has one method which, when passed a filename, returns
* the MIME type associated with that filename.
@@ -63,6 +62,4 @@
* @return The MIME type for the filename passed in.
*/
String getContentTypeFor(String filename);
-
} // interface FileNameMap
-
Index: java/net/HttpURLConnection.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/net/HttpURLConnection.java,v
retrieving revision 1.17
diff -u -r1.17 HttpURLConnection.java
--- java/net/HttpURLConnection.java 19 Mar 2004 21:54:27 -0000 1.17
+++ java/net/HttpURLConnection.java 8 Apr 2004 16:24:07 -0000
@@ -8,7 +8,7 @@
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
-
+
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+02111-1307 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -36,14 +36,14 @@
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-
package java.net;
-import java.io.InputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.PushbackInputStream;
import java.security.Permission;
+
/*
* Written using on-line Java Platform 1.2 API Specification, as well
* as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
@@ -51,12 +51,12 @@
*/
/**
- * This class provides a common abstract implementation for those
+ * This class provides a common abstract implementation for those
* URL connection classes that will connect using the HTTP protocol.
* In addition to the functionality provided by the URLConnection
* class, it defines constants for HTTP return code values and
* methods for setting the HTTP request method and determining whether
- * or not to follow redirects.
+ * or not to follow redirects.
*
* @since 1.1
*
@@ -73,27 +73,27 @@
* beware of using this value
*/
static final int HTTP_CONTINUE = 100;
-
+
/**
* Indicates the request succeeded.
*/
- public static final int HTTP_OK = 200;
+ public static final int HTTP_OK = 200;
/**
* The requested resource has been created.
*/
- public static final int HTTP_CREATED = 201;
+ public static final int HTTP_CREATED = 201;
/**
* The request has been accepted for processing but has not completed.
* There is no guarantee that the requested action will actually ever
* be completed succesfully, but everything is ok so far.
*/
- public static final int HTTP_ACCEPTED = 202;
+ public static final int HTTP_ACCEPTED = 202;
/**
* The meta-information returned in the header is not the actual data
- * from the original server, but may be from a local or other copy.
+ * from the original server, but may be from a local or other copy.
* Normally this still indicates a successful completion.
*/
public static final int HTTP_NOT_AUTHORITATIVE = 203;
@@ -102,20 +102,19 @@
* The server performed the request, but there is no data to send
* back. This indicates that the user's display should not be changed.
*/
- public static final int HTTP_NO_CONTENT = 204;
+ public static final int HTTP_NO_CONTENT = 204;
/**
* The server performed the request, but there is no data to sent back,
* however, the user's display should be "reset" to clear out any form
* fields entered.
*/
- public static final int HTTP_RESET = 205;
+ public static final int HTTP_RESET = 205;
/**
* The server completed the partial GET request for the resource.
*/
- public static final int HTTP_PARTIAL = 206;
-
+ public static final int HTTP_PARTIAL = 206;
/* HTTP Redirection Response Codes */
@@ -123,22 +122,22 @@
* There is a list of choices available for the requested resource.
*/
public static final int HTTP_MULT_CHOICE = 300;
-
+
/**
* The resource has been permanently moved to a new location.
*/
public static final int HTTP_MOVED_PERM = 301;
-
+
/**
* The resource requested has been temporarily moved to a new location.
*/
public static final int HTTP_MOVED_TEMP = 302;
-
+
/**
* The response to the request issued is available at another location.
*/
public static final int HTTP_SEE_OTHER = 303;
-
+
/**
* The document has not been modified since the criteria specified in
* a conditional GET.
@@ -149,64 +148,63 @@
* The requested resource needs to be accessed through a proxy.
*/
public static final int HTTP_USE_PROXY = 305;
-
-
+
/* HTTP Client Error Response Codes */
/**
* The request was misformed or could not be understood.
*/
public static final int HTTP_BAD_REQUEST = 400;
-
+
/**
* The request made requires user authorization. Try again with
* a correct authentication header.
*/
public static final int HTTP_UNAUTHORIZED = 401;
-
+
/**
* Code reserved for future use - I hope way in the future.
*/
public static final int HTTP_PAYMENT_REQUIRED = 402;
-
+
/**
* There is no permission to access the requested resource.
*/
public static final int HTTP_FORBIDDEN = 403;
-
+
/**
* The requested resource was not found.
*/
public static final int HTTP_NOT_FOUND = 404;
-
+
/**
* The specified request method is not allowed for this resource.
*/
public static final int HTTP_BAD_METHOD = 405;
-
+
/**
* Based on the input headers sent, the resource returned in response
* to the request would not be acceptable to the client.
*/
public static final int HTTP_NOT_ACCEPTABLE = 406;
-
+
/**
* The client must authenticate with a proxy prior to attempting this
* request.
*/
public static final int HTTP_PROXY_AUTH = 407;
-
+
/**
* The request timed out.
*/
public static final int HTTP_CLIENT_TIMEOUT = 408;
-
+
/**
* There is a conflict between the current state of the resource and the
* requested action.
*/
public static final int HTTP_CONFLICT = 409;
-
+
/**
* The requested resource is no longer available. This ususally indicates
* a permanent condition.
@@ -218,28 +216,27 @@
* supplied.
*/
public static final int HTTP_LENGTH_REQUIRED = 411;
-
+
/**
* A client specified pre-condition was not met on the server.
*/
public static final int HTTP_PRECON_FAILED = 412;
-
+
/**
* The request sent was too large for the server to handle.
*/
public static final int HTTP_ENTITY_TOO_LARGE = 413;
-
+
/**
* The name of the resource specified was too long.
*/
public static final int HTTP_REQ_TOO_LONG = 414;
-
+
/**
* The request is in a format not supported by the requested resource.
*/
public static final int HTTP_UNSUPPORTED_TYPE = 415;
-
/* HTTP Server Error Response Codes */
/**
@@ -247,16 +244,16 @@
*
* @deprecated
*/
- public static final int HTTP_SERVER_ERROR = 500;
+ public static final int HTTP_SERVER_ERROR = 500;
/**
* The server encountered an unexpected error (such as a CGI script crash)
* that prevents the request from being fulfilled.
*/
- public static final int HTTP_INTERNAL_ERROR = 500;
+ public static final int HTTP_INTERNAL_ERROR = 500;
/**
- * The server does not support the requested functionality.
+ * The server does not support the requested functionality.
* @since 1.3
*/
public static final int HTTP_NOT_IMPLEMENTED = 501;
@@ -294,8 +291,8 @@
/**
* This is a list of valid request methods, separated by "|" characters.
*/
- private static String valid_methods
- = "|GET|POST|HEAD|OPTIONS|PUT|DELETE|TRACE|";
+ private static String valid_methods =
+ "|GET|POST|HEAD|OPTIONS|PUT|DELETE|TRACE|";
// Instance Variables
@@ -312,7 +309,7 @@
/**
* The response message string received from the server.
*/
- protected String responseMessage = null;
+ protected String responseMessage;
/**
* If this instance should follow redirect requests.
@@ -324,7 +321,7 @@
* Used by getResponseCode()
and
* getResponseMessage()
.
*/
- private boolean gotResponseVals = false;
+ private boolean gotResponseVals;
/**
* Create an HttpURLConnection for the specified URL
@@ -335,16 +332,16 @@
{
super(url);
}
-
- /**
+
+ /**
* Closes the connection to the server.
*/
public abstract void disconnect();
- /**
+ /**
* Returns a boolean indicating whether or not this connection is going
* through a proxy
- *
+ *
* @return true if through a proxy, false otherwise
*/
public abstract boolean usingProxy();
@@ -370,7 +367,7 @@
}
/**
- * Returns a boolean indicating whether or not HTTP redirects will
+ * Returns a boolean indicating whether or not HTTP redirects will
* automatically be followed or not.
*
* @return true if redirects will be followed, false otherwise
@@ -383,16 +380,20 @@
/**
* Returns the value of this HttpURLConnection's instanceFollowRedirects
* field
+ *
+ * @return true if following redirects is enabled, false otherwise
*/
- public boolean getInstanceFollowRedirects ()
+ public boolean getInstanceFollowRedirects()
{
return instanceFollowRedirects;
}
/**
* Sets the value of this HttpURLConnection's instanceFollowRedirects field
+ *
+ * @param follow true to enable following redirects, false otherwise
*/
- public void setInstanceFollowRedirects (boolean follow)
+ public void setInstanceFollowRedirects(boolean follow)
{
instanceFollowRedirects = follow;
}
@@ -401,6 +402,8 @@
* Set the method for the URL request, one of:
* GET POST HEAD OPTIONS PUT DELETE TRACE are legal
*
+ * @param method the method to use
+ *
* @exception ProtocolException If the method cannot be reset or if the
* requested method isn't valid for HTTP
*/
@@ -414,7 +417,6 @@
this.method = method;
else
throw new ProtocolException("Invalid HTTP request method: " + method);
-
}
/**
@@ -439,7 +441,7 @@
*/
public int getResponseCode() throws IOException
{
- if (!gotResponseVals)
+ if (! gotResponseVals)
getResponseVals();
return responseCode;
}
@@ -455,7 +457,7 @@
*/
public String getResponseMessage() throws IOException
{
- if (!gotResponseVals)
+ if (! gotResponseVals)
getResponseVals();
return responseMessage;
}
@@ -464,9 +466,9 @@
{
// getHeaderField() will connect for us, but do it here first in
// order to pick up IOExceptions.
- if (!connected)
+ if (! connected)
connect();
-
+
gotResponseVals = true;
// If responseCode not yet explicitly set by subclass
@@ -474,7 +476,7 @@
{
// Response is the first header received from the connection.
String respField = getHeaderField(0);
-
+
if (respField == null || ! respField.startsWith("HTTP/"))
{
// Set to default values on failure.
@@ -483,7 +485,8 @@
return;
}
- int firstSpc, nextSpc;
+ int firstSpc;
+ int nextSpc;
firstSpc = respField.indexOf(' ');
nextSpc = respField.indexOf(' ', firstSpc + 1);
responseMessage = respField.substring(nextSpc + 1);
@@ -505,6 +508,8 @@
* Returns a permission object representing the permission necessary to make
* the connection represented by this object
*
+ * @return the permission necessary for this connection
+ *
* @exception IOException If an error occurs
*/
public Permission getPermission() throws IOException
@@ -514,9 +519,9 @@
int port = url.getPort();
if (port == -1)
port = 80;
-
+
host = host + ":" + port;
-
+
return new SocketPermission(host, "connect");
}
@@ -529,52 +534,56 @@
*
* @return An InputStream
for reading error data.
*/
- public InputStream getErrorStream ()
+ public InputStream getErrorStream()
{
- if (!connected)
- return(null);
-
+ if (! connected)
+ return (null);
+
int code;
- try
+ try
{
code = getResponseCode();
}
- catch(IOException e)
+ catch (IOException e)
{
code = -1;
}
-
+
if (code == -1)
- return(null);
-
- if (((code/100) != 4) || ((code/100) != 5))
- return(null);
-
+ return (null);
+
+ if (((code / 100) != 4) || ((code / 100) != 5))
+ return (null);
+
try
{
PushbackInputStream pbis = new PushbackInputStream(getInputStream());
-
+
int i = pbis.read();
if (i == -1)
- return(null);
-
+ return (null);
+
pbis.unread(i);
- return(pbis);
+ return (pbis);
}
- catch(IOException e)
+ catch (IOException e)
{
- return(null);
+ return (null);
}
}
/**
* Returns the value of the named field parsed as date
+ *
+ * @param key the key of the header field
+ * @param value the default value if the header field is not present
+ *
+ * @return the value of the header field
*/
- public long getHeaderFieldDate (String key, long value)
+ public long getHeaderFieldDate(String key, long value)
{
// FIXME: implement this correctly
// http://www.w3.org/Protocols/HTTP-NG/ng-notes.txt
-
- return super.getHeaderFieldDate (key, value);
+ return super.getHeaderFieldDate(key, value);
}
}
Index: java/net/InetSocketAddress.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/net/InetSocketAddress.java,v
retrieving revision 1.9
diff -u -r1.9 InetSocketAddress.java
--- java/net/InetSocketAddress.java 26 Nov 2003 15:55:00 -0000 1.9
+++ java/net/InetSocketAddress.java 8 Apr 2004 16:24:07 -0000
@@ -1,4 +1,4 @@
-/* InetSocketAddress.java --
+/* InetSocketAddress.java --
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -37,21 +37,21 @@
package java.net;
-/**
+
+/**
* InetSocketAddress instances represent socket addresses
* in the java.nio package. They encapsulate a InetAddress and
* a port number.
*
* @since 1.4
*/
-
public class InetSocketAddress extends SocketAddress
{
/**
* Compatible with JDK 1.4+
*/
private static final long serialVersionUID = 5076001401234631237L;
-
+
/**
* Name of host.
*/
@@ -66,10 +66,10 @@
* Port of host.
*/
private int port;
-
+
/**
* Constructs an InetSocketAddress instance.
- *
+ *
* @param addr Address of the socket
* @param port Port if the socket
*
@@ -79,34 +79,33 @@
throws IllegalArgumentException
{
if (port < 0 || port > 65535)
- throw new IllegalArgumentException ("Bad port number: " + port);
+ throw new IllegalArgumentException("Bad port number: " + port);
if (addr == null)
addr = InetAddress.ANY_IF;
-
+
this.addr = addr;
this.port = port;
- this.hostname = addr.getHostName ();
+ this.hostname = addr.getHostName();
}
/**
* Constructs an InetSocketAddress instance.
- *
+ *
* @param port Port if the socket
*
* @exception IllegalArgumentException If the port number is illegal
*/
- public InetSocketAddress(int port)
- throws IllegalArgumentException
+ public InetSocketAddress(int port) throws IllegalArgumentException
{
- this ((InetAddress) null, port);
+ this((InetAddress) null, port);
}
/**
* Constructs an InetSocketAddress instance.
*
- * @param addr Address of the socket
- * @param port Port if the socket
+ * @param hostname The hostname for the socket address
+ * @param port The port for the socket address
*
* @exception IllegalArgumentException If the port number is illegal
*/
@@ -114,49 +113,48 @@
throws IllegalArgumentException
{
if (hostname == null)
- throw new IllegalArgumentException ("Null host name value");
-
+ throw new IllegalArgumentException("Null host name value");
+
if (port < 0 || port > 65535)
- throw new IllegalArgumentException ("Bad port number: " + port);
+ throw new IllegalArgumentException("Bad port number: " + port);
this.port = port;
this.hostname = hostname;
try
{
- this.addr = InetAddress.getByName(hostname);
+ this.addr = InetAddress.getByName(hostname);
}
catch (Exception e) // UnknownHostException, SecurityException
{
- this.addr = null;
+ this.addr = null;
}
}
-
- /**
+
+ /**
* Test if obj is a InetSocketAddress
and
* has the same address and port
*
* @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.
// The hostname may differ.
-
if (obj instanceof InetSocketAddress)
{
- InetSocketAddress sa = (InetSocketAddress) obj;
-
- if (addr == null && sa.addr != null)
- return false;
- else if (addr == null && sa.addr == null)
- return hostname.equals (sa.hostname) && sa.port == port;
- else
- return addr.equals (sa.addr) && sa.port == port;
+ InetSocketAddress sa = (InetSocketAddress) obj;
+
+ if (addr == null && sa.addr != null)
+ return false;
+ else if (addr == null && sa.addr == null)
+ return hostname.equals(sa.hostname) && sa.port == port;
+ else
+ return addr.equals(sa.addr) && sa.port == port;
}
-
+
return false;
}
@@ -190,7 +188,7 @@
{
return port;
}
-
+
/**
* Returns the hashcode of the InetSocketAddress
*
@@ -210,7 +208,7 @@
{
return addr == null;
}
-
+
/**
* Returns the InetSocketAddress
as string
*
Index: java/net/MalformedURLException.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/net/MalformedURLException.java,v
retrieving revision 1.7
diff -u -r1.7 MalformedURLException.java
--- java/net/MalformedURLException.java 24 Feb 2002 04:25:16 -0000 1.7
+++ java/net/MalformedURLException.java 8 Apr 2004 16:24:07 -0000
@@ -39,6 +39,7 @@
import java.io.IOException;
+
/**
* This exception indicates that a URL passed to an object was not in a
* valid format.
Index: java/net/MulticastSocket.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/net/MulticastSocket.java,v
retrieving revision 1.23
diff -u -r1.23 MulticastSocket.java
--- java/net/MulticastSocket.java 12 Feb 2004 16:38:11 -0000 1.23
+++ java/net/MulticastSocket.java 8 Apr 2004 16:24:07 -0000
@@ -8,7 +8,7 @@
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
-
+
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@@ -41,21 +41,21 @@
import java.io.IOException;
import java.util.Enumeration;
+
/**
* Written using on-line Java Platform 1.2 API Specification, as well
* as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
* Status: Believed complete and correct.
*/
-
/**
* This class models a multicast UDP socket. A multicast address is a
- * class D internet address (one whose most significant bits are 1110).
+ * class D internet address (one whose most significant bits are 1110).
* A multicast group consists of a multicast address and a well known
* port number. All members of the group listening on that address and
* port will receive all the broadcasts to the group.
*
- * Please note that applets are not allowed to use multicast sockets
- *
+ * Please note that applets are not allowed to use multicast sockets
+ *
* Written using on-line Java Platform 1.2 API Specification, as well
* as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
* Status: Believed complete and correct.
@@ -111,10 +111,10 @@
if (address != null)
bind(address);
}
-
+
/**
* Returns the interface being used for multicast packets
- *
+ *
* @return The multicast interface
*
* @exception SocketException If an error occurs
@@ -131,7 +131,7 @@
* Returns the current value of the "Time to Live" option. This is the
* number of hops a packet can make before it "expires". This method id
* deprecated. Use getTimeToLive
instead.
- *
+ *
* @return The TTL value
*
* @exception IOException If an error occurs
@@ -153,8 +153,8 @@
/**
* Returns the current value of the "Time to Live" option. This is the
- * number of hops a packet can make before it "expires".
- *
+ * number of hops a packet can make before it "expires".
+ *
* @return The TTL value
*
* @exception IOException If an error occurs
@@ -189,12 +189,12 @@
/**
* Sets the local network interface used to send multicast messages
*
- * @param netIF The local network interface used to send multicast messages
- *
+ * @param netIf The local network interface used to send multicast messages
+ *
* @exception SocketException If an error occurs
- *
+ *
* @see MulticastSocket#getNetworkInterface()
- *
+ *
* @since 1.4
*/
public void setNetworkInterface(NetworkInterface netIf)
@@ -203,13 +203,13 @@
if (isClosed())
throw new SocketException("socket is closed");
- Enumeration e = netIf.getInetAddresses ();
+ Enumeration e = netIf.getInetAddresses();
- if (!e.hasMoreElements ())
+ if (! e.hasMoreElements())
throw new SocketException("no network devices found");
- InetAddress address = (InetAddress) e.nextElement ();
- getImpl().setOption (SocketOptions.IP_MULTICAST_IF, address);
+ InetAddress address = (InetAddress) e.nextElement();
+ getImpl().setOption(SocketOptions.IP_MULTICAST_IF, address);
}
/**
@@ -220,18 +220,17 @@
* @exception SocketException If an error occurs
*
* @see MulticastSocket#setNetworkInterface(NetworkInterface netIf)
- *
+ *
* @since 1.4
*/
- public NetworkInterface getNetworkInterface()
- throws SocketException
+ public NetworkInterface getNetworkInterface() throws SocketException
{
if (isClosed())
throw new SocketException("socket is closed");
InetAddress address =
- (InetAddress) getImpl().getOption (SocketOptions.IP_MULTICAST_IF);
- NetworkInterface netIf = NetworkInterface.getByInetAddress (address);
+ (InetAddress) getImpl().getOption(SocketOptions.IP_MULTICAST_IF);
+ NetworkInterface netIf = NetworkInterface.getByInetAddress(address);
return netIf;
}
@@ -239,7 +238,7 @@
/**
* Disable/Enable local loopback of multicast packets. The option is used by
* the platform's networking code as a hint for setting whether multicast
- * data will be looped back to the local socket.
+ * data will be looped back to the local socket.
*
* Because this option is a hint, applications that want to verify what
* loopback mode is set to should call #getLoopbackMode
@@ -255,12 +254,15 @@
if (isClosed())
throw new SocketException("socket is closed");
- getImpl().setOption (SocketOptions.IP_MULTICAST_LOOP, Boolean.valueOf(disable));
+ getImpl().setOption(SocketOptions.IP_MULTICAST_LOOP,
+ Boolean.valueOf(disable));
}
/**
- * Checks if local loopback mode is enabled or not
+ * Checks if local loopback mode is enabled
*
+ * @return true if loopback mode is enabled, false otherwise
+ *
* @exception SocketException If an error occurs
*
* @since 1.4
@@ -270,11 +272,11 @@
if (isClosed())
throw new SocketException("socket is closed");
- Object buf = getImpl().getOption (SocketOptions.IP_MULTICAST_LOOP);
+ Object buf = getImpl().getOption(SocketOptions.IP_MULTICAST_LOOP);
if (buf instanceof Boolean)
return ((Boolean) buf).booleanValue();
-
+
throw new SocketException("unexpected type");
}
@@ -303,12 +305,12 @@
/**
* Sets the "Time to Live" value for a socket. The value must be between
- * 1 and 255.
+ * 1 and 255.
*
* @param ttl The new TTL value
*
* @exception IOException If an error occurs
- *
+ *
* @since 1.2
*/
public void setTimeToLive(int ttl) throws IOException
@@ -323,10 +325,10 @@
}
/**
- * Joins the specified mulitcast group.
+ * Joins the specified multicast group.
+ *
+ * @param mcastaddr The address of the group to join
*
- * @param addr The address of the group to join
- *
* @exception IOException If an error occurs
* @exception SecurityException If a security manager exists and its
* checkMulticast method doesn't allow the operation
@@ -349,7 +351,7 @@
/**
* Leaves the specified multicast group
*
- * @param addr The address of the group to leave
+ * @param mcastaddr The address of the group to leave
*
* @exception IOException If an error occurs
* @exception SecurityException If a security manager exists and its
@@ -377,7 +379,7 @@
* @param netIf The local network interface to receive the multicast
* messages on or null to defer the interface set by #setInterface or
* #setNetworkInterface
- *
+ *
* @exception IOException If an error occurs
* @exception IllegalArgumentException If address type is not supported
* @exception SecurityException If a security manager exists and its
@@ -395,26 +397,26 @@
throw new SocketException("socket is closed");
if (! (mcastaddr instanceof InetSocketAddress))
- throw new IllegalArgumentException ("SocketAddress type not supported");
+ throw new IllegalArgumentException("SocketAddress type not supported");
InetSocketAddress tmp = (InetSocketAddress) mcastaddr;
-
- if (! tmp.getAddress ().isMulticastAddress ())
- throw new IOException ("Not a Multicast address");
- SecurityManager s = System.getSecurityManager ();
+ if (! tmp.getAddress().isMulticastAddress())
+ throw new IOException("Not a Multicast address");
+
+ SecurityManager s = System.getSecurityManager();
if (s != null)
- s.checkMulticast (tmp.getAddress ());
+ s.checkMulticast(tmp.getAddress());
- getImpl().joinGroup (mcastaddr, netIf);
+ getImpl().joinGroup(mcastaddr, netIf);
}
-
+
/**
* Leaves the specified mulitcast group on a specified interface.
*
* @param mcastaddr The multicast address to leave
* @param netIf The local networki interface or null to defer to the
- * interface set by setInterface or setNetworkInterface
+ * interface set by setInterface or setNetworkInterface
*
* @exception IOException If an error occurs
* @exception IllegalArgumentException If address type is not supported
@@ -433,17 +435,17 @@
throw new SocketException("socket is closed");
InetSocketAddress tmp = (InetSocketAddress) mcastaddr;
-
- if (! tmp.getAddress ().isMulticastAddress ())
- throw new IOException ("Not a Multicast address");
- SecurityManager s = System.getSecurityManager ();
+ if (! tmp.getAddress().isMulticastAddress())
+ throw new IOException("Not a Multicast address");
+
+ SecurityManager s = System.getSecurityManager();
if (s != null)
- s.checkMulticast (tmp.getAddress ());
+ s.checkMulticast(tmp.getAddress());
- getImpl().leaveGroup (mcastaddr, netIf);
+ getImpl().leaveGroup(mcastaddr, netIf);
}
-
+
/**
* Sends a packet of data to a multicast address with a TTL that is
* different from the default TTL on this socket. The default TTL for
@@ -458,7 +460,8 @@
*
* @deprecated
*/
- public synchronized void send(DatagramPacket p, byte ttl) throws IOException
+ public synchronized void send(DatagramPacket packet, byte ttl)
+ throws IOException
{
if (isClosed())
throw new SocketException("socket is closed");
@@ -466,18 +469,18 @@
SecurityManager s = System.getSecurityManager();
if (s != null)
{
- InetAddress addr = p.getAddress();
- if (addr.isMulticastAddress())
- s.checkPermission (new SocketPermission
- (addr.getHostName () + p.getPort (),
- "accept,connect"));
- else
- s.checkConnect(addr.getHostAddress(), p.getPort());
+ InetAddress addr = packet.getAddress();
+ if (addr.isMulticastAddress())
+ s.checkPermission(new SocketPermission(addr.getHostName()
+ + packet.getPort(),
+ "accept,connect"));
+ else
+ s.checkConnect(addr.getHostAddress(), packet.getPort());
}
int oldttl = getImpl().getTimeToLive();
getImpl().setTimeToLive(((int) ttl) & 0xFF);
- getImpl().send(p);
+ getImpl().send(packet);
getImpl().setTimeToLive(oldttl);
}
-} // class MulticastSocket
+}
Index: java/net/NetPermission.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/net/NetPermission.java,v
retrieving revision 1.9
diff -u -r1.9 NetPermission.java
--- java/net/NetPermission.java 25 May 2003 18:03:51 -0000 1.9
+++ java/net/NetPermission.java 8 Apr 2004 16:24:07 -0000
@@ -39,21 +39,22 @@
import java.security.BasicPermission;
+
/**
* This class is used to model miscellaneous network permissions. It is
- * a subclass of BasicPermission
. This means that it models a
- * "boolean" permission. One that you either have or do not have. Thus
- * there is no permitted action list associated with this object.
+ * a subclass of BasicPermission
. This means that it models a
+ * "boolean" permission. One that you either have or do not have. Thus
+ * there is no permitted action list associated with this object.
*
* The following permission names are defined for this class:
- *
+ *
*
NetPermission
with the
- * specified name and perms. Note that the perms field is irrelevant and is
+ * Initializes a new instance of NetPermission
with the
+ * specified name and perms. Note that the perms field is irrelevant and is
* ignored. This constructor should never need to be used.
*
* @param name The name of this permission
Index: java/net/NetworkInterface.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/net/NetworkInterface.java,v
retrieving revision 1.6
diff -u -r1.6 NetworkInterface.java
--- java/net/NetworkInterface.java 2 Oct 2003 18:49:59 -0000 1.6
+++ java/net/NetworkInterface.java 8 Apr 2004 16:24:07 -0000
@@ -7,7 +7,7 @@
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
-
+
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@@ -41,6 +41,7 @@
import java.util.Enumeration;
import java.util.Vector;
+
/**
* This class models a network interface on the host computer. A network
* interface contains a name (typically associated with a specific
@@ -54,25 +55,22 @@
public final class NetworkInterface
{
static
- {
- if (Configuration.INIT_LOAD_LIBRARY)
- {
- System.loadLibrary ("javanet");
- }
- }
+ {
+ if (Configuration.INIT_LOAD_LIBRARY)
+ System.loadLibrary("javanet");
+ }
private String name;
-
private Vector inetAddresses;
- private NetworkInterface (String name, InetAddress address)
+ private NetworkInterface(String name, InetAddress address)
{
this.name = name;
- this.inetAddresses = new Vector (1, 1);
- this.inetAddresses.add (address);
+ this.inetAddresses = new Vector(1, 1);
+ this.inetAddresses.add(address);
}
- private native static Vector getRealNetworkInterfaces ()
+ private static native Vector getRealNetworkInterfaces()
throws SocketException;
/**
@@ -80,45 +78,45 @@
*
* @return The name of the interface.
*/
- public String getName ()
+ public String getName()
{
return name;
}
/**
* Returns all available addresses of the network interface
- *
+ *
* If a @see SecurityManager is available all addresses are checked
* with @see SecurityManager::checkConnect() if they are available.
- * Only InetAddresses
are returned where the security manager
+ * Only InetAddresses
are returned where the security manager
* doesn't throw an exception.
- *
+ *
* @return An enumeration of all addresses.
*/
- public Enumeration getInetAddresses ()
+ public Enumeration getInetAddresses()
{
- SecurityManager s = System.getSecurityManager ();
+ SecurityManager s = System.getSecurityManager();
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 ();
- addresses.hasMoreElements (); )
+ for (Enumeration addresses = inetAddresses.elements();
+ addresses.hasMoreElements();)
{
- InetAddress addr = (InetAddress) addresses.nextElement ();
+ InetAddress addr = (InetAddress) addresses.nextElement();
try
{
- s.checkConnect (addr.getHostAddress (), 58000);
- tmpInetAddresses.add (addr);
+ s.checkConnect(addr.getHostAddress(), 58000);
+ tmpInetAddresses.add(addr);
}
catch (SecurityException e)
{
}
- }
+ }
- return tmpInetAddresses.elements ();
+ return tmpInetAddresses.elements();
}
/**
@@ -126,7 +124,7 @@
*
* @return The display name of the interface
*/
- public String getDisplayName ()
+ public String getDisplayName()
{
return name;
}
@@ -139,21 +137,20 @@
* @exception SocketException If an error occurs
* @exception NullPointerException If the specified name is null
*/
- public static NetworkInterface getByName (String name)
+ public static NetworkInterface getByName(String name)
throws SocketException
{
- Vector networkInterfaces = getRealNetworkInterfaces ();
+ Vector networkInterfaces = getRealNetworkInterfaces();
- for (Enumeration e = networkInterfaces.elements ();
- e.hasMoreElements (); )
+ for (Enumeration e = networkInterfaces.elements(); e.hasMoreElements();)
{
- NetworkInterface tmp = (NetworkInterface) e.nextElement ();
-
- if (name.equals (tmp.getName ()))
- return tmp;
+ NetworkInterface tmp = (NetworkInterface) e.nextElement();
+
+ if (name.equals(tmp.getName()))
+ 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 @@
* @exception SocketException If an error occurs
* @exception NullPointerException If the specified addess is null
*/
- public static NetworkInterface getByInetAddress (InetAddress addr)
+ public static NetworkInterface getByInetAddress(InetAddress addr)
throws SocketException
{
- Vector networkInterfaces = getRealNetworkInterfaces ();
-
- for (Enumeration interfaces = networkInterfaces.elements ();
- interfaces.hasMoreElements (); )
+ Vector networkInterfaces = getRealNetworkInterfaces();
+
+ for (Enumeration interfaces = networkInterfaces.elements();
+ interfaces.hasMoreElements();)
{
- NetworkInterface tmp = (NetworkInterface) interfaces.nextElement ();
-
- for (Enumeration addresses = tmp.inetAddresses.elements ();
- addresses.hasMoreElements (); )
- {
- if (addr.equals ((InetAddress) addresses.nextElement ()))
- return tmp;
- }
+ NetworkInterface tmp = (NetworkInterface) interfaces.nextElement();
+
+ for (Enumeration addresses = tmp.inetAddresses.elements();
+ addresses.hasMoreElements();)
+ {
+ if (addr.equals((InetAddress) addresses.nextElement()))
+ return tmp;
+ }
}
- throw new SocketException (
- "no network interface is bound to such an IP address");
+ throw new SocketException("no network interface is bound to such an IP address");
}
/**
@@ -191,8 +187,7 @@
*
* @exception SocketException If an error occurs
*/
- public static Enumeration getNetworkInterfaces ()
- throws SocketException
+ public static Enumeration getNetworkInterfaces() throws SocketException
{
Vector networkInterfaces = getRealNetworkInterfaces();
@@ -206,44 +201,43 @@
* Checks if the current instance is equal to obj
*
* @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;
-
+
NetworkInterface tmp = (NetworkInterface) obj;
- return (name.equals (tmp.name)
- && inetAddresses.equals (tmp.inetAddresses));
+ return (name.equals(tmp.name) && inetAddresses.equals(tmp.inetAddresses));
}
/**
* Returns the hashcode of the current instance
*/
- public int hashCode ()
+ public int hashCode()
{
// FIXME: hash correctly
- return name.hashCode () + inetAddresses.hashCode ();
+ return name.hashCode() + inetAddresses.hashCode();
}
/**
* Returns a string representation of the interface
*/
- public String toString ()
+ public String toString()
{
// FIXME: check if this is correct
String result;
- String separator = System.getProperty ("line.separator");
+ String separator = System.getProperty("line.separator");
- result = "name: " + getDisplayName () + " (" + getName () +
- ") addresses:" + separator;
+ result =
+ "name: " + getDisplayName() + " (" + getName() + ") addresses:"
+ + separator;
- for (Enumeration e = inetAddresses.elements ();
- e.hasMoreElements (); )
+ for (Enumeration e = inetAddresses.elements(); e.hasMoreElements();)
{
- InetAddress address = (InetAddress) e.nextElement ();
- result += address.toString () + ";" + separator;
+ InetAddress address = (InetAddress) e.nextElement();
+ result += address.toString() + ";" + separator;
}
return result;
Index: java/net/NoRouteToHostException.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/net/NoRouteToHostException.java,v
retrieving revision 1.7
diff -u -r1.7 NoRouteToHostException.java
--- java/net/NoRouteToHostException.java 24 Feb 2002 04:25:16 -0000 1.7
+++ java/net/NoRouteToHostException.java 8 Apr 2004 16:24:07 -0000
@@ -35,8 +35,8 @@
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-
package java.net;
+
/**
* This exception indicates that there is no TCP/IP route to the requested
Index: java/net/PasswordAuthentication.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/net/PasswordAuthentication.java,v
retrieving revision 1.8
diff -u -r1.8 PasswordAuthentication.java
--- java/net/PasswordAuthentication.java 25 May 2003 18:03:51 -0000 1.8
+++ java/net/PasswordAuthentication.java 8 Apr 2004 16:24:07 -0000
@@ -7,7 +7,7 @@
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
-
+
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@@ -37,6 +37,7 @@
package java.net;
+
/**
* This class serves a container for username/password pairs.
*
@@ -50,7 +51,7 @@
*/
/**
- * The username
+ * The username
*/
private String username;
@@ -66,7 +67,7 @@
*/
/**
- * Creates a new PasswordAuthentication
object from the
+ * Creates a new PasswordAuthentication
object from the
* specified username and password.
*
* @param username The username for this object
@@ -91,9 +92,9 @@
*/
public String getUserName()
{
- return(username);
+ return (username);
}
-
+
/**
* Returns the password associated with this object
*
@@ -101,8 +102,6 @@
*/
public char[] getPassword()
{
- return(password);
+ return (password);
}
-
} // class PasswordAuthentication
-
Index: java/net/PortUnreachableException.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/net/PortUnreachableException.java,v
retrieving revision 1.1
diff -u -r1.1 PortUnreachableException.java
--- java/net/PortUnreachableException.java 24 Feb 2002 04:25:16 -0000 1.1
+++ java/net/PortUnreachableException.java 8 Apr 2004 16:24:07 -0000
@@ -37,6 +37,7 @@
package java.net;
+
/**
* This exception signals that an ICMP port unreachable datagram has been
* received.
@@ -69,4 +70,3 @@
super(message);
}
} // class PortUnreachableException
-
Index: java/net/ProtocolException.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/net/ProtocolException.java,v
retrieving revision 1.8
diff -u -r1.8 ProtocolException.java
--- java/net/ProtocolException.java 24 Feb 2002 04:25:16 -0000 1.8
+++ java/net/ProtocolException.java 8 Apr 2004 16:24:07 -0000
@@ -39,6 +39,7 @@
import java.io.IOException;
+
/**
* This exception indicates that some sort of low level protocol
* exception occurred. Look in the descriptive message (if any) for
Index: java/net/ServerSocket.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/net/ServerSocket.java,v
retrieving revision 1.35
diff -u -r1.35 ServerSocket.java
--- java/net/ServerSocket.java 21 Mar 2004 10:42:27 -0000 1.35
+++ java/net/ServerSocket.java 8 Apr 2004 16:24:07 -0000
@@ -8,7 +8,7 @@
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
-
+
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@@ -36,7 +36,6 @@
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-
package java.net;
import gnu.java.net.PlainSocketImpl;
@@ -44,6 +43,7 @@
import java.nio.channels.IllegalBlockingModeException;
import java.nio.channels.ServerSocketChannel;
+
/* Written using on-line Java Platform 1.2 API Specification.
* Status: I believe all methods are implemented.
*/
@@ -55,7 +55,7 @@
* server sockets are ready to communicate with one another utilizing
* whatever application layer protocol they desire.
*
- * As with the Socket
class, most instance methods of this class
+ * As with the Socket
class, most instance methods of this class
* simply redirect their calls to an implementation class.
*
* @author Aaron M. Renn (address@hidden)
@@ -78,34 +78,36 @@
* True if socket is bound.
*/
private boolean bound;
-
+
/*
* This constructor is only used by java.nio.
*/
+
// FIXME: Workaround a bug in gcj.
//ServerSocket (PlainSocketImpl impl) throws IOException
- ServerSocket (SocketImpl impl) throws IOException
+ ServerSocket(SocketImpl impl) throws IOException
{
if (impl == null)
throw new NullPointerException("impl may not be null");
this.impl = impl;
- this.impl.create (true);
+ this.impl.create(true);
}
/*
* This method is only used by java.nio.
*/
+
// FIXME: Workaround a bug in gcj.
//PlainSocketImpl getImpl()
SocketImpl getImpl()
{
return impl;
}
-
+
/**
* Constructor that simply sets the implementation.
- *
+ *
* @exception IOException If an error occurs
*
* @specnote This constructor is public since JDK 1.4
@@ -126,13 +128,12 @@
* connection queue on this socket will be set to 50.
*
* @param port The port number to bind to
- *
+ *
* @exception IOException If an error occurs
* @exception SecurityException If a security manager exists and its
* checkListen method doesn't allow the operation
*/
- public ServerSocket (int port)
- throws IOException
+ public ServerSocket(int port) throws IOException
{
this(port, 50);
}
@@ -150,8 +151,7 @@
* @exception SecurityException If a security manager exists and its
* checkListen method doesn't allow the operation
*/
- public ServerSocket (int port, int backlog)
- throws IOException
+ public ServerSocket(int port, int backlog) throws IOException
{
this(port, backlog, null);
}
@@ -173,13 +173,13 @@
*
* @since 1.1
*/
- public ServerSocket (int port, int backlog, InetAddress bindAddr)
+ public ServerSocket(int port, int backlog, InetAddress bindAddr)
throws IOException
{
this();
// bind/listen socket
- bind (new InetSocketAddress (bindAddr, port), backlog);
+ bind(new InetSocketAddress(bindAddr, port), backlog);
}
/**
@@ -191,21 +191,20 @@
* @exception IllegalArgumentException If address type is not supported
* @exception SecurityException If a security manager exists and its
* checkListen method doesn't allow the operation
- *
+ *
* @since 1.4
*/
- public void bind (SocketAddress endpoint)
- throws IOException
+ public void bind(SocketAddress endpoint) throws IOException
{
- bind (endpoint, 50);
+ bind(endpoint, 50);
}
-
+
/**
* Binds the server socket to a specified socket address
*
* @param endpoint The socket address to bind to
* @param backlog The length of the pending connection queue
- *
+ *
* @exception IOException If an error occurs
* @exception IllegalArgumentException If address type is not supported
* @exception SecurityException If a security manager exists and its
@@ -213,26 +212,27 @@
*
* @since 1.4
*/
- public void bind (SocketAddress endpoint, int backlog) throws IOException
+ public void bind(SocketAddress endpoint, int backlog)
+ throws IOException
{
if (isClosed())
throw new SocketException("ServerSocket is closed");
-
+
if (! (endpoint instanceof InetSocketAddress))
- throw new IllegalArgumentException ("Address type not supported");
+ throw new IllegalArgumentException("Address type not supported");
InetSocketAddress tmp = (InetSocketAddress) endpoint;
- SecurityManager s = System.getSecurityManager ();
+ SecurityManager s = System.getSecurityManager();
if (s != null)
- s.checkListen (tmp.getPort ());
+ s.checkListen(tmp.getPort());
InetAddress addr = tmp.getAddress();
-
+
// Initialize addr with 0.0.0.0.
if (addr == null)
addr = InetAddress.ANY_IF;
-
+
try
{
impl.bind(addr, tmp.getPort());
@@ -241,21 +241,21 @@
}
catch (IOException exception)
{
- close();
- throw exception;
+ close();
+ throw exception;
}
catch (RuntimeException exception)
{
- close();
- throw exception;
+ close();
+ throw exception;
}
catch (Error error)
{
- close();
- throw error;
+ close();
+ throw error;
}
}
-
+
/**
* This method returns the local address to which this socket is bound
*
@@ -263,17 +263,17 @@
*/
public InetAddress getInetAddress()
{
- if (!isBound())
+ if (! isBound())
return null;
-
+
try
{
- return (InetAddress) impl.getOption (SocketOptions.SO_BINDADDR);
+ return (InetAddress) impl.getOption(SocketOptions.SO_BINDADDR);
}
catch (SocketException e)
{
- // This never happens as we are bound.
- return null;
+ // This never happens as we are bound.
+ return null;
}
}
@@ -284,30 +284,34 @@
*/
public int getLocalPort()
{
- if (!isBound())
+ if (! isBound())
return -1;
-
+
return impl.getLocalPort();
}
/**
* Returns the local socket address
*
+ * @return the local socket address, null if not bound
+ *
* @since 1.4
*/
public SocketAddress getLocalSocketAddress()
{
- if (!isBound())
+ if (! isBound())
return null;
-
+
return new InetSocketAddress(getInetAddress(), getLocalPort());
}
/**
- * Accepts a new connection and returns a connected Socket
- * instance representing that connection. This method will block until a
+ * Accepts a new connection and returns a connected Socket
+ * instance representing that connection. This method will block until a
* connection is available.
*
+ * @return socket object for the just accepted connection
+ *
* @exception IOException If an error occurs
* @exception SecurityException If a security manager exists and its
* checkListen method doesn't allow the operation
@@ -316,17 +320,17 @@
* @exception SocketTimeoutException If a timeout was previously set with
* setSoTimeout and the timeout has been reached
*/
- public Socket accept () throws IOException
+ public Socket accept() throws IOException
{
- SecurityManager sm = System.getSecurityManager ();
+ SecurityManager sm = System.getSecurityManager();
if (sm != null)
- sm.checkListen (impl.getLocalPort ());
+ sm.checkListen(impl.getLocalPort());
Socket socket = new Socket();
-
+
try
{
- implAccept(socket);
+ implAccept(socket);
}
catch (IOException e)
{
@@ -337,15 +341,15 @@
catch (IOException e2)
{
}
-
+
throw e;
}
-
+
return socket;
}
/**
- * This protected method is used to help subclasses override
+ * This protected method is used to help subclasses override
* ServerSocket.accept()
. The passed in socket will be
* connected when this method returns.
*
@@ -357,21 +361,19 @@
*
* @since 1.1
*/
- protected final void implAccept (Socket socket)
- throws IOException
+ protected final void implAccept(Socket socket) throws IOException
{
if (isClosed())
throw new SocketException("ServerSocket is closed");
-
+
// The Sun spec says that if we have an associated channel and
// it is in non-blocking mode, we throw an IllegalBlockingModeException.
// However, in our implementation if the channel itself initiated this
// operation, then we must honor it regardless of its blocking mode.
- if (getChannel() != null
- && !getChannel().isBlocking ()
- && !((PlainSocketImpl) getImpl()).isInChannelOperation())
- throw new IllegalBlockingModeException ();
-
+ if (getChannel() != null && ! getChannel().isBlocking()
+ && ! ((PlainSocketImpl) getImpl()).isInChannelOperation())
+ throw new IllegalBlockingModeException();
+
impl.accept(socket.getImpl());
}
@@ -380,11 +382,11 @@
*
* @exception IOException If an error occurs
*/
- public void close () throws IOException
+ public void close() throws IOException
{
if (isClosed())
return;
-
+
impl.close();
impl = null;
bound = false;
@@ -399,6 +401,8 @@
*
* The socket only has a ServerSocketChannel if its created
* by ServerSocketChannel.open.
+ *
+ * @return the associated socket channel, null if none exists
*
* @since 1.4
*/
@@ -409,6 +413,8 @@
/**
* Returns true when the socket is bound, otherwise false
+ *
+ * @return true if socket is bound, false otherwise
*
* @since 1.4
*/
@@ -419,6 +425,8 @@
/**
* Returns true if the socket is closed, otherwise false
+ *
+ * @return true if socket is closed, false otherwise
*
* @since 1.4
*/
@@ -429,7 +437,7 @@
/**
* Sets the value of SO_TIMEOUT. A value of 0 implies that SO_TIMEOUT is
- * disabled (ie, operations never time out). This is the number of
+ * disabled (ie, operations never time out). This is the number of
* milliseconds a socket operation can block before an
* InterruptedIOException is thrown.
*
@@ -439,11 +447,11 @@
*
* @since 1.1
*/
- public void setSoTimeout (int timeout) throws SocketException
+ public void setSoTimeout(int timeout) throws SocketException
{
if (isClosed())
throw new SocketException("ServerSocket is closed");
-
+
if (timeout < 0)
throw new IllegalArgumentException("SO_TIMEOUT value must be >= 0");
@@ -462,135 +470,135 @@
*
* @since 1.1
*/
- public int getSoTimeout () throws IOException
+ public int getSoTimeout() throws IOException
{
if (isClosed())
throw new SocketException("ServerSocket is closed");
-
+
Object timeout = impl.getOption(SocketOptions.SO_TIMEOUT);
- if (!(timeout instanceof Integer))
+ if (! (timeout instanceof Integer))
throw new IOException("Internal Error");
- return ((Integer)timeout).intValue();
+ return ((Integer) timeout).intValue();
}
/**
* Enables/Disables the SO_REUSEADDR option
+ *
+ * @param on true if SO_REUSEADDR should be enabled, false otherwise
*
* @exception SocketException If an error occurs
- *
+ *
* @since 1.4
*/
- public void setReuseAddress (boolean on)
- throws SocketException
+ public void setReuseAddress(boolean on) throws SocketException
{
if (isClosed())
throw new SocketException("ServerSocket is closed");
-
- impl.setOption (SocketOptions.SO_REUSEADDR, Boolean.valueOf(on));
+
+ impl.setOption(SocketOptions.SO_REUSEADDR, Boolean.valueOf(on));
}
/**
* Checks if the SO_REUSEADDR option is enabled
- *
+ *
+ * @return true if SO_REUSEADDR is set, false otherwise
+ *
* @exception SocketException If an error occurs
- *
+ *
* @since 1.4
*/
- public boolean getReuseAddress()
- throws SocketException
+ public boolean getReuseAddress() throws SocketException
{
if (isClosed())
throw new SocketException("ServerSocket is closed");
-
- Object reuseaddr = impl.getOption (SocketOptions.SO_REUSEADDR);
- if (!(reuseaddr instanceof Boolean))
- throw new SocketException ("Internal Error");
-
- return ((Boolean) reuseaddr).booleanValue ();
+ Object reuseaddr = impl.getOption(SocketOptions.SO_REUSEADDR);
+
+ if (! (reuseaddr instanceof Boolean))
+ throw new SocketException("Internal Error");
+
+ return ((Boolean) reuseaddr).booleanValue();
}
/**
* This method sets the value for the system level socket option
* SO_RCVBUF to the specified value. Note that valid values for this
* option are specific to a given operating system.
- *
+ *
* @param size The new receive buffer size.
- *
+ *
* @exception SocketException If an error occurs or Socket is not connected
* @exception IllegalArgumentException If size is 0 or negative
*
* @since 1.4
*/
- public void setReceiveBufferSize (int size)
- throws SocketException
+ public void setReceiveBufferSize(int size) throws SocketException
{
if (isClosed())
throw new SocketException("ServerSocket is closed");
-
+
if (size <= 0)
- throw new IllegalArgumentException ("SO_RCVBUF value must be > 0");
+ throw new IllegalArgumentException("SO_RCVBUF value must be > 0");
- impl.setOption (SocketOptions.SO_RCVBUF, new Integer (size));
+ impl.setOption(SocketOptions.SO_RCVBUF, new Integer(size));
}
/**
* This method returns the value of the system level socket option
* SO_RCVBUF, which is used by the operating system to tune buffer
* sizes for data transfers.
- *
+ *
* @return The receive buffer size.
- *
+ *
* @exception SocketException If an error occurs or Socket is not connected
- *
+ *
* @since 1.4
*/
- public int getReceiveBufferSize ()
- throws SocketException
+ public int getReceiveBufferSize() throws SocketException
{
if (isClosed())
throw new SocketException("ServerSocket is closed");
-
- Object buf = impl.getOption (SocketOptions.SO_RCVBUF);
- if (!(buf instanceof Integer))
- throw new SocketException ("Internal Error: Unexpected type");
-
- return ((Integer) buf).intValue ();
+ Object buf = impl.getOption(SocketOptions.SO_RCVBUF);
+
+ if (! (buf instanceof Integer))
+ throw new SocketException("Internal Error: Unexpected type");
+
+ return ((Integer) buf).intValue();
}
/**
- * Returns the value of this socket as a String
.
+ * Returns the value of this socket as a String
.
*
* @return This socket represented as a String
.
*/
- public String toString ()
+ public String toString()
{
- if (!isBound())
+ if (! isBound())
return "ServerSocket[unbound]";
-
- return ("ServerSocket[addr=" + getInetAddress()
- + ",port=" + impl.getPort()
- + ",localport=" + impl.getLocalPort()
- + "]");
+
+ return ("ServerSocket[addr=" + getInetAddress() + ",port="
+ + impl.getPort() + ",localport=" + impl.getLocalPort() + "]");
}
/**
- * Sets the SocketImplFactory
for all
+ * Sets the SocketImplFactory
for all
* ServerSocket
's. This may only be done
* once per virtual machine. Subsequent attempts will generate an
* exception. Note that a SecurityManager
check is made prior
* to setting the factory. If insufficient privileges exist to set the
* factory, an exception will be thrown
*
+ * @param fac the factory to set
+ *
* @exception SecurityException If this operation is not allowed by the
* SecurityManager
.
* @exception SocketException If the factory object is already defined
* @exception IOException If any other error occurs
*/
- public static synchronized void setSocketFactory (SocketImplFactory fac)
+ public static synchronized void setSocketFactory(SocketImplFactory fac)
throws IOException
{
factory = fac;
Index: java/net/Socket.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/net/Socket.java,v
retrieving revision 1.42
diff -u -r1.42 Socket.java
--- java/net/Socket.java 12 Feb 2004 16:38:11 -0000 1.42
+++ java/net/Socket.java 8 Apr 2004 16:24:07 -0000
@@ -8,7 +8,7 @@
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
-
+
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@@ -36,15 +36,15 @@
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-
package java.net;
import gnu.java.net.PlainSocketImpl;
-import java.io.InputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
-import java.nio.channels.SocketChannel;
import java.nio.channels.IllegalBlockingModeException;
+import java.nio.channels.SocketChannel;
+
/* Written using on-line Java Platform 1.2 API Specification.
* Status: I believe all methods are implemented.
@@ -56,11 +56,11 @@
*
* This class does not actually do any work. Instead, it redirects all of
* its calls to a socket implementation object which implements the
- * SocketImpl
interface. The implementation class is
- * instantiated by factory class that implements the
+ * SocketImpl
interface. The implementation class is
+ * instantiated by factory class that implements the
* SocketImplFactory interface
. A default
* factory is provided, however the factory may be set by a call to
- * the setSocketImplFactory
method. Note that this may only be
+ * the setSocketImplFactory
method. Note that this may only be
* done once per virtual machine. If a subsequent attempt is made to set the
* factory, a SocketException
will be thrown.
*
@@ -81,7 +81,8 @@
private SocketImpl impl;
/**
- * True if socket implementation was created by calling their create() method.
+ * True if socket implementation was created by calling their
+ * create() method.
*/
private boolean implCreated;
@@ -101,14 +102,14 @@
private boolean outputShutdown;
/**
- * Initializes a new instance of Socket
object without
- * connecting to a remote host. This useful for subclasses of socket that
+ * Initializes a new instance of Socket
object without
+ * connecting to a remote host. This useful for subclasses of socket that
* might want this behavior.
*
* @specnote This constructor is public since JDK 1.4
* @since 1.1
*/
- public Socket ()
+ public Socket()
{
if (factory != null)
impl = factory.createSocketImpl();
@@ -119,7 +120,7 @@
/**
* Initializes a new instance of Socket
object without
* connecting to a remote host. This is useful for subclasses of socket
- * that might want this behavior.
+ * that might want this behavior.
*
* Additionally, this socket will be created using the supplied
* implementation class instead the default class or one returned by a
@@ -133,7 +134,7 @@
*
* @since 1.1
*/
- protected Socket (SocketImpl impl) throws SocketException
+ protected Socket(SocketImpl impl) throws SocketException
{
if (impl == null)
this.impl = new PlainSocketImpl();
@@ -142,7 +143,7 @@
}
/**
- * Initializes a new instance of Socket
and connects to the
+ * Initializes a new instance of Socket
and connects to the
* hostname and port specified as arguments.
*
* @param host The name of the host to connect to
@@ -154,14 +155,14 @@
* @exception SecurityException If a security manager exists and its
* checkConnect method doesn't allow the operation
*/
- public Socket (String host, int port)
+ public Socket(String host, int port)
throws UnknownHostException, IOException
{
this(InetAddress.getByName(host), port, null, 0, true);
}
/**
- * Initializes a new instance of Socket
and connects to the
+ * Initializes a new instance of Socket
and connects to the
* address and port number specified as arguments.
*
* @param address The address to connect to
@@ -171,15 +172,14 @@
* @exception SecurityException If a security manager exists and its
* checkConnect method doesn't allow the operation
*/
- public Socket (InetAddress address, int port)
- throws IOException
+ public Socket(InetAddress address, int port) throws IOException
{
this(address, port, null, 0, true);
}
/**
- * Initializes a new instance of Socket
that connects to the
- * named host on the specified port and binds to the specified local address
+ * Initializes a new instance of Socket
that connects to the
+ * named host on the specified port and binds to the specified local address
* and port.
*
* @param host The name of the remote host to connect to.
@@ -194,15 +194,15 @@
*
* @since 1.1
*/
- public Socket (String host, int port,
- InetAddress localAddr, int localPort) throws IOException
+ public Socket(String host, int port, InetAddress localAddr, int localPort)
+ throws IOException
{
this(InetAddress.getByName(host), port, localAddr, localPort, true);
}
/**
- * Initializes a new instance of Socket
and connects to the
- * address and port number specified as arguments, plus binds to the
+ * Initializes a new instance of Socket
and connects to the
+ * address and port number specified as arguments, plus binds to the
* specified local address and port.
*
* @param address The remote address to connect to
@@ -216,16 +216,16 @@
*
* @since 1.1
*/
- public Socket (InetAddress address, int port,
- InetAddress localAddr, int localPort) throws IOException
+ public Socket(InetAddress address, int port, InetAddress localAddr,
+ int localPort) throws IOException
{
this(address, port, localAddr, localPort, true);
}
/**
- * Initializes a new instance of Socket
and connects to the
- * hostname and port specified as arguments. If the stream argument is set
- * to true
, then a stream socket is created. If it is
+ * Initializes a new instance of Socket
and connects to the
+ * hostname and port specified as arguments. If the stream argument is set
+ * to true
, then a stream socket is created. If it is
* false
, a datagram socket is created.
*
* @param host The name of the host to connect to
@@ -240,20 +240,21 @@
* @deprecated Use the DatagramSocket
class to create
* datagram oriented sockets.
*/
- public Socket (String host, int port, boolean stream) throws IOException
+ public Socket(String host, int port, boolean stream)
+ throws IOException
{
this(InetAddress.getByName(host), port, null, 0, stream);
}
/**
- * Initializes a new instance of Socket
and connects to the
- * address and port number specified as arguments. If the stream param is
- * true
, a stream socket will be created, otherwise a datagram
+ * Initializes a new instance of Socket
and connects to the
+ * address and port number specified as arguments. If the stream param is
+ * true
, a stream socket will be created, otherwise a datagram
* socket is created.
*
* @param host The address to connect to
* @param port The port number to connect to
- * @param stream true
to create a stream socket,
+ * @param stream true
to create a stream socket,
* false
to create a datagram socket.
*
* @exception IOException If an error occurs
@@ -263,7 +264,8 @@
* @deprecated Use the DatagramSocket
class to create
* datagram oriented sockets.
*/
- public Socket (InetAddress host, int port, boolean stream) throws IOException
+ public Socket(InetAddress host, int port, boolean stream)
+ throws IOException
{
this(host, port, null, 0, stream);
}
@@ -296,11 +298,11 @@
// bind socket
SocketAddress bindaddr =
- laddr == null ? null : new InetSocketAddress (laddr, lport);
- bind (bindaddr);
-
+ laddr == null ? null : new InetSocketAddress(laddr, lport);
+ bind(bindaddr);
+
// connect socket
- connect (new InetSocketAddress (raddr, rport));
+ connect(new InetSocketAddress(raddr, rport));
// FIXME: JCL p. 1586 says if localPort is unspecified, bind to any port,
// i.e. '0' and if localAddr is unspecified, use getLocalAddress() as
@@ -308,12 +310,11 @@
}
// This has to be accessible from java.net.ServerSocket.
- SocketImpl getImpl()
- throws SocketException
+ SocketImpl getImpl() throws SocketException
{
try
{
- if (!implCreated)
+ if (! implCreated)
{
impl.create(true);
implCreated = true;
@@ -336,10 +337,10 @@
* @exception SecurityException If a security manager exists and its
* checkConnect method doesn't allow the operation
* @exception IllegalArgumentException If the address type is not supported
- *
+ *
* @since 1.4
*/
- public void bind (SocketAddress bindpoint) throws IOException
+ public void bind(SocketAddress bindpoint) throws IOException
{
if (isClosed())
throw new SocketException("socket is closed");
@@ -347,36 +348,36 @@
// XXX: JDK 1.4.1 API documentation says that if bindpoint is null the
// socket will be bound to an ephemeral port and a valid local address.
if (bindpoint == null)
- bindpoint = new InetSocketAddress (InetAddress.ANY_IF, 0);
-
- if ( !(bindpoint instanceof InetSocketAddress))
- throw new IllegalArgumentException ();
+ bindpoint = new InetSocketAddress(InetAddress.ANY_IF, 0);
+
+ if (! (bindpoint instanceof InetSocketAddress))
+ throw new IllegalArgumentException();
InetSocketAddress tmp = (InetSocketAddress) bindpoint;
-
+
// bind to address/port
try
{
- getImpl().bind (tmp.getAddress(), tmp.getPort());
+ getImpl().bind(tmp.getAddress(), tmp.getPort());
bound = true;
}
catch (IOException exception)
{
- close ();
- throw exception;
+ close();
+ throw exception;
}
catch (RuntimeException exception)
{
- close ();
- throw exception;
+ close();
+ throw exception;
}
catch (Error error)
{
- close ();
- throw error;
+ close();
+ throw error;
}
}
-
+
/**
* Connects the socket with a remote address.
*
@@ -386,13 +387,12 @@
* @exception IllegalArgumentException If the addess type is not supported
* @exception IllegalBlockingModeException If this socket has an associated
* channel, and the channel is in non-blocking mode
- *
+ *
* @since 1.4
*/
- public void connect (SocketAddress endpoint)
- throws IOException
+ public void connect(SocketAddress endpoint) throws IOException
{
- connect (endpoint, 0);
+ connect(endpoint, 0);
}
/**
@@ -401,7 +401,7 @@
* until established or an error occurs.
*
* @param endpoint The address to connect to
- * @param timeout The length of the timeout in milliseconds, or
+ * @param timeout The length of the timeout in milliseconds, or
* 0 to indicate no timeout.
*
* @exception IOException If an error occurs
@@ -409,15 +409,15 @@
* @exception IllegalBlockingModeException If this socket has an associated
* channel, and the channel is in non-blocking mode
* @exception SocketTimeoutException If the timeout is reached
- *
+ *
* @since 1.4
*/
- public void connect (SocketAddress endpoint, int timeout)
+ public void connect(SocketAddress endpoint, int timeout)
throws IOException
{
if (isClosed())
throw new SocketException("socket is closed");
-
+
if (! (endpoint instanceof InetSocketAddress))
throw new IllegalArgumentException("unsupported address type");
@@ -425,32 +425,31 @@
// it is in non-blocking mode, we throw an IllegalBlockingModeException.
// However, in our implementation if the channel itself initiated this
// operation, then we must honor it regardless of its blocking mode.
- if (getChannel() != null
- && !getChannel().isBlocking ()
- && !((PlainSocketImpl) getImpl()).isInChannelOperation())
- throw new IllegalBlockingModeException ();
-
- if (!isBound ())
- bind (null);
+ if (getChannel() != null && ! getChannel().isBlocking()
+ && ! ((PlainSocketImpl) getImpl()).isInChannelOperation())
+ throw new IllegalBlockingModeException();
+
+ if (! isBound())
+ bind(null);
try
{
- getImpl().connect (endpoint, timeout);
+ getImpl().connect(endpoint, timeout);
}
catch (IOException exception)
{
- close ();
- throw exception;
+ close();
+ throw exception;
}
catch (RuntimeException exception)
{
- close ();
- throw exception;
+ close();
+ throw exception;
}
catch (Error error)
{
- close ();
- throw error;
+ close();
+ throw error;
}
}
@@ -460,9 +459,9 @@
*
* @return The remote address this socket is connected to
*/
- public InetAddress getInetAddress ()
+ public InetAddress getInetAddress()
{
- if (!isConnected())
+ if (! isConnected())
return null;
try
@@ -485,20 +484,20 @@
*
* @since 1.1
*/
- public InetAddress getLocalAddress ()
+ public InetAddress getLocalAddress()
{
InetAddress addr = null;
-
+
try
{
- addr = (InetAddress) getImpl().getOption(SocketOptions.SO_BINDADDR);
+ addr = (InetAddress) getImpl().getOption(SocketOptions.SO_BINDADDR);
}
- catch(SocketException e)
+ catch (SocketException e)
{
- // (hopefully) shouldn't happen
- // throw new java.lang.InternalError
- // ("Error in PlainSocketImpl.getOption");
- return null;
+ // (hopefully) shouldn't happen
+ // throw new java.lang.InternalError
+ // ("Error in PlainSocketImpl.getOption");
+ return null;
}
// FIXME: According to libgcj, checkConnect() is supposed to be called
@@ -519,9 +518,9 @@
*
* @return The remote port this socket is connected to
*/
- public int getPort ()
+ public int getPort()
{
- if (!isConnected())
+ if (! isConnected())
return 0;
try
@@ -543,11 +542,11 @@
*
* @return The local port
*/
- public int getLocalPort ()
+ public int getLocalPort()
{
- if (!isBound())
+ if (! isBound())
return -1;
-
+
try
{
if (getImpl() != null)
@@ -562,21 +561,22 @@
}
/**
- * If the socket is already bound this returns the local SocketAddress,
- * otherwise null
+ * Returns local socket address.
+ *
+ * @return the local socket address, null if not bound
*
* @since 1.4
*/
public SocketAddress getLocalSocketAddress()
{
- if (!isBound())
+ if (! isBound())
return null;
-
- InetAddress addr = getLocalAddress ();
+
+ InetAddress addr = getLocalAddress();
try
{
- return new InetSocketAddress (addr, getImpl().getLocalPort());
+ return new InetSocketAddress(addr, getImpl().getLocalPort());
}
catch (SocketException e)
{
@@ -586,19 +586,21 @@
}
/**
- * If the socket is already connected this returns the remote SocketAddress,
- * otherwise null
+ * Returns the remote socket address.
+ *
+ * @return the remote socket address, null of not connected
*
* @since 1.4
*/
public SocketAddress getRemoteSocketAddress()
{
- if (!isConnected ())
+ if (! isConnected())
return null;
try
{
- return new InetSocketAddress (getImpl().getInetAddress (), getImpl().getPort ());
+ return new InetSocketAddress(getImpl().getInetAddress(),
+ getImpl().getPort());
}
catch (SocketException e)
{
@@ -614,14 +616,14 @@
*
* @exception IOException If an error occurs or Socket is not connected
*/
- public InputStream getInputStream () throws IOException
+ public InputStream getInputStream() throws IOException
{
if (isClosed())
throw new SocketException("socket is closed");
-
- if (!isConnected())
+
+ if (! isConnected())
throw new IOException("not connected");
-
+
return getImpl().getInputStream();
}
@@ -632,42 +634,42 @@
*
* @exception IOException If an error occurs or Socket is not connected
*/
- public OutputStream getOutputStream () throws IOException
+ public OutputStream getOutputStream() throws IOException
{
if (isClosed())
throw new SocketException("socket is closed");
-
- if (!isConnected())
+
+ if (! isConnected())
throw new IOException("not connected");
-
+
return getImpl().getOutputStream();
}
/**
- * Sets the TCP_NODELAY option on the socket.
+ * Sets the TCP_NODELAY option on the socket.
*
* @param on true to enable, false to disable
- *
+ *
* @exception SocketException If an error occurs or Socket is not connected
*
* @since 1.1
*/
- public void setTcpNoDelay (boolean on) throws SocketException
+ public void setTcpNoDelay(boolean on) throws SocketException
{
if (isClosed())
throw new SocketException("socket is closed");
-
+
getImpl().setOption(SocketOptions.TCP_NODELAY, Boolean.valueOf(on));
}
/**
- * Tests whether or not the TCP_NODELAY option is set on the socket.
+ * Tests whether or not the TCP_NODELAY option is set on the socket.
* Returns true if enabled, false if disabled. When on it disables the
* Nagle algorithm which means that packets are always send immediatly and
* never merged together to reduce network trafic.
*
* @return Whether or not TCP_NODELAY is set
- *
+ *
* @exception SocketException If an error occurs or Socket not connected
*
* @since 1.1
@@ -676,17 +678,17 @@
{
if (isClosed())
throw new SocketException("socket is closed");
-
+
Object on = getImpl().getOption(SocketOptions.TCP_NODELAY);
-
+
if (on instanceof Boolean)
- return(((Boolean)on).booleanValue());
+ return (((Boolean) on).booleanValue());
else
throw new SocketException("Internal Error");
}
/**
- * Sets the value of the SO_LINGER option on the socket. If the
+ * Sets the value of the SO_LINGER option on the socket. If the
* SO_LINGER option is set on a socket and there is still data waiting to
* be sent when the socket is closed, then the close operation will block
* until either that data is delivered or until the timeout period
@@ -694,7 +696,7 @@
* (platform specific?)
*
* @param on true to enable SO_LINGER, false to disable
- * @param linger The SO_LINGER timeout in hundreths of a second or -1 if
+ * @param linger The SO_LINGER timeout in hundreths of a second or -1 if
* SO_LINGER not set.
*
* @exception SocketException If an error occurs or Socket not connected
@@ -706,25 +708,23 @@
{
if (isClosed())
throw new SocketException("socket is closed");
-
- if (on == true)
+
+ if (on)
{
- if (linger < 0)
- throw new IllegalArgumentException("SO_LINGER must be >= 0");
+ if (linger < 0)
+ throw new IllegalArgumentException("SO_LINGER must be >= 0");
- if (linger > 65535)
- linger = 65535;
+ if (linger > 65535)
+ linger = 65535;
- getImpl().setOption(SocketOptions.SO_LINGER, new Integer(linger));
+ getImpl().setOption(SocketOptions.SO_LINGER, new Integer(linger));
}
else
- {
- getImpl().setOption(SocketOptions.SO_LINGER, Boolean.valueOf(false));
- }
+ getImpl().setOption(SocketOptions.SO_LINGER, Boolean.valueOf(false));
}
/**
- * Returns the value of the SO_LINGER option on the socket. If the
+ * Returns the value of the SO_LINGER option on the socket. If the
* SO_LINGER option is set on a socket and there is still data waiting to
* be sent when the socket is closed, then the close operation will block
* until either that data is delivered or until the timeout period
@@ -732,7 +732,7 @@
* of a second (platform specific?)) if SO_LINGER is set, or -1 if
* SO_LINGER is not set.
*
- * @return The SO_LINGER timeout in hundreths of a second or -1
+ * @return The SO_LINGER timeout in hundreths of a second or -1
* if SO_LINGER not set
*
* @exception SocketException If an error occurs or Socket is not connected
@@ -743,11 +743,11 @@
{
if (isClosed())
throw new SocketException("socket is closed");
-
+
Object linger = getImpl().getOption(SocketOptions.SO_LINGER);
if (linger instanceof Integer)
- return(((Integer)linger).intValue());
+ return (((Integer) linger).intValue());
else
return -1;
}
@@ -762,78 +762,78 @@
*
* @since 1.4
*/
- public void sendUrgentData (int data) throws IOException
+ public void sendUrgentData(int data) throws IOException
{
if (isClosed())
throw new SocketException("socket is closed");
-
- getImpl().sendUrgentData (data);
+
+ getImpl().sendUrgentData(data);
}
/**
* Enables/disables the SO_OOBINLINE option
- *
- * @param on True if SO_OOBLINE should be enabled
- *
+ *
+ * @param on True if SO_OOBLINE should be enabled
+ *
* @exception SocketException If an error occurs
- *
+ *
* @since 1.4
*/
- public void setOOBInline (boolean on) throws SocketException
+ public void setOOBInline(boolean on) throws SocketException
{
if (isClosed())
throw new SocketException("socket is closed");
-
+
getImpl().setOption(SocketOptions.SO_OOBINLINE, Boolean.valueOf(on));
}
/**
* Returns the current setting of the SO_OOBINLINE option for this socket
- *
+ *
* @return True if SO_OOBINLINE is set, false otherwise.
*
* @exception SocketException If an error occurs
- *
+ *
* @since 1.4
*/
- public boolean getOOBInline () throws SocketException
+ public boolean getOOBInline() throws SocketException
{
if (isClosed())
throw new SocketException("socket is closed");
-
+
Object buf = getImpl().getOption(SocketOptions.SO_OOBINLINE);
if (buf instanceof Boolean)
- return(((Boolean)buf).booleanValue());
+ return (((Boolean) buf).booleanValue());
else
throw new SocketException("Internal Error: Unexpected type");
}
-
+
/**
* Sets the value of the SO_TIMEOUT option on the socket. If this value
* is set, and an read/write is performed that does not complete within
* the timeout period, a short count is returned (or an EWOULDBLOCK signal
* would be sent in Unix if no data had been read). A value of 0 for
- * this option implies that there is no timeout (ie, operations will
+ * this option implies that there is no timeout (ie, operations will
* block forever). On systems that have separate read and write timeout
* values, this method returns the read timeout. This
* value is in milliseconds.
*
- * @param timeout The length of the timeout in milliseconds, or
+ * @param timeout The length of the timeout in milliseconds, or
* 0 to indicate no timeout.
*
* @exception SocketException If an error occurs or Socket not connected
*
* @since 1.1
*/
- public synchronized void setSoTimeout (int timeout) throws SocketException
+ public synchronized void setSoTimeout(int timeout) throws SocketException
{
if (isClosed())
throw new SocketException("socket is closed");
-
+
if (timeout < 0)
throw new IllegalArgumentException("SO_TIMEOUT value must be >= 0");
-
+
getImpl().setOption(SocketOptions.SO_TIMEOUT, new Integer(timeout));
}
@@ -842,26 +842,26 @@
* is set, and an read/write is performed that does not complete within
* the timeout period, a short count is returned (or an EWOULDBLOCK signal
* would be sent in Unix if no data had been read). A value of 0 for
- * this option implies that there is no timeout (ie, operations will
+ * this option implies that there is no timeout (ie, operations will
* block forever). On systems that have separate read and write timeout
* values, this method returns the read timeout. This
* value is in thousandths of a second (implementation specific?).
*
- * @return The length of the timeout in thousandth's of a second or 0
+ * @return The length of the timeout in thousandth's of a second or 0
* if not set
*
* @exception SocketException If an error occurs or Socket not connected
*
* @since 1.1
*/
- public synchronized int getSoTimeout () throws SocketException
+ public synchronized int getSoTimeout() throws SocketException
{
if (isClosed())
throw new SocketException("socket is closed");
-
+
Object timeout = getImpl().getOption(SocketOptions.SO_TIMEOUT);
if (timeout instanceof Integer)
- return(((Integer)timeout).intValue());
+ return (((Integer) timeout).intValue());
else
return 0;
}
@@ -878,14 +878,14 @@
*
* @since 1.2
*/
- public void setSendBufferSize (int size) throws SocketException
+ public void setSendBufferSize(int size) throws SocketException
{
if (isClosed())
throw new SocketException("socket is closed");
-
+
if (size <= 0)
throw new IllegalArgumentException("SO_SNDBUF value must be > 0");
-
+
getImpl().setOption(SocketOptions.SO_SNDBUF, new Integer(size));
}
@@ -900,15 +900,15 @@
*
* @since 1.2
*/
- public int getSendBufferSize () throws SocketException
+ public int getSendBufferSize() throws SocketException
{
if (isClosed())
throw new SocketException("socket is closed");
-
+
Object buf = getImpl().getOption(SocketOptions.SO_SNDBUF);
if (buf instanceof Integer)
- return(((Integer)buf).intValue());
+ return (((Integer) buf).intValue());
else
throw new SocketException("Internal Error: Unexpected type");
}
@@ -925,14 +925,14 @@
*
* @since 1.2
*/
- public void setReceiveBufferSize (int size) throws SocketException
+ public void setReceiveBufferSize(int size) throws SocketException
{
if (isClosed())
throw new SocketException("socket is closed");
-
+
if (size <= 0)
throw new IllegalArgumentException("SO_RCVBUF value must be > 0");
-
+
getImpl().setOption(SocketOptions.SO_RCVBUF, new Integer(size));
}
@@ -947,15 +947,15 @@
*
* @since 1.2
*/
- public int getReceiveBufferSize () throws SocketException
+ public int getReceiveBufferSize() throws SocketException
{
if (isClosed())
throw new SocketException("socket is closed");
-
+
Object buf = getImpl().getOption(SocketOptions.SO_RCVBUF);
if (buf instanceof Integer)
- return(((Integer)buf).intValue());
+ return (((Integer) buf).intValue());
else
throw new SocketException("Internal Error: Unexpected type");
}
@@ -970,11 +970,11 @@
*
* @since 1.3
*/
- public void setKeepAlive (boolean on) throws SocketException
+ public void setKeepAlive(boolean on) throws SocketException
{
if (isClosed())
throw new SocketException("socket is closed");
-
+
getImpl().setOption(SocketOptions.SO_KEEPALIVE, Boolean.valueOf(on));
}
@@ -988,15 +988,15 @@
*
* @since 1.3
*/
- public boolean getKeepAlive () throws SocketException
+ public boolean getKeepAlive() throws SocketException
{
if (isClosed())
throw new SocketException("socket is closed");
-
+
Object buf = getImpl().getOption(SocketOptions.SO_KEEPALIVE);
if (buf instanceof Boolean)
- return(((Boolean)buf).booleanValue());
+ return (((Boolean) buf).booleanValue());
else
throw new SocketException("Internal Error: Unexpected type");
}
@@ -1006,11 +1006,11 @@
*
* @exception IOException If an error occurs
*/
- public synchronized void close () throws IOException
+ public synchronized void close() throws IOException
{
if (isClosed())
return;
-
+
getImpl().close();
impl = null;
bound = false;
@@ -1024,15 +1024,14 @@
*
* @return The String
representation of this Socket
*/
- public String toString ()
+ public String toString()
{
try
{
if (isConnected())
- return ("Socket[addr=" + getImpl().getInetAddress()
- + ",port=" + getImpl().getPort()
- + ",localport=" + getImpl().getLocalPort()
- + "]");
+ return ("Socket[addr=" + getImpl().getInetAddress() + ",port="
+ + getImpl().getPort() + ",localport="
+ + getImpl().getLocalPort() + "]");
}
catch (SocketException e)
{
@@ -1043,19 +1042,21 @@
}
/**
- * Sets the SocketImplFactory
. This may be done only once per
- * virtual machine. Subsequent attempts will generate a
+ * Sets the SocketImplFactory
. This may be done only once per
+ * virtual machine. Subsequent attempts will generate a
* SocketException
. Note that a SecurityManager
- * check is made prior to setting the factory. If
- * insufficient privileges exist to set the factory, then an
+ * check is made prior to setting the factory. If
+ * insufficient privileges exist to set the factory, then an
* IOException
will be thrown.
*
+ * @param fac the factory to set
+ *
* @exception SecurityException If the SecurityManager
does
* not allow this operation.
* @exception SocketException If the SocketImplFactory is already defined
* @exception IOException If any other error occurs
*/
- public static synchronized void setSocketImplFactory (SocketImplFactory fac)
+ public static synchronized void setSocketImplFactory(SocketImplFactory fac)
throws IOException
{
// See if already set
@@ -1084,7 +1085,7 @@
{
if (isClosed())
throw new SocketException("socket is closed");
-
+
getImpl().shutdownInput();
inputShutdown = true;
}
@@ -1100,7 +1101,7 @@
{
if (isClosed())
throw new SocketException("socket is closed");
-
+
getImpl().shutdownOutput();
outputShutdown = true;
}
@@ -1108,7 +1109,8 @@
/**
* Returns the socket channel associated with this socket.
*
- * It returns null if no associated socket exists.
+ * @return the associated socket channel,
+ * null if no associated channel exists
*
* @since 1.4
*/
@@ -1126,55 +1128,57 @@
*
* @since 1.4
*/
- public boolean getReuseAddress () throws SocketException
+ public boolean getReuseAddress() throws SocketException
{
if (isClosed())
throw new SocketException("socket is closed");
-
- Object reuseaddr = getImpl().getOption (SocketOptions.SO_REUSEADDR);
- if (!(reuseaddr instanceof Boolean))
- throw new SocketException ("Internal Error");
+ Object reuseaddr = getImpl().getOption(SocketOptions.SO_REUSEADDR);
- return ((Boolean) reuseaddr).booleanValue ();
+ if (! (reuseaddr instanceof Boolean))
+ throw new SocketException("Internal Error");
+
+ return ((Boolean) reuseaddr).booleanValue();
}
/**
* Enables/Disables the SO_REUSEADDR option
*
- * @param reuseAddress True if SO_REUSEADDR should be set.
- *
+ * @param reuseAddress true if SO_REUSEADDR should be enabled,
+ * false otherwise
+ *
* @exception SocketException If an error occurs
*
* @since 1.4
*/
- public void setReuseAddress (boolean on) throws SocketException
+ public void setReuseAddress(boolean reuseAddress) throws SocketException
{
- getImpl().setOption (SocketOptions.SO_REUSEADDR, Boolean.valueOf(on));
+ getImpl().setOption(SocketOptions.SO_REUSEADDR,
+ Boolean.valueOf(reuseAddress));
}
/**
* Returns the current traffic class
*
* @return The current traffic class.
- *
+ *
* @exception SocketException If an error occurs
*
* @see Socket#setTrafficClass(int tc)
*
* @since 1.4
*/
- public int getTrafficClass () throws SocketException
+ public int getTrafficClass() throws SocketException
{
if (isClosed())
throw new SocketException("socket is closed");
-
+
Object obj = getImpl().getOption(SocketOptions.IP_TOS);
if (obj instanceof Integer)
- return ((Integer) obj).intValue ();
+ return ((Integer) obj).intValue();
else
- throw new SocketException ("Unexpected type");
+ throw new SocketException("Unexpected type");
}
/**
@@ -1189,15 +1193,15 @@
*
* @since 1.4
*/
- public void setTrafficClass (int tc) throws SocketException
+ public void setTrafficClass(int tc) throws SocketException
{
if (isClosed())
throw new SocketException("socket is closed");
-
+
if (tc < 0 || tc > 255)
throw new IllegalArgumentException();
- getImpl().setOption (SocketOptions.IP_TOS, new Integer (tc));
+ getImpl().setOption(SocketOptions.IP_TOS, new Integer(tc));
}
/**
@@ -1207,11 +1211,11 @@
*
* @since 1.4
*/
- public boolean isConnected ()
+ public boolean isConnected()
{
try
{
- return getImpl().getInetAddress () != null;
+ return getImpl().getInetAddress() != null;
}
catch (SocketException e)
{
@@ -1226,19 +1230,19 @@
*
* @since 1.4
*/
- public boolean isBound ()
+ public boolean isBound()
{
return bound;
}
/**
* Checks if the socket is closed.
- *
+ *
* @return True if socket is closed, false otherwise.
*
* @since 1.4
*/
- public boolean isClosed ()
+ public boolean isClosed()
{
return impl == null;
}
@@ -1247,10 +1251,10 @@
* Checks if the socket's input stream is shutdown
*
* @return True if input is shut down.
- *
+ *
* @since 1.4
*/
- public boolean isInputShutdown ()
+ public boolean isInputShutdown()
{
return inputShutdown;
}
@@ -1259,10 +1263,10 @@
* Checks if the socket's output stream is shutdown
*
* @return True if output is shut down.
- *
+ *
* @since 1.4
*/
- public boolean isOutputShutdown ()
+ public boolean isOutputShutdown()
{
return outputShutdown;
}
Index: java/net/SocketAddress.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/net/SocketAddress.java,v
retrieving revision 1.6
diff -u -r1.6 SocketAddress.java
--- java/net/SocketAddress.java 14 Jan 2003 21:46:20 -0000 1.6
+++ java/net/SocketAddress.java 8 Apr 2004 16:24:08 -0000
@@ -1,4 +1,4 @@
-/* SocketAddress.java --
+/* SocketAddress.java --
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -39,7 +39,8 @@
import java.io.Serializable;
-/**
+
+/**
* Abstract base class for InetSocketAddress.
* InetSocketAddress is to my knowledge the only derived
* class. [Ronald]
Index: java/net/SocketException.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/net/SocketException.java,v
retrieving revision 1.8
diff -u -r1.8 SocketException.java
--- java/net/SocketException.java 24 Feb 2002 04:25:16 -0000 1.8
+++ java/net/SocketException.java 8 Apr 2004 16:24:08 -0000
@@ -39,6 +39,7 @@
import java.io.IOException;
+
/**
* This exception indicates that a generic error occurred related to an
* operation on a socket. Check the descriptive message (if any) for
Index: java/net/SocketImpl.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/net/SocketImpl.java,v
retrieving revision 1.18
diff -u -r1.18 SocketImpl.java
--- java/net/SocketImpl.java 29 Jul 2003 15:50:20 -0000 1.18
+++ java/net/SocketImpl.java 8 Apr 2004 16:24:08 -0000
@@ -36,14 +36,14 @@
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-
package java.net;
import java.io.FileDescriptor;
-import java.io.InputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
+
/* Written using on-line Java Platform 1.2 API Specification.
* Believed complete and correct.
*/
@@ -113,7 +113,8 @@
*
* @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.
@@ -153,7 +154,8 @@
*
* @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
@@ -220,26 +222,38 @@
*
* @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
*
* @return The remote address
*/
- protected InetAddress getInetAddress() { return address; }
+ protected InetAddress getInetAddress()
+ {
+ return address;
+ }
/**
* Returns the remote port this socket is connected to
*
* @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
* or not.
*
+ * @return true if the socket implementation supports sending urgent data,
+ * false otherwise
+ *
* @since 1.4
*/
protected boolean supportsUrgentData()
@@ -248,7 +262,7 @@
// sending urgend data.
return false;
}
-
+
/**
* Sends one byte of urgent data to the socket.
*
@@ -258,15 +272,17 @@
*
* @since 1.4
*/
- protected abstract void sendUrgentData(int data)
- throws IOException;
-
+ protected abstract void sendUrgentData(int data) throws IOException;
+
/**
* Returns the local port this socket is bound to
*
* @return The local port
*/
- protected int getLocalPort() { return localport; }
+ protected int getLocalPort()
+ {
+ return localport;
+ }
/**
* Returns a String
representing the remote host and port of
@@ -276,10 +292,9 @@
*/
public String toString()
{
- return "[addr=" + ((address == null) ? "0.0.0.0/0.0.0.0" :
- address.toString())
- + ",port=" + port
- + ",localport=" + localport + "]";
+ return "[addr="
+ + ((address == null) ? "0.0.0.0/0.0.0.0" : address.toString())
+ + ",port=" + port + ",localport=" + localport + "]";
}
/**
@@ -288,9 +303,9 @@
*
* @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 @@
*
* @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");
}
}
Index: java/net/SocketImplFactory.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/net/SocketImplFactory.java,v
retrieving revision 1.10
diff -u -r1.10 SocketImplFactory.java
--- java/net/SocketImplFactory.java 12 Oct 2003 15:35:01 -0000 1.10
+++ java/net/SocketImplFactory.java 8 Apr 2004 16:24:08 -0000
@@ -7,7 +7,7 @@
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
-
+
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@@ -35,13 +35,12 @@
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-
package java.net;
+
/** Written using on-line Java Platform 1.2 API Specification.
* Status: Believed complete and correct.
*/
-
/**
* This interface defines one method which returns a SocketImpl
* object. This should not be needed by ordinary applications.
@@ -57,6 +56,4 @@
* @return A SocketImpl
object
*/
SocketImpl createSocketImpl();
-
} // interface SocketImplFactory
-
Index: java/net/SocketOptions.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/net/SocketOptions.java,v
retrieving revision 1.12
diff -u -r1.12 SocketOptions.java
--- java/net/SocketOptions.java 12 Oct 2003 15:35:01 -0000 1.12
+++ java/net/SocketOptions.java 8 Apr 2004 16:24:08 -0000
@@ -1,5 +1,5 @@
/* 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.
This file is part of GNU Classpath.
@@ -8,7 +8,7 @@
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
-
+
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@@ -38,15 +38,15 @@
package java.net;
+
/**
* Written using on-line Java Platform 1.2 API Specification.
* Status: Believed complete and correct.
*/
-
/**
- * This interface is used by SocketImpl
and
+ * This interface is used by SocketImpl
and
* DatagramSocketImpl
to implement options
- * on sockets.
+ * on sockets.
*
* @since 1.2
*
@@ -163,6 +163,4 @@
* @exception SocketException If an error occurs
*/
Object getOption(int optionId) throws SocketException;
-
} // interface SocketOptions
-
Index: java/net/SocketTimeoutException.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/net/SocketTimeoutException.java,v
retrieving revision 1.1
diff -u -r1.1 SocketTimeoutException.java
--- java/net/SocketTimeoutException.java 24 Feb 2002 04:25:16 -0000 1.1
+++ java/net/SocketTimeoutException.java 8 Apr 2004 16:24:08 -0000
@@ -39,6 +39,7 @@
import java.io.InterruptedIOException;
+
/**
* This exception signals that a socket read or accept timed out.
*
Index: java/net/URISyntaxException.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/net/URISyntaxException.java,v
retrieving revision 1.1
diff -u -r1.1 URISyntaxException.java
--- java/net/URISyntaxException.java 24 Feb 2002 04:25:16 -0000 1.1
+++ java/net/URISyntaxException.java 8 Apr 2004 16:24:08 -0000
@@ -37,6 +37,7 @@
package java.net;
+
/**
* This exception is thrown when a String cannot be parsed as a URI.
*
@@ -137,7 +138,7 @@
*/
public String getMessage()
{
- return super.getMessage() + (index >= 0 ? " at index " + index : "")
- + ": " + input;
+ return (super.getMessage() + (index >= 0 ? " at index " + index : "")
+ + ": " + input);
}
}
Index: java/net/URLDecoder.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/net/URLDecoder.java,v
retrieving revision 1.12
diff -u -r1.12 URLDecoder.java
--- java/net/URLDecoder.java 2 Mar 2003 20:31:56 -0000 1.12
+++ java/net/URLDecoder.java 8 Apr 2004 16:24:08 -0000
@@ -7,7 +7,7 @@
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
-
+
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@@ -39,8 +39,9 @@
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
* text. The x-www-form-urlencoded format replaces certain disallowed
* characters with encoded equivalents. All upper case and lower case
@@ -65,7 +66,7 @@
/**
* Public contructor. Note that this class has only static methods.
*/
- public URLDecoder ()
+ public URLDecoder()
{
}
@@ -84,12 +85,12 @@
{
try
{
- return decode(s, "UTF-8");
+ return decode(s, "UTF-8");
}
catch (UnsupportedEncodingException uee)
{
- // Should never happen since UTF-8 encoding should always be supported
- return s;
+ // Should never happen since UTF-8 encoding should always be supported
+ return s;
}
}
@@ -120,7 +121,7 @@
{
// First convert all '+' characters to spaces.
String str = s.replace('+', ' ');
-
+
// Then go through the whole string looking for byte encoded characters
int i;
int start = 0;
@@ -134,12 +135,12 @@
start = i;
// Get all consecutive encoded bytes
- while ((i+2 < length) && (str.charAt(i) == '%'))
+ while ((i + 2 < length) && (str.charAt(i) == '%'))
i += 3;
// Decode all these bytes
- if ((bytes == null) || (bytes.length < ((i-start)/3)))
- bytes = new byte[((i-start)/3)];
+ if ((bytes == null) || (bytes.length < ((i - start) / 3)))
+ bytes = new byte[((i - start) / 3)];
int index = 0;
try
@@ -147,7 +148,7 @@
while (start < i)
{
String sub = str.substring(start + 1, start + 3);
- bytes[index] = (byte)Integer.parseInt(sub, 16);
+ bytes[index] = (byte) Integer.parseInt(sub, 16);
index++;
start += 3;
}
@@ -176,5 +177,4 @@
return result.toString();
}
-
} // class URLDecoder
Index: java/net/URLEncoder.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/net/URLEncoder.java,v
retrieving revision 1.11
diff -u -r1.11 URLEncoder.java
--- java/net/URLEncoder.java 22 Jul 2003 16:36:02 -0000 1.11
+++ java/net/URLEncoder.java 8 Apr 2004 16:24:08 -0000
@@ -7,7 +7,7 @@
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
-
+
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@@ -39,29 +39,30 @@
import java.io.UnsupportedEncodingException;
+
/*
* Written using on-line Java Platform 1.2/1.4 API Specification, as well
* as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
* Status: Believed complete and correct.
*/
- /**
- * This utility class contains static methods that converts a
- * string into a fully encoded URL string in x-www-form-urlencoded
- * format. This format replaces certain disallowed characters with
- * encoded equivalents. All upper case and lower case letters in the
- * US alphabet remain as is, the space character (' ') is replaced with
- * '+' sign, and all other characters are converted to a "%XX" format
- * where XX is the hexadecimal representation of that character in a
- * certain encoding (by default, the platform encoding, though the
- * standard is "UTF-8").
- *
- * This method is very useful for encoding strings to be sent to CGI scripts - * - * @author Aaron M. Renn (address@hidden) - * @author Warren Levy
- * @author Mark Wielaard (address@hidden) - */ +/** + * This utility class contains static methods that converts a + * string into a fully encoded URL string in x-www-form-urlencoded + * format. This format replaces certain disallowed characters with + * encoded equivalents. All upper case and lower case letters in the + * US alphabet remain as is, the space character (' ') is replaced with + * '+' sign, and all other characters are converted to a "%XX" format + * where XX is the hexadecimal representation of that character in a + * certain encoding (by default, the platform encoding, though the + * standard is "UTF-8"). + *+ * This method is very useful for encoding strings to be sent to CGI scripts + * + * @author Aaron M. Renn (address@hidden) + * @author Warren Levy
+ * @author Mark Wielaard (address@hidden) + */ public class URLEncoder { /** @@ -82,11 +83,11 @@ { // We default to 8859_1 for compatibility with the same // 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) { - // Should never happen since default should always be supported + // Should never happen since default should always be supported return s; } } @@ -114,42 +115,42 @@ StringBuffer result = new StringBuffer(length); while (true) - { - 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. + { + while (i < length && isSafe(s.charAt(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 - 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; - } + // 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++; + } + 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 @@ */ private static boolean isSafe(char c) { - return ((c >= 'a' && c <= 'z') || - (c >= 'A' && c <= 'Z') || - (c >= '0' && c <= '9') || - c == '-' || c == '_' || c == '.' || c == '*'); + return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') + || (c >= '0' && c <= '9') || c == '-' || c == '_' || c == '.' + || c == '*'); } /** * Private constructor that does nothing. Included to avoid a default * public constructor being created by the compiler. */ - private URLEncoder() { } + private URLEncoder() + { + } /** * Used to convert to hex. We don't use Integer.toHexString, since @@ -179,4 +181,4 @@ * leading 0. */ private static final String hex = "0123456789ABCDEF"; -} // class URLEncoder +} Index: java/net/URLStreamHandlerFactory.java =================================================================== RCS file: /cvsroot/classpath/classpath/java/net/URLStreamHandlerFactory.java,v retrieving revision 1.10 diff -u -r1.10 URLStreamHandlerFactory.java --- java/net/URLStreamHandlerFactory.java 13 Oct 2003 06:29:48 -0000 1.10 +++ java/net/URLStreamHandlerFactory.java 8 Apr 2004 16:24:08 -0000 @@ -7,7 +7,7 @@ it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -37,15 +37,15 @@ package java.net; + /** * Written using on-line Java Platform 1.2 API Specification, as well * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998). * Status: Believed complete and correct. */ - /** * 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 *URLStreamHandler
object.
*
* @author Aaron M. Renn (address@hidden)
@@ -54,14 +54,12 @@
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
* URLStreamHandler
object.
*
* @param protocol The protocol name to map ("http", "ftp", etc).
*
* @return The URLStreamHandler
for the specified protocol
*/
- URLStreamHandler createURLStreamHandler (String protocol);
-
+ URLStreamHandler createURLStreamHandler(String protocol);
} // interface URLStreamHandlerFactory
-
Index: java/net/UnknownHostException.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/net/UnknownHostException.java,v
retrieving revision 1.7
diff -u -r1.7 UnknownHostException.java
--- java/net/UnknownHostException.java 24 Feb 2002 04:25:16 -0000 1.7
+++ java/net/UnknownHostException.java 8 Apr 2004 16:24:08 -0000
@@ -39,6 +39,7 @@
import java.io.IOException;
+
/**
* 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
Index: java/net/UnknownServiceException.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/net/UnknownServiceException.java,v
retrieving revision 1.8
diff -u -r1.8 UnknownServiceException.java
--- java/net/UnknownServiceException.java 24 Feb 2002 04:25:16 -0000 1.8
+++ java/net/UnknownServiceException.java 8 Apr 2004 16:24:08 -0000
@@ -39,6 +39,7 @@
import java.io.IOException;
+
/**
* Contrary to what you might think, this does not indicate that the
* TCP/IP service name specified was invalid. Instead it indicates that