Commit f6d49f66 by Michael Koch Committed by Michael Koch

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

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

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

From-SVN: r80900
parent cf6f7d55
2004-04-20 Michael Koch <konqueror@gmx.de>
* java/net/Authenticator.java,
java/net/BindException.java,
java/net/ConnectException.java,
java/net/ContentHandler.java,
java/net/ContentHandlerFactory.java,
java/net/DatagramPacket.java,
java/net/DatagramSocket.java,
java/net/DatagramSocketImpl.java,
java/net/DatagramSocketImplFactory.java,
java/net/FileNameMap.java,
java/net/HttpURLConnection.java,
java/net/Inet4Address.java,
java/net/Inet6Address.java,
java/net/InetAddress.java,
java/net/InetSocketAddress.java,
java/net/JarURLConnection.java,
java/net/MalformedURLException.java,
java/net/MulticastSocket.java,
java/net/NetPermission.java,
java/net/NetworkInterface.java,
java/net/NoRouteToHostException.java,
java/net/PasswordAuthentication.java,
java/net/PortUnreachableException.java,
java/net/ProtocolException.java,
java/net/ServerSocket.java,
java/net/Socket.java,
java/net/SocketAddress.java,
java/net/SocketException.java,
java/net/SocketImpl.java,
java/net/SocketImplFactory.java,
java/net/SocketOptions.java,
java/net/SocketPermission.java,
java/net/SocketTimeoutException.java,
java/net/URI.java,
java/net/URISyntaxException.java,
java/net/URL.java,
java/net/URLClassLoader.java,
java/net/URLConnection.java,
java/net/URLDecoder.java,
java/net/URLEncoder.java,
java/net/URLStreamHandler.java,
java/net/URLStreamHandlerFactory.java,
java/net/UnknownHostException.java,
java/net/UnknownServiceException.java:
Fixed javadocs, coding style and argument names all over.
2004-04-20 Michael Koch <konqueror@gmx.de>
* java/lang/Byte.java,
java/lang/CharSequence.java,
java/lang/ClassLoader.java,
......
......@@ -37,6 +37,7 @@ exception statement from your version. */
package java.net;
/**
* This abstract class provides a model for obtaining authentication
* information (in the form of a username and password) required by
......@@ -150,13 +151,15 @@ public abstract class Authenticator
* @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);
}
/**
......@@ -187,9 +190,12 @@ public abstract class Authenticator
*
* @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 @@ public abstract class Authenticator
sm.checkPermission(new NetPermission("requestPasswordAuthentication"));
if (defaultAuthenticator == null)
return(null);
return null;
defaultAuthenticator.host = host;
defaultAuthenticator.addr = addr;
......@@ -206,7 +212,7 @@ public abstract class Authenticator
defaultAuthenticator.prompt = prompt;
defaultAuthenticator.scheme = scheme;
return(defaultAuthenticator.getPasswordAuthentication());
return defaultAuthenticator.getPasswordAuthentication();
}
/*
......@@ -232,7 +238,7 @@ public abstract class Authenticator
*/
protected final InetAddress getRequestingSite()
{
return(addr);
return addr;
}
/**
......@@ -240,13 +246,13 @@ public abstract class Authenticator
* or <code>null</code> if not available.
*
* @return The name of the host requesting authentication, or
* </code>null</code> if it is not available.
* <code>null</code> if it is not available.
*
* @since 1.4
*/
protected final String getRequestingHost()
{
return(host);
return host;
}
/**
......@@ -257,7 +263,7 @@ public abstract class Authenticator
*/
protected final int getRequestingPort()
{
return(port);
return port;
}
/**
......@@ -268,7 +274,7 @@ public abstract class Authenticator
*/
protected final String getRequestingProtocol()
{
return(protocol);
return protocol;
}
/**
......@@ -279,7 +285,7 @@ public abstract class Authenticator
*/
protected final String getRequestingPrompt()
{
return(prompt);
return prompt;
}
/**
......@@ -289,7 +295,7 @@ public abstract class Authenticator
*/
protected final String getRequestingScheme()
{
return(scheme);
return scheme;
}
/**
......@@ -302,8 +308,6 @@ public abstract class Authenticator
*/
protected PasswordAuthentication getPasswordAuthentication()
{
return(null);
return null;
}
} // class Authenticator
......@@ -37,6 +37,7 @@ exception statement from your version. */
package java.net;
/**
* This exception indicates that an error occurred while attempting to bind
* socket to a particular port.
......
......@@ -35,9 +35,9 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package java.net;
/**
* This exception indicates that an error occurred while attempting to
* connect to a remote host. Often this indicates that the remote host
......
......@@ -113,15 +113,14 @@ public abstract class ContentHandler
public Object getContent(URLConnection urlc, Class[] classes)
throws IOException
{
Object obj = getContent (urlc);
Object obj = getContent(urlc);
for (int i = 0; i < classes.length; i++)
{
if (classes [i].isInstance (obj))
if (classes[i].isInstance(obj))
return obj;
}
return null;
}
} // class ContentHandler
......@@ -35,15 +35,14 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
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 maps MIME types to <code>ContentHandler</code> objects.
* It consists of one method that, when passed a MIME type, returns a
......@@ -63,6 +62,4 @@ public interface ContentHandlerFactory
* @return The <code>ContentHandler</code> for the passed in MIME type
*/
ContentHandler createContentHandler(String mimeType);
} // interface ContentHandlerFactory
......@@ -37,6 +37,7 @@ 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).
......@@ -134,8 +135,8 @@ public final class DatagramPacket
*
* @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 &lt;= buf.length)
* @param addr The address to send to
* @param length The length of the buffer (must be &lt;= buf.length)
* @param address The address to send to
* @param port The port to send to
*
* @since 1.2
......@@ -177,8 +178,7 @@ public final class DatagramPacket
* @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 @@ public final class DatagramPacket
/**
* 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 @@ public final class DatagramPacket
*
* @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;
}
/**
......@@ -329,7 +329,7 @@ public final class DatagramPacket
*/
public SocketAddress getSocketAddress()
{
return new InetSocketAddress (address, port);
return new InetSocketAddress(address, port);
}
/**
......@@ -360,7 +360,6 @@ public final class DatagramPacket
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)
......
......@@ -36,11 +36,11 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
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 @@ import java.io.FileDescriptor;
*/
public abstract class DatagramSocketImpl implements SocketOptions
{
/**
* The local port to which this socket is bound
*/
......@@ -130,7 +129,7 @@ public abstract class DatagramSocketImpl implements SocketOptions
*
* @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,7 +168,8 @@ public abstract class DatagramSocketImpl implements SocketOptions
*
* @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
}
......@@ -179,7 +179,7 @@ public abstract class DatagramSocketImpl implements SocketOptions
*
* @since 1.4
*/
protected void disconnect ()
protected void disconnect()
{
// This method has to be overwritten by real implementations
}
......@@ -199,8 +199,11 @@ public abstract class DatagramSocketImpl implements SocketOptions
* This method returns the current Time to Live (TTL) setting on this
* socket. <b>Use <code>getTimeToLive()</code></b> 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 @@ public abstract class DatagramSocketImpl implements SocketOptions
* 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;
......@@ -251,7 +256,7 @@ public abstract class DatagramSocketImpl implements SocketOptions
*
* @since 1.4
*/
protected abstract void joinGroup (SocketAddress mcastaddr,
protected abstract void joinGroup(SocketAddress mcastaddr,
NetworkInterface netIf)
throws IOException;
......@@ -265,12 +270,14 @@ public abstract class DatagramSocketImpl implements SocketOptions
*
* @since 1.4
*/
protected abstract void leaveGroup (SocketAddress mcastaddr,
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 @@ public abstract class DatagramSocketImpl implements SocketOptions
/**
* Returns the local port this socket is bound to
*
* @return the local port
*/
protected int getLocalPort()
{
......
......@@ -37,10 +37,10 @@ exception statement from your version. */
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
* <code>DatagramSocketImpl</code> object.
......@@ -57,5 +57,4 @@ public interface DatagramSocketImplFactory
* @return A DatagramSocketImpl object
*/
DatagramSocketImpl createDatagramSocketImpl();
} // interface DatagramSocketImplFactory
......@@ -35,15 +35,14 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
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 @@ public interface FileNameMap
* @return The MIME type for the filename passed in.
*/
String getContentTypeFor(String filename);
} // interface FileNameMap
......@@ -36,14 +36,14 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
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).
......@@ -116,7 +116,6 @@ public abstract class HttpURLConnection extends URLConnection
*/
public static final int HTTP_PARTIAL = 206;
/* HTTP Redirection Response Codes */
/**
......@@ -150,7 +149,6 @@ public abstract class HttpURLConnection extends URLConnection
*/
public static final int HTTP_USE_PROXY = 305;
/* HTTP Client Error Response Codes */
/**
......@@ -239,7 +237,6 @@ public abstract class HttpURLConnection extends URLConnection
*/
public static final int HTTP_UNSUPPORTED_TYPE = 415;
/* HTTP Server Error Response Codes */
/**
......@@ -294,8 +291,8 @@ public abstract class HttpURLConnection extends URLConnection
/**
* 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 @@ public abstract class HttpURLConnection extends URLConnection
/**
* 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 @@ public abstract class HttpURLConnection extends URLConnection
* Used by <code>getResponseCode()</code> and
* <code>getResponseMessage()</code>.
*/
private boolean gotResponseVals = false;
private boolean gotResponseVals;
/**
* Create an HttpURLConnection for the specified URL
......@@ -383,16 +380,20 @@ public abstract class HttpURLConnection extends URLConnection
/**
* 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 @@ public abstract class HttpURLConnection extends URLConnection
* 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 @@ public abstract class HttpURLConnection extends URLConnection
this.method = method;
else
throw new ProtocolException("Invalid HTTP request method: " + method);
}
/**
......@@ -439,7 +441,7 @@ public abstract class HttpURLConnection extends URLConnection
*/
public int getResponseCode() throws IOException
{
if (!gotResponseVals)
if (! gotResponseVals)
getResponseVals();
return responseCode;
}
......@@ -455,7 +457,7 @@ public abstract class HttpURLConnection extends URLConnection
*/
public String getResponseMessage() throws IOException
{
if (!gotResponseVals)
if (! gotResponseVals)
getResponseVals();
return responseMessage;
}
......@@ -464,7 +466,7 @@ public abstract class HttpURLConnection extends URLConnection
{
// getHeaderField() will connect for us, but do it here first in
// order to pick up IOExceptions.
if (!connected)
if (! connected)
connect();
gotResponseVals = true;
......@@ -483,7 +485,8 @@ public abstract class HttpURLConnection extends URLConnection
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 @@ public abstract class HttpURLConnection extends URLConnection
* 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
......@@ -529,26 +534,26 @@ public abstract class HttpURLConnection extends URLConnection
*
* @return An <code>InputStream</code> for reading error data.
*/
public InputStream getErrorStream ()
public InputStream getErrorStream()
{
if (!connected)
return(null);
if (! connected)
return (null);
int code;
try
{
code = getResponseCode();
}
catch(IOException e)
catch (IOException e)
{
code = -1;
}
if (code == -1)
return(null);
return (null);
if (((code/100) != 4) || ((code/100) != 5))
return(null);
if (((code / 100) != 4) || ((code / 100) != 5))
return (null);
try
{
......@@ -556,25 +561,29 @@ public abstract class HttpURLConnection extends URLConnection
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);
}
}
......@@ -35,12 +35,12 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package java.net;
import java.io.ObjectStreamException;
import java.util.Arrays;
/**
* @author Michael Koch
* @date August 3, 2002.
......@@ -53,7 +53,6 @@ import java.util.Arrays;
* RFC 2365 (http://www.ietf.org/rfc/rfc2365.txt)
* Status: Believed complete and correct.
*/
public final class Inet4Address extends InetAddress
{
static final long serialVersionUID = 3286316764910316507L;
......@@ -61,9 +60,9 @@ public final class Inet4Address extends InetAddress
/**
* needed for serialization
*/
private Object writeReplace () throws ObjectStreamException
private Object writeReplace() throws ObjectStreamException
{
return new InetAddress (addr, hostName);
return new InetAddress(addr, hostName);
}
/**
......@@ -74,7 +73,7 @@ public final class Inet4Address extends InetAddress
*/
Inet4Address(byte[] addr, String host)
{
super (addr, host);
super(addr, host);
}
/**
......@@ -82,17 +81,17 @@ public final class Inet4Address extends InetAddress
*
* @since 1.1
*/
public boolean isMulticastAddress ()
public boolean isMulticastAddress()
{
return (addr [0] & 0xF0) == 0xE0;
return (addr[0] & 0xF0) == 0xE0;
}
/**
* Checks if this address is a loopback address
*/
public boolean isLoopbackAddress ()
public boolean isLoopbackAddress()
{
return addr [0] == 0x7F;
return addr[0] == 0x7F;
}
/**
......@@ -100,7 +99,7 @@ public final class Inet4Address extends InetAddress
*
* @since 1.4
*/
public boolean isAnyLocalAddress ()
public boolean isAnyLocalAddress()
{
byte[] anylocal = { 0, 0, 0, 0 };
......@@ -112,7 +111,7 @@ public final class Inet4Address extends InetAddress
*
* @since 1.4
*/
public boolean isLinkLocalAddress ()
public boolean isLinkLocalAddress()
{
// XXX: This seems to not exist with IPv4 addresses
return false;
......@@ -123,21 +122,21 @@ public final class Inet4Address extends InetAddress
*
* @since 1.4
*/
public boolean isSiteLocalAddress ()
public boolean isSiteLocalAddress()
{
// 10.0.0.0/8
if (addr [0] == 0x0A)
if (addr[0] == 0x0A)
return true;
// XXX: Suns JDK 1.4.1 (on Linux) seems to have a bug here:
// it says 172.16.0.0 - 172.255.255.255 are site local addresses
//
// 172.16.0.0/12
if (addr [0] == 0xAC && (addr [1] & 0xF0) == 0x01)
if (addr[0] == 0xAC && (addr[1] & 0xF0) == 0x01)
return true;
// 192.168.0.0/16
if (addr [0] == 0xC0 && addr [1] == 0xA8)
if (addr[0] == 0xC0 && addr[1] == 0xA8)
return true;
// XXX: Do we need to check more addresses here ?
......@@ -149,7 +148,7 @@ public final class Inet4Address extends InetAddress
*
* @since 1.4
*/
public boolean isMCGlobal ()
public boolean isMCGlobal()
{
// XXX: This seems to net exist with IPv4 addresses
return false;
......@@ -160,7 +159,7 @@ public final class Inet4Address extends InetAddress
*
* @since 1.4
*/
public boolean isMCNodeLocal ()
public boolean isMCNodeLocal()
{
// XXX: This seems to net exist with IPv4 addresses
return false;
......@@ -171,14 +170,12 @@ public final class Inet4Address extends InetAddress
*
* @since 1.4
*/
public boolean isMCLinkLocal ()
public boolean isMCLinkLocal()
{
if (!isMulticastAddress ())
if (! isMulticastAddress())
return false;
return (addr [0] == 0xE0)
&& (addr [1] == 0x00)
&& (addr [2] == 0x00);
return (addr[0] == 0xE0) && (addr[1] == 0x00) && (addr[2] == 0x00);
}
/**
......@@ -186,7 +183,7 @@ public final class Inet4Address extends InetAddress
*
* @since 1.4
*/
public boolean isMCSiteLocal ()
public boolean isMCSiteLocal()
{
// XXX: This seems to net exist with IPv4 addresses
return false;
......@@ -197,7 +194,7 @@ public final class Inet4Address extends InetAddress
*
* @since 1.4
*/
public boolean isMCOrgLocal ()
public boolean isMCOrgLocal()
{
// XXX: This seems to net exist with IPv4 addresses
return false;
......@@ -206,7 +203,7 @@ public final class Inet4Address extends InetAddress
/**
* Returns the address of the current instance
*/
public byte[] getAddress ()
public byte[] getAddress()
{
return addr;
}
......@@ -216,37 +213,37 @@ public final class Inet4Address extends InetAddress
*
* @since 1.0.2
*/
public String getHostAddress ()
public String getHostAddress()
{
StringBuffer sbuf = new StringBuffer (40);
StringBuffer sbuf = new StringBuffer(40);
int len = addr.length;
int i = 0;
for ( ; ; )
for (;;)
{
sbuf.append (addr [i] & 0xFF);
sbuf.append(addr[i] & 0xFF);
i++;
if (i == len)
break;
sbuf.append ('.');
sbuf.append('.');
}
return sbuf.toString ();
return sbuf.toString();
}
/**
* Computes the hashcode of the instance
*/
public int hashCode ()
public int hashCode()
{
int hash = 0;
int len = addr.length;
int i = len > 4 ? len - 4 : 0;
for ( ; i < len; i++)
hash = (hash << 8) | (addr [i] & 0xFF);
for (; i < len; i++)
hash = (hash << 8) | (addr[i] & 0xFF);
return hash;
}
......@@ -256,7 +253,7 @@ public final class Inet4Address extends InetAddress
*
* @param obj Object to compare with
*/
public boolean equals (Object obj)
public boolean equals(Object obj)
{
if (! (obj instanceof InetAddress))
return false;
......@@ -267,8 +264,8 @@ public final class Inet4Address extends InetAddress
if (addr1.length != addr2.length)
return false;
for (int i = addr1.length; --i >= 0; )
if (addr1 [i] != addr2 [i])
for (int i = addr1.length; --i >= 0;)
if (addr1[i] != addr2[i])
return false;
return true;
......
......@@ -35,11 +35,11 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package java.net;
import java.util.Arrays;
/**
* @author Michael Koch
* @date August 3, 2002.
......@@ -50,7 +50,6 @@ import java.util.Arrays;
* RFC 1884 (http://www.ietf.org/rfc/rfc1884.txt)
* Status: Believed complete and correct.
*/
public final class Inet6Address extends InetAddress
{
static final long serialVersionUID = 6880410070516793377L;
......@@ -66,9 +65,9 @@ public final class Inet6Address extends InetAddress
* @param addr The IP address
* @param host The hostname
*/
Inet6Address (byte[] addr, String host)
Inet6Address(byte[] addr, String host)
{
super (addr, host);
super(addr, host);
this.ipaddress = addr;
}
......@@ -77,9 +76,9 @@ public final class Inet6Address extends InetAddress
*
* @since 1.1
*/
public boolean isMulticastAddress ()
public boolean isMulticastAddress()
{
return ipaddress [0] == 0xFF;
return ipaddress[0] == 0xFF;
}
/**
......@@ -87,10 +86,9 @@ public final class Inet6Address extends InetAddress
*
* @since 1.4
*/
public boolean isAnyLocalAddress ()
public boolean isAnyLocalAddress()
{
byte[] anylocal = { 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0 };
byte[] anylocal = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
return Arrays.equals(ipaddress, anylocal);
}
......@@ -100,10 +98,9 @@ public final class Inet6Address extends InetAddress
*
* @since 1.4
*/
public boolean isLoopbackAddress ()
public boolean isLoopbackAddress()
{
byte[] loopback = { 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 1 };
byte[] loopback = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
return Arrays.equals(ipaddress, loopback);
}
......@@ -113,9 +110,9 @@ public final class Inet6Address extends InetAddress
*
* @since 1.4
*/
public boolean isLinkLocalAddress ()
public boolean isLinkLocalAddress()
{
return ipaddress [0] == 0xFA;
return ipaddress[0] == 0xFA;
}
/**
......@@ -123,9 +120,9 @@ public final class Inet6Address extends InetAddress
*
* @since 1.4
*/
public boolean isSiteLocalAddress ()
public boolean isSiteLocalAddress()
{
return ipaddress [0] == 0xFB;
return ipaddress[0] == 0xFB;
}
/**
......@@ -133,12 +130,12 @@ public final class Inet6Address extends InetAddress
*
* @since 1.4
*/
public boolean isMCGlobal ()
public boolean isMCGlobal()
{
if (!isMulticastAddress ())
if (! isMulticastAddress())
return false;
return (ipaddress [1] & 0x0F) == 0xE;
return (ipaddress[1] & 0x0F) == 0xE;
}
/**
......@@ -146,12 +143,12 @@ public final class Inet6Address extends InetAddress
*
* @since 1.4
*/
public boolean isMCNodeLocal ()
public boolean isMCNodeLocal()
{
if (!isMulticastAddress ())
if (! isMulticastAddress())
return false;
return (ipaddress [1] & 0x0F) == 0x1;
return (ipaddress[1] & 0x0F) == 0x1;
}
/**
......@@ -159,12 +156,12 @@ public final class Inet6Address extends InetAddress
*
* @since 1.4
*/
public boolean isMCLinkLocal ()
public boolean isMCLinkLocal()
{
if (!isMulticastAddress ())
if (! isMulticastAddress())
return false;
return (ipaddress [1] & 0x0F) == 0x2;
return (ipaddress[1] & 0x0F) == 0x2;
}
/**
......@@ -172,12 +169,12 @@ public final class Inet6Address extends InetAddress
*
* @since 1.4
*/
public boolean isMCSiteLocal ()
public boolean isMCSiteLocal()
{
if (!isMulticastAddress ())
if (! isMulticastAddress())
return false;
return (ipaddress [1] & 0x0F) == 0x5;
return (ipaddress[1] & 0x0F) == 0x5;
}
/**
......@@ -185,12 +182,12 @@ public final class Inet6Address extends InetAddress
*
* @since 1.4
*/
public boolean isMCOrgLocal ()
public boolean isMCOrgLocal()
{
if (!isMulticastAddress ())
if (! isMulticastAddress())
return false;
return (ipaddress [1] & 0x0F) == 0x8;
return (ipaddress[1] & 0x0F) == 0x8;
}
/**
......@@ -198,7 +195,7 @@ public final class Inet6Address extends InetAddress
* network byte order: the highest order byte of the address is i
* n getAddress()[0]
*/
public byte[] getAddress ()
public byte[] getAddress()
{
return ipaddress;
}
......@@ -206,50 +203,49 @@ public final class Inet6Address extends InetAddress
/**
* Returns the IP address string in textual presentation
*/
public String getHostAddress ()
public String getHostAddress()
{
StringBuffer sbuf = new StringBuffer (40);
StringBuffer sbuf = new StringBuffer(40);
for (int i = 0; i < 16; i += 2)
{
int x = ((ipaddress [i] & 0xFF) << 8) | (ipaddress [i + 1] & 0xFF);
boolean empty = sbuf.length () == 0;
int x = ((ipaddress[i] & 0xFF) << 8) | (ipaddress[i + 1] & 0xFF);
boolean empty = sbuf.length() == 0;
if (empty)
{
if (i > 0)
sbuf.append ("::");
sbuf.append("::");
}
else
sbuf.append (':');
sbuf.append(':');
if (x != 0 || i >= 14)
sbuf.append (Integer.toHexString (x));
sbuf.append(Integer.toHexString(x));
}
return sbuf.toString ();
return sbuf.toString();
}
/**
* Returns a hashcode for this IP address
*/
public int hashCode ()
public int hashCode()
{
return super.hashCode ();
return super.hashCode();
}
/**
* Compares this object against the specified object
*/
public boolean equals (Object obj)
public boolean equals(Object obj)
{
if (! (obj instanceof Inet6Address))
return false;
Inet6Address tmp = (Inet6Address) obj;
return super.equals (tmp)
&& this.ipaddress == tmp.ipaddress;
return super.equals(tmp) && this.ipaddress == tmp.ipaddress;
}
/**
......@@ -258,14 +254,14 @@ public final class Inet6Address extends InetAddress
*
* @since 1.4
*/
public boolean isIPv4CompatibleAddress ()
public boolean isIPv4CompatibleAddress()
{
if (ipaddress [0] != 0x00 || ipaddress [1] != 0x00 ||
ipaddress [2] != 0x00 || ipaddress [3] != 0x00 ||
ipaddress [4] != 0x00 || ipaddress [5] != 0x00 ||
ipaddress [6] != 0x00 || ipaddress [7] != 0x00 ||
ipaddress [8] != 0x00 || ipaddress [9] != 0x00 ||
ipaddress [10] != 0x00 || ipaddress [11] != 0x00)
if (ipaddress[0] != 0x00 || ipaddress[1] != 0x00 || ipaddress[2] != 0x00
|| ipaddress[3] != 0x00 || ipaddress[4] != 0x00
|| ipaddress[5] != 0x00 || ipaddress[6] != 0x00
|| ipaddress[7] != 0x00 || ipaddress[8] != 0x00
|| ipaddress[9] != 0x00 || ipaddress[10] != 0x00
|| ipaddress[11] != 0x00)
return false;
return true;
......
......@@ -35,7 +35,6 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package java.net;
import gnu.classpath.Configuration;
......@@ -118,7 +117,7 @@ public class InetAddress implements Serializable
*
* @param ipaddr The IP number of this address as an array of bytes
*/
InetAddress (byte[] address)
InetAddress(byte[] address)
{
this (address, null);
}
......@@ -131,7 +130,7 @@ public class InetAddress implements Serializable
* @param ipaddr The IP number of this address as an array of bytes
* @param hostname The hostname of this IP address.
*/
InetAddress (byte[] address, String hostname)
InetAddress(byte[] address, String hostname)
{
addr = address;
hostName = hostname;
......@@ -153,7 +152,7 @@ public class InetAddress implements Serializable
{
// Mask against high order bits of 1110
if (addr.length == 4)
return (addr [0] & 0xF0) == 0xE0;
return (addr[0] & 0xF0) == 0xE0;
// Mask against high order bits of 11111111
if (addr.length == 16)
......@@ -171,7 +170,7 @@ public class InetAddress implements Serializable
{
// This is the IPv4 implementation.
// Any class derived from InetAddress should override this.
return equals (ANY_IF);
return equals(ANY_IF);
}
/**
......@@ -183,8 +182,7 @@ public class InetAddress implements Serializable
{
// This is the IPv4 implementation.
// Any class derived from InetAddress should override this.
return addr [0] == 0x7F;
return addr[0] == 0x7F;
}
/**
......@@ -196,7 +194,6 @@ public class InetAddress implements Serializable
{
// This is the IPv4 implementation.
// Any class derived from InetAddress should override this.
// XXX: This seems to not exist with IPv4 addresses
return false;
}
......@@ -210,22 +207,18 @@ public class InetAddress implements Serializable
{
// This is the IPv4 implementation.
// Any class derived from InetAddress should override this.
// 10.0.0.0/8
if (addr [0] == 0x0A)
if (addr[0] == 0x0A)
return true;
// XXX: Suns JDK 1.4.1 (on Linux) seems to have a bug here:
// it says 172.16.0.0 - 172.255.255.255 are site local addresses
// 172.16.0.0/12
if (addr [0] == 0xAC
&& (addr [1] & 0xF0) == 0x01)
if (addr[0] == 0xAC && (addr[1] & 0xF0) == 0x01)
return true;
// 192.168.0.0/16
if (addr [0] == 0xC0
&& addr [1] == 0xA8)
if (addr[0] == 0xC0 && addr[1] == 0xA8)
return true;
// XXX: Do we need to check more addresses here ?
......@@ -241,7 +234,6 @@ public class InetAddress implements Serializable
{
// This is the IPv4 implementation.
// Any class derived from InetAddress should override this.
// XXX: This seems to not exist with IPv4 addresses
return false;
}
......@@ -255,7 +247,6 @@ public class InetAddress implements Serializable
{
// This is the IPv4 implementation.
// Any class derived from InetAddress should override this.
// XXX: This seems to not exist with IPv4 addresses
return false;
}
......@@ -269,13 +260,10 @@ public class InetAddress implements Serializable
{
// This is the IPv4 implementation.
// Any class derived from InetAddress should override this.
if (!isMulticastAddress())
if (! isMulticastAddress())
return false;
return (addr [0] == 0xE0
&& addr [1] == 0x00
&& addr [2] == 0x00);
return (addr[0] == 0xE0 && addr[1] == 0x00 && addr[2] == 0x00);
}
/**
......@@ -287,7 +275,6 @@ public class InetAddress implements Serializable
{
// This is the IPv4 implementation.
// Any class derived from InetAddress should override this.
// XXX: This seems to not exist with IPv4 addresses
return false;
}
......@@ -302,7 +289,6 @@ public class InetAddress implements Serializable
{
// This is the IPv4 implementation.
// Any class derived from InetAddress should override this.
// XXX: This seems to not exist with IPv4 addresses
return false;
}
......@@ -393,7 +379,8 @@ public class InetAddress implements Serializable
*/
public String getHostAddress()
{
StringBuffer sb = new StringBuffer (40);
StringBuffer sb = new StringBuffer(40);
int len = addr.length;
int i = 0;
......@@ -458,7 +445,7 @@ public class InetAddress implements Serializable
int len = addr.length;
int i = len > 4 ? len - 4 : 0;
for ( ; i < len; i++)
for (; i < len; i++)
hash = (hash << 8) | (addr[i] & 0xFF);
return hash;
......@@ -474,7 +461,7 @@ public class InetAddress implements Serializable
* @return true if the passed in object's address is equal to this one's,
* false otherwise
*/
public boolean equals (Object obj)
public boolean equals(Object obj)
{
if (! (obj instanceof InetAddress))
return false;
......@@ -491,7 +478,7 @@ public class InetAddress implements Serializable
return false;
for (int i = 0; i < addr.length; i++)
if (addr [i] != addr2 [i])
if (addr[i] != addr2[i])
return false;
return true;
......@@ -529,10 +516,10 @@ public class InetAddress implements Serializable
*
* @since 1.4
*/
public static InetAddress getByAddress (byte[] addr)
public static InetAddress getByAddress(byte[] addr)
throws UnknownHostException
{
return getByAddress (null, addr);
return getByAddress(null, addr);
}
/**
......@@ -546,16 +533,16 @@ public class InetAddress implements Serializable
*
* @since 1.4
*/
public static InetAddress getByAddress (String host, byte[] addr)
public static InetAddress getByAddress(String host, byte[] addr)
throws UnknownHostException
{
if (addr.length == 4)
return new Inet4Address (addr, host);
return new Inet4Address(addr, host);
if (addr.length == 16)
return new Inet6Address (addr, host);
return new Inet6Address(addr, host);
throw new UnknownHostException ("IP address has illegal length");
throw new UnknownHostException("IP address has illegal length");
}
/**
......@@ -586,19 +573,19 @@ public class InetAddress implements Serializable
* @exception SecurityException If a security manager exists and its
* checkConnect method doesn't allow the operation
*/
public static InetAddress getByName (String hostname)
public static InetAddress getByName(String hostname)
throws UnknownHostException
{
SecurityManager s = System.getSecurityManager();
if (s != null)
s.checkConnect (hostname, -1);
s.checkConnect(hostname, -1);
// Default to current host if necessary
if (hostname == null || hostname.length() == 0)
return getLocalHost();
// Assume that the host string is an IP address
byte[] address = aton (hostname);
byte[] address = aton(hostname);
if (address != null)
{
if (address.length == 4)
......@@ -621,8 +608,8 @@ public class InetAddress implements Serializable
}
// Try to resolve the host by DNS
InetAddress[] addresses = getAllByName (hostname);
return addresses [0];
InetAddress[] addresses = getAllByName(hostname);
return addresses[0];
}
/**
......@@ -632,7 +619,7 @@ public class InetAddress implements Serializable
* dotted decimal format such as "127.0.0.1". If the value is null, the
* hostname of the local machine is supplied by default.
*
* @param @param hostname The name of the desired host, or null for the
* @param hostname The name of the desired host, or null for the
* local machine.
*
* @return All addresses of the host as an array of InetAddress objects.
......@@ -642,12 +629,12 @@ public class InetAddress implements Serializable
* @exception SecurityException If a security manager exists and its
* checkConnect method doesn't allow the operation
*/
public static InetAddress[] getAllByName (String hostname)
public static InetAddress[] getAllByName(String hostname)
throws UnknownHostException
{
SecurityManager s = System.getSecurityManager();
if (s != null)
s.checkConnect (hostname, -1);
s.checkConnect(hostname, -1);
// Check if hostname is an IP address
byte[] address = aton (hostname);
......@@ -748,15 +735,15 @@ public class InetAddress implements Serializable
// FIXME: implement this
}
private void readObject (ObjectInputStream ois)
private void readObject(ObjectInputStream ois)
throws IOException, ClassNotFoundException
{
ois.defaultReadObject();
addr = new byte [4];
addr [3] = (byte) address;
addr = new byte[4];
addr[3] = (byte) address;
for (int i = 2; i >= 0; --i)
addr [i] = (byte) (address >>= 8);
addr[i] = (byte) (address >>= 8);
// Ignore family from serialized data. Since the saved address is 32 bits
// the deserialized object will have an IPv4 address i.e. AF_INET family.
......@@ -766,7 +753,7 @@ public class InetAddress implements Serializable
family = getFamily (addr);
}
private void writeObject (ObjectOutputStream oos) throws IOException
private void writeObject(ObjectOutputStream oos) throws IOException
{
// Build a 32 bit address from the last 4 bytes of a 4 byte IPv4 address
// or a 16 byte IPv6 address.
......@@ -774,7 +761,7 @@ public class InetAddress implements Serializable
int i = len - 4;
for (; i < len; i++)
address = address << 8 | (((int) addr [i]) & 0xFF);
address = address << 8 | (((int) addr[i]) & 0xFF);
oos.defaultWriteObject();
}
......
......@@ -37,6 +37,7 @@ exception statement from your version. */
package java.net;
/**
* InetSocketAddress instances represent socket addresses
* in the java.nio package. They encapsulate a InetAddress and
......@@ -44,7 +45,6 @@ package java.net;
*
* @since 1.4
*/
public class InetSocketAddress extends SocketAddress
{
/**
......@@ -79,14 +79,14 @@ public class InetSocketAddress extends SocketAddress
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();
}
/**
......@@ -96,17 +96,16 @@ public class InetSocketAddress extends SocketAddress
*
* @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,10 +113,10 @@ public class InetSocketAddress extends SocketAddress
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;
......@@ -140,11 +139,10 @@ public class InetSocketAddress extends SocketAddress
*
* @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;
......@@ -152,9 +150,9 @@ public class InetSocketAddress extends SocketAddress
if (addr == null && sa.addr != null)
return false;
else if (addr == null && sa.addr == null)
return hostname.equals (sa.hostname) && sa.port == port;
return hostname.equals(sa.hostname) && sa.port == port;
else
return addr.equals (sa.addr) && sa.port == port;
return addr.equals(sa.addr) && sa.port == port;
}
return false;
......
......@@ -35,24 +35,24 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package java.net;
import java.io.IOException;
import java.security.cert.Certificate;
import java.util.jar.Attributes;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.jar.JarInputStream;
import java.util.jar.Manifest;
import java.util.zip.ZipEntry;
import java.security.cert.Certificate;
/**
* This abstract class represents a common superclass for implementations
* of jar URL's. A jar URL is a special type of URL that allows JAR
* files on remote systems to be accessed. It has the form:
* <p>
* jar:<standard URL pointing to jar file>!/file/within/jarfile
* jar:&lt;standard URL pointing to jar filei&gt;!/file/within/jarfile
* <p> for example:
* <p>
* jar:http://www.urbanophile.com/java/foo.jar!/com/urbanophile/bar.class
......@@ -96,30 +96,29 @@ public abstract class JarURLConnection extends URLConnection
/**
* Creates a JarURLConnection from an URL object
*
* @param URL url The URL object for this connection.
* @param url The URL object for this connection.
*
* @exception MalformedURLException If url is invalid
*
* @specnote This constructor is protected since JDK 1.4
*/
protected JarURLConnection (URL url)
throws MalformedURLException
protected JarURLConnection(URL url) throws MalformedURLException
{
super (url);
super(url);
if (!url.getProtocol().equals ("jar"))
throw new MalformedURLException (url + ": Not jar protocol.");
if (! url.getProtocol().equals("jar"))
throw new MalformedURLException(url + ": Not jar protocol.");
String spec = url.getFile();
int bang = spec.indexOf ("!/");
int bang = spec.indexOf("!/");
if (bang == -1)
throw new MalformedURLException (url + ": No `!/' in spec.");
throw new MalformedURLException(url + ": No `!/' in spec.");
// Extract the url for the jar itself.
jarFileURL = new URL (spec.substring (0, bang));
jarFileURL = new URL(spec.substring(0, bang));
// Get the name of the entry, if any.
entryName = spec.length() == (bang + 2) ? null : spec.substring (bang + 2);
entryName = spec.length() == (bang + 2) ? null : spec.substring(bang + 2);
}
/**
......@@ -128,7 +127,7 @@ public abstract class JarURLConnection extends URLConnection
*
* @return The remote URL
*/
public URL getJarFileURL ()
public URL getJarFileURL()
{
return jarFileURL;
}
......@@ -140,7 +139,7 @@ public abstract class JarURLConnection extends URLConnection
*
* @return The entry name.
*/
public String getEntryName ()
public String getEntryName()
{
return entryName;
}
......@@ -152,7 +151,7 @@ public abstract class JarURLConnection extends URLConnection
*
* @exception IOException If an error occurs
*/
public JarEntry getJarEntry () throws IOException
public JarEntry getJarEntry() throws IOException
{
JarFile jarfile = null;
......@@ -203,7 +202,7 @@ public abstract class JarURLConnection extends URLConnection
*
* @exception IOException If an error occurs
*/
public abstract JarFile getJarFile () throws IOException;
public abstract JarFile getJarFile() throws IOException;
/**
* Returns an array of Certificate objects for the jar file entry specified
......@@ -213,7 +212,7 @@ public abstract class JarURLConnection extends URLConnection
*
* @exception IOException If an error occurs
*/
public Certificate[] getCertificates () throws IOException
public Certificate[] getCertificates() throws IOException
{
JarEntry entry = getJarEntry();
......@@ -228,7 +227,7 @@ public abstract class JarURLConnection extends URLConnection
*
* @exception IOException If an error occurs
*/
public Attributes getMainAttributes () throws IOException
public Attributes getMainAttributes() throws IOException
{
Manifest manifest = getManifest();
......@@ -244,7 +243,7 @@ public abstract class JarURLConnection extends URLConnection
*
* @exception IOException If an error occurs
*/
public Attributes getAttributes () throws IOException
public Attributes getAttributes() throws IOException
{
JarEntry entry = getJarEntry();
......@@ -259,7 +258,7 @@ public abstract class JarURLConnection extends URLConnection
*
* @exception IOException If an error occurs
*/
public Manifest getManifest () throws IOException
public Manifest getManifest() throws IOException
{
JarFile file = getJarFile();
......
......@@ -39,6 +39,7 @@ package java.net;
import java.io.IOException;
/**
* This exception indicates that a URL passed to an object was not in a
* valid format.
......
......@@ -41,12 +41,12 @@ package java.net;
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).
......@@ -189,7 +189,7 @@ public class MulticastSocket extends DatagramSocket
/**
* 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
*
......@@ -203,13 +203,13 @@ public class MulticastSocket extends DatagramSocket
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);
}
/**
......@@ -223,15 +223,14 @@ public class MulticastSocket extends DatagramSocket
*
* @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;
}
......@@ -255,11 +254,14 @@ public class MulticastSocket extends DatagramSocket
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
*
......@@ -270,7 +272,7 @@ public class MulticastSocket extends DatagramSocket
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();
......@@ -323,9 +325,9 @@ public class MulticastSocket extends DatagramSocket
}
/**
* Joins the specified mulitcast group.
* Joins the specified multicast group.
*
* @param addr The address of the group to join
* @param mcastaddr The address of the group to join
*
* @exception IOException If an error occurs
* @exception SecurityException If a security manager exists and its
......@@ -349,7 +351,7 @@ public class MulticastSocket extends DatagramSocket
/**
* 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
......@@ -395,18 +397,18 @@ public class MulticastSocket extends DatagramSocket
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");
if (! tmp.getAddress().isMulticastAddress())
throw new IOException("Not a Multicast address");
SecurityManager s = System.getSecurityManager ();
SecurityManager s = System.getSecurityManager();
if (s != null)
s.checkMulticast (tmp.getAddress ());
s.checkMulticast(tmp.getAddress());
getImpl().joinGroup (mcastaddr, netIf);
getImpl().joinGroup(mcastaddr, netIf);
}
/**
......@@ -434,14 +436,14 @@ public class MulticastSocket extends DatagramSocket
InetSocketAddress tmp = (InetSocketAddress) mcastaddr;
if (! tmp.getAddress ().isMulticastAddress ())
throw new IOException ("Not a Multicast address");
if (! tmp.getAddress().isMulticastAddress())
throw new IOException("Not a Multicast address");
SecurityManager s = System.getSecurityManager ();
SecurityManager s = System.getSecurityManager();
if (s != null)
s.checkMulticast (tmp.getAddress ());
s.checkMulticast(tmp.getAddress());
getImpl().leaveGroup (mcastaddr, netIf);
getImpl().leaveGroup(mcastaddr, netIf);
}
/**
......@@ -458,7 +460,8 @@ public class MulticastSocket extends DatagramSocket
*
* @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 @@ public class MulticastSocket extends DatagramSocket
SecurityManager s = System.getSecurityManager();
if (s != null)
{
InetAddress addr = p.getAddress();
InetAddress addr = packet.getAddress();
if (addr.isMulticastAddress())
s.checkPermission (new SocketPermission
(addr.getHostName () + p.getPort (),
s.checkPermission(new SocketPermission(addr.getHostName()
+ packet.getPort(),
"accept,connect"));
else
s.checkConnect(addr.getHostAddress(), p.getPort());
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
}
......@@ -39,6 +39,7 @@ package java.net;
import java.security.BasicPermission;
/**
* This class is used to model miscellaneous network permissions. It is
* a subclass of <code>BasicPermission</code>. This means that it models a
......@@ -50,11 +51,11 @@ import java.security.BasicPermission;
* <ul>
* <li>setDefaultAuthenticator - Grants the ability to install a facility
* to collect username and password information when requested by a
* web site or proxy server.
* web site or proxy server.</li>
* <li>requestPasswordAuthentication - Grants the ability to ask the
* authentication facility for the user's password.
* authentication facility for the user's password.</li>
* <li>specifyStreamHandler - Grants the permission to specify the
* stream handler class used when loading from a URL.
* stream handler class used when loading from a URL.</li>
* </ul>
*
* @author Aaron M. Renn (arenn@urbanophile.com)
......
......@@ -41,6 +41,7 @@ import gnu.classpath.Configuration;
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
......@@ -56,23 +57,20 @@ public final class NetworkInterface
static
{
if (Configuration.INIT_LOAD_LIBRARY)
{
System.loadLibrary ("javanet");
}
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,7 +78,7 @@ public final class NetworkInterface
*
* @return The name of the interface.
*/
public String getName ()
public String getName()
{
return name;
}
......@@ -95,30 +93,30 @@ public final class NetworkInterface
*
* @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 @@ public final class NetworkInterface
*
* @return The display name of the interface
*/
public String getDisplayName ()
public String getDisplayName()
{
return name;
}
......@@ -139,21 +137,20 @@ public final class NetworkInterface
* @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 ();
NetworkInterface tmp = (NetworkInterface) e.nextElement();
if (name.equals (tmp.getName ()))
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 @@ public final class NetworkInterface
* @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 ();
Vector networkInterfaces = getRealNetworkInterfaces();
for (Enumeration interfaces = networkInterfaces.elements ();
interfaces.hasMoreElements (); )
for (Enumeration interfaces = networkInterfaces.elements();
interfaces.hasMoreElements();)
{
NetworkInterface tmp = (NetworkInterface) interfaces.nextElement ();
NetworkInterface tmp = (NetworkInterface) interfaces.nextElement();
for (Enumeration addresses = tmp.inetAddresses.elements ();
addresses.hasMoreElements (); )
for (Enumeration addresses = tmp.inetAddresses.elements();
addresses.hasMoreElements();)
{
if (addr.equals ((InetAddress) addresses.nextElement ()))
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 @@ public final class NetworkInterface
*
* @exception SocketException If an error occurs
*/
public static Enumeration getNetworkInterfaces ()
throws SocketException
public static Enumeration getNetworkInterfaces() throws SocketException
{
Vector networkInterfaces = getRealNetworkInterfaces();
......@@ -207,43 +202,42 @@ public final class NetworkInterface
*
* @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;
......
......@@ -35,9 +35,9 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package java.net;
/**
* This exception indicates that there is no TCP/IP route to the requested
* host. This is often due to a misconfigured routing table.
......
......@@ -37,6 +37,7 @@ exception statement from your version. */
package java.net;
/**
* This class serves a container for username/password pairs.
*
......@@ -91,7 +92,7 @@ public final class PasswordAuthentication
*/
public String getUserName()
{
return(username);
return (username);
}
/**
......@@ -101,8 +102,6 @@ public final class PasswordAuthentication
*/
public char[] getPassword()
{
return(password);
return (password);
}
} // class PasswordAuthentication
......@@ -37,6 +37,7 @@ exception statement from your version. */
package java.net;
/**
* This exception signals that an ICMP port unreachable datagram has been
* received.
......@@ -69,4 +70,3 @@ public class PortUnreachableException extends SocketException
super(message);
}
} // class PortUnreachableException
......@@ -39,6 +39,7 @@ package java.net;
import java.io.IOException;
/**
* This exception indicates that some sort of low level protocol
* exception occurred. Look in the descriptive message (if any) for
......
......@@ -39,6 +39,7 @@ package java.net;
import java.io.Serializable;
/**
* Abstract base class for InetSocketAddress.
* InetSocketAddress is to my knowledge the only derived
......
......@@ -39,6 +39,7 @@ package java.net;
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
......
......@@ -36,14 +36,14 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
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 @@ public abstract class SocketImpl implements SocketOptions
*
* @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 @@ public abstract class SocketImpl implements SocketOptions
*
* @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 @@ public abstract class SocketImpl implements SocketOptions
*
* @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()
......@@ -258,15 +272,17 @@ public abstract class SocketImpl implements SocketOptions
*
* @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 <code>String</code> representing the remote host and port of
......@@ -276,10 +292,9 @@ public abstract class SocketImpl implements SocketOptions
*/
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 @@ public abstract class SocketImpl implements SocketOptions
*
* @exception IOException if an error occurs
*/
protected void shutdownInput () throws IOException
protected void shutdownInput() throws IOException
{
throw new IOException ("Not implemented in this socket class");
throw new IOException("Not implemented in this socket class");
}
/**
......@@ -299,8 +314,8 @@ public abstract class SocketImpl implements SocketOptions
*
* @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");
}
}
......@@ -35,13 +35,12 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
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 <code>SocketImpl</code>
* object. This should not be needed by ordinary applications.
......@@ -57,6 +56,4 @@ public interface SocketImplFactory
* @return A <code>SocketImpl</code> object
*/
SocketImpl createSocketImpl();
} // interface SocketImplFactory
......@@ -38,11 +38,11 @@ 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 is used by <code>SocketImpl</code> and
* <code>DatagramSocketImpl</code> to implement options
......@@ -163,6 +163,4 @@ public interface SocketOptions
* @exception SocketException If an error occurs
*/
Object getOption(int optionId) throws SocketException;
} // interface SocketOptions
/* SocketPermission.java -- Class modeling permissions for socket operations
Copyright (C) 1998, 2000, 2001, 2002 Free Software Foundation, Inc.
Copyright (C) 1998, 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
......@@ -41,6 +41,7 @@ import java.io.Serializable;
import java.security.Permission;
import java.security.PermissionCollection;
/**
* This class models a specific set of permssions for connecting to a
* host. There are two elements to this, the host/port combination and
......@@ -64,18 +65,20 @@ import java.security.PermissionCollection;
* value for a port (respectively) is used by default. Here are some
* examples:
* <p><ul>
* <li>8080 - Represents port 8080 only
* <li>2000-3000 - Represents ports 2000 through 3000 inclusive
* <li>-4000 - Represents ports 0 through 4000 inclusive
* <li>1024- - Represents ports 1024 through 65535 inclusive
* <li>8080 - Represents port 8080 only</li>
* <li>2000-3000 - Represents ports 2000 through 3000 inclusive</li>
* <li>-4000 - Represents ports 0 through 4000 inclusive</li>
* <li>1024- - Represents ports 1024 through 65535 inclusive</li>
* </ul><p>
* The permission list is a comma separated list of individual permissions.
* These individual permissions are:
* <p>
* accept<br>
* connect<br>
* listen<br>
* resolve<br>
* <pre>
* accept
* connect
* listen
* resolve
* </pre>
* <p>
* The "listen" permission is only relevant if the host is localhost. If
* any permission at all is specified, then resolve permission is implied to
......@@ -103,12 +106,12 @@ import java.security.PermissionCollection;
*
* @author Aaron M. Renn (arenn@urbanophile.com)
*/
public final class SocketPermission extends Permission
implements Serializable
public final class SocketPermission extends Permission implements Serializable
{
static final long serialVersionUID = -7204263841984476862L;
// FIXME: Needs serialization work, including readObject/writeObject methods.
/**
* A hostname/port combination as described above
*/
......@@ -147,7 +150,7 @@ public final class SocketPermission extends Permission
*/
public boolean equals(Object obj)
{
if (!(obj instanceof SocketPermission))
if (! (obj instanceof SocketPermission))
return (false);
if (((SocketPermission) obj).hostport.equals(hostport))
......@@ -231,20 +234,22 @@ public final class SocketPermission extends Permission
/**
* Returns true if the permission object passed it is implied by the
* this permission. This will be true if
* <p><ul>
* <li>The argument is of type <code>SocketPermission</code>
* <li>The actions list of the argument are in this object's actions
* <li>The port range of the argument is within this objects port range
* <li>The hostname is equal to or a subset of this objects hostname
* this permission. This will be true if:
*
* <ul>
* <li>The argument is of type <code>SocketPermission</code></li>
* <li>The actions list of the argument are in this object's actions</li>
* <li>The port range of the argument is within this objects port range</li>
* <li>The hostname is equal to or a subset of this objects hostname</li>
* </ul>
* <p>
* The argument's hostname will be a subset of this object's hostname if:
* <p><ul>
* <li>The argument's hostname or IP address is equal to this object's.
* <li>The argument's canonical hostname is equal to this object's.
*
* <p>The argument's hostname will be a subset of this object's hostname if:</p>
*
* <ul>
* <li>The argument's hostname or IP address is equal to this object's.</li>
* <li>The argument's canonical hostname is equal to this object's.</li>
* <li>The argument's canonical name matches this domains hostname with
* wildcards
* wildcards</li>
* </ul>
*
* @param perm The <code>Permission</code> to check against
......@@ -266,12 +271,20 @@ public final class SocketPermission extends Permission
String ourlist = getActions();
String theirlist = p.getActions();
if (!ourlist.startsWith(theirlist))
if (! ourlist.startsWith(theirlist))
return (false);
// Now check ports
int ourfirstport = 0, ourlastport = 0, theirfirstport = 0, theirlastport =
0;
int ourfirstport = 0;
// Now check ports
int ourlastport = 0;
// Now check ports
int theirfirstport = 0;
// Now check ports
int theirlastport = 0;
// Get ours
if (hostport.indexOf(":") == -1)
......@@ -299,8 +312,7 @@ public final class SocketPermission extends Permission
ourlastport = Integer.parseInt(range);
else
ourlastport =
Integer.parseInt(range.
substring(range.indexOf("-") + 1,
Integer.parseInt(range.substring(range.indexOf("-") + 1,
range.length()));
}
......@@ -329,8 +341,7 @@ public final class SocketPermission extends Permission
theirlastport = Integer.parseInt(range);
else
theirlastport =
Integer.parseInt(range.
substring(range.indexOf("-") + 1,
Integer.parseInt(range.substring(range.indexOf("-") + 1,
range.length()));
}
......@@ -339,7 +350,10 @@ public final class SocketPermission extends Permission
return (false);
// Finally we can check the hosts
String ourhost, theirhost;
String ourhost;
// Finally we can check the hosts
String theirhost;
// Get ours
if (hostport.indexOf(":") == -1)
......@@ -358,7 +372,10 @@ public final class SocketPermission extends Permission
return (true);
// Try the canonical names
String ourcanonical = null, theircanonical = null;
String ourcanonical = null;
// Try the canonical names
String theircanonical = null;
try
{
ourcanonical = InetAddress.getByName(ourhost).getHostName();
......
......@@ -39,6 +39,7 @@ package java.net;
import java.io.InterruptedIOException;
/**
* This exception signals that a socket read or accept timed out.
*
......
......@@ -37,6 +37,7 @@ exception statement from your version. */
package java.net;
/**
* This exception is thrown when a String cannot be parsed as a URI.
*
......@@ -137,7 +138,7 @@ public class URISyntaxException extends Exception
*/
public String getMessage()
{
return super.getMessage() + (index >= 0 ? " at index " + index : "")
+ ": " + input;
return (super.getMessage() + (index >= 0 ? " at index " + index : "")
+ ": " + input);
}
}
......@@ -35,18 +35,18 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package java.net;
import gnu.java.net.URLParseError;
import java.io.InputStream;
import java.io.IOException;
import java.io.Serializable;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.HashMap;
import java.util.StringTokenizer;
/*
* Written using on-line Java Platform 1.2 API Specification, as well
* as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
......@@ -171,7 +171,6 @@ public final class URL implements Serializable
* where we keep track of it.
*/
private static URLStreamHandlerFactory factory;
private static final long serialVersionUID = -7627629688361524110L;
/**
......@@ -187,7 +186,7 @@ public final class URL implements Serializable
static
{
String s = System.getProperty ("gnu.java.net.nocache_protocol_handlers");
String s = System.getProperty("gnu.java.net.nocache_protocol_handlers");
if (s == null)
cache_handlers = true;
......@@ -231,7 +230,6 @@ public final class URL implements Serializable
this(protocol, host, -1, file, null);
}
/**
* This method initializes a new instance of <code>URL</code> with the
* specified protocol, host, port, and file. Additionally, this method
......@@ -254,9 +252,8 @@ public final class URL implements Serializable
*
* @since 1.2
*/
public URL (String protocol, String host, int port, String file,
URLStreamHandler ph)
throws MalformedURLException
public URL(String protocol, String host, int port, String file,
URLStreamHandler ph) throws MalformedURLException
{
if (protocol == null)
throw new MalformedURLException("null protocol");
......@@ -266,7 +263,7 @@ public final class URL implements Serializable
{
SecurityManager s = System.getSecurityManager();
if (s != null)
s.checkPermission (new NetPermission ("specifyStreamHandler"));
s.checkPermission(new NetPermission("specifyStreamHandler"));
this.ph = ph;
}
......@@ -274,8 +271,8 @@ public final class URL implements Serializable
this.ph = getURLStreamHandler(protocol);
if (this.ph == null)
throw new MalformedURLException (
"Protocol handler not found: " + protocol);
throw new MalformedURLException("Protocol handler not found: "
+ protocol);
this.host = host;
this.port = port;
......@@ -380,13 +377,13 @@ public final class URL implements Serializable
// right after the "://". The second colon is for an optional port value
// and implies that the host from the context is used if available.
int colon;
if ((colon = spec.indexOf("://", 1)) > 0 &&
! spec.regionMatches(colon, "://:", 0, 4))
if ((colon = spec.indexOf("://", 1)) > 0
&& ! spec.regionMatches(colon, "://:", 0, 4))
context = null;
int slash;
if ((colon = spec.indexOf(':')) > 0 &&
(colon < (slash = spec.indexOf('/')) || slash < 0))
if ((colon = spec.indexOf(':')) > 0
&& (colon < (slash = spec.indexOf('/')) || slash < 0))
{
// Protocol specified in spec string.
protocol = spec.substring(0, colon).toLowerCase();
......@@ -415,14 +412,15 @@ public final class URL implements Serializable
authority = context.authority;
}
else // Protocol NOT specified in spec. and no context available.
throw new
MalformedURLException("Absolute URL required with null context");
throw new MalformedURLException("Absolute URL required with null context");
if (ph != null)
{
SecurityManager s = System.getSecurityManager ();
SecurityManager s = System.getSecurityManager();
if (s != null)
s.checkPermission (new NetPermission ("specifyStreamHandler"));
s.checkPermission(new NetPermission("specifyStreamHandler"));
this.ph = ph;
}
......@@ -460,16 +458,16 @@ public final class URL implements Serializable
* exactly (ie, protocol, host, port, file, and ref). Overrides
* Object.equals(), implemented by calling the equals method of the handler.
*
* @param url The URL to compare with
* @param obj The URL to compare with
*
* @return true if the URL is equal, false otherwise
*/
public boolean equals (Object obj)
public boolean equals(Object obj)
{
if (! (obj instanceof URL))
return false;
return ph.equals (this, (URL) obj);
return ph.equals(this, (URL) obj);
}
/**
......@@ -602,7 +600,7 @@ public final class URL implements Serializable
*
* @return the user at a particular host or null when no user defined.
*/
public String getUserInfo ()
public String getUserInfo()
{
int at = (host == null) ? -1 : host.indexOf('@');
return at < 0 ? null : host.substring(0, at);
......@@ -614,7 +612,7 @@ public final class URL implements Serializable
*
* @return the query part of the file, or null when there is no query part.
*/
public String getQuery ()
public String getQuery()
{
int quest = (file == null) ? -1 : file.indexOf('?');
return quest < 0 ? null : file.substring(quest + 1, file.length());
......@@ -630,7 +628,7 @@ public final class URL implements Serializable
if (hashCode != 0)
return hashCode; // Use cached value if available.
else
return ph.hashCode (this);
return ph.hashCode(this);
}
/**
......@@ -670,9 +668,9 @@ public final class URL implements Serializable
*
* @return true if URL matches this URL's file, false otherwise
*/
public boolean sameFile(URL other)
public boolean sameFile(URL url)
{
return ph.sameFile(this, other);
return ph.sameFile(this, url);
}
/**
......@@ -720,9 +718,8 @@ public final class URL implements Serializable
*
* @since 1.3
*/
protected void set(String protocol, String host, int port,
String authority, String userInfo,
String path, String query, String ref)
protected void set(String protocol, String host, int port, String authority,
String userInfo, String path, String query, String ref)
{
// TBD: Theoretically, a poorly written StreamHandler could pass an
// invalid protocol. It will cause the handler to be set to null
......@@ -754,8 +751,7 @@ public final class URL implements Serializable
* @exception SecurityException If a security manager exists and its
* checkSetFactory method doesn't allow the operation
*/
public static synchronized void
setURLStreamHandlerFactory(URLStreamHandlerFactory fac)
public static synchronized void setURLStreamHandlerFactory(URLStreamHandlerFactory fac)
{
if (factory != null)
throw new Error("URLStreamHandlerFactory already set");
......@@ -801,15 +797,14 @@ public final class URL implements Serializable
*
* @return A URLStreamHandler for this protocol, or null when not found.
*/
private static synchronized URLStreamHandler
getURLStreamHandler (String protocol)
private static synchronized URLStreamHandler getURLStreamHandler(String protocol)
{
URLStreamHandler ph = null;
// First, see if a protocol handler is in our cache.
if (cache_handlers)
{
if ((ph = (URLStreamHandler) ph_cache.get (protocol)) != null)
if ((ph = (URLStreamHandler) ph_cache.get(protocol)) != null)
return ph;
}
......@@ -855,18 +850,18 @@ public final class URL implements Serializable
ph_search_path = DEFAULT_SEARCH_PATH;
// Finally loop through our search path looking for a match.
StringTokenizer pkgPrefix = new StringTokenizer (ph_search_path, "|");
StringTokenizer pkgPrefix = new StringTokenizer(ph_search_path, "|");
do
{
String clsName = (pkgPrefix.nextToken() + "."
+ protocol + ".Handler");
String clsName =
(pkgPrefix.nextToken() + "." + protocol + ".Handler");
try
{
Object obj = Class.forName (clsName).newInstance();
Object obj = Class.forName(clsName).newInstance();
if (!(obj instanceof URLStreamHandler))
if (! (obj instanceof URLStreamHandler))
continue;
else
ph = (URLStreamHandler) obj;
......@@ -882,10 +877,9 @@ public final class URL implements Serializable
}
// Update the hashtable with the new protocol handler.
if (ph != null
&& cache_handlers)
if (ph != null && cache_handlers)
if (ph instanceof URLStreamHandler)
ph_cache.put (protocol, ph);
ph_cache.put(protocol, ph);
else
ph = null;
......
......@@ -39,6 +39,7 @@ package java.net;
import java.io.UnsupportedEncodingException;
/**
* This utility class contains static methods that converts a
* string encoded in the x-www-form-urlencoded format to the original
......@@ -65,7 +66,7 @@ public class URLDecoder
/**
* Public contructor. Note that this class has only static methods.
*/
public URLDecoder ()
public URLDecoder()
{
}
......@@ -134,12 +135,12 @@ public class URLDecoder
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 @@ public class URLDecoder
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 @@ public class URLDecoder
return result.toString();
}
} // class URLDecoder
......@@ -39,13 +39,14 @@ package java.net;
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
......@@ -115,7 +116,7 @@ public class URLEncoder
StringBuffer result = new StringBuffer(length);
while (true)
{
while ( i < length && isSafe(s.charAt(i)) )
while (i < length && isSafe(s.charAt(i)))
i++;
// Safe character can just be added
......@@ -134,12 +135,12 @@ public class URLEncoder
// Get all unsafe characters
start = i;
char c;
while ( i < length && (c = s.charAt(i)) != ' ' && !isSafe(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);
String unsafe = s.substring(start, i);
byte[] bytes = unsafe.getBytes(encoding);
for (int j = 0; j < bytes.length; j++)
{
result.append('%');
......@@ -160,17 +161,18 @@ public class URLEncoder
*/
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 @@ public class URLEncoder
* leading 0.
*/
private static final String hex = "0123456789ABCDEF";
} // class URLEncoder
}
......@@ -37,12 +37,12 @@ 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 contains one method which maps the protocol portion of
* a URL (eg, "http" in "http://www.urbanophile.com/arenn/") to a
......@@ -61,7 +61,5 @@ public interface URLStreamHandlerFactory
*
* @return The <code>URLStreamHandler</code> for the specified protocol
*/
URLStreamHandler createURLStreamHandler (String protocol);
URLStreamHandler createURLStreamHandler(String protocol);
} // interface URLStreamHandlerFactory
......@@ -39,6 +39,7 @@ package java.net;
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
......
......@@ -39,6 +39,7 @@ package java.net;
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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment