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
This commit is contained in:
parent
cf6f7d5589
commit
f6d49f66ec
45 changed files with 1979 additions and 1905 deletions
|
@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify
|
|||
it under the terms of the GNU General Public License as published by
|
||||
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 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
|
||||
|
@ -54,25 +55,22 @@ import java.util.Vector;
|
|||
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 @@ public final class NetworkInterface
|
|||
*
|
||||
* @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 <code>InetAddresses</code> are returned where the security manager
|
||||
* Only <code>InetAddresses</code> 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 @@ 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 ();
|
||||
|
||||
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 @@ 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 ();
|
||||
|
||||
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 @@ 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();
|
||||
|
||||
|
@ -206,44 +201,43 @@ public final class NetworkInterface
|
|||
* 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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue