2002-10-04 Michael Koch <konqueror@gmx.de>

* java/net/InetAddress.java:
	(isMulticastAddress): Added documentation.
	(getHostAddress): Added documentation.
	(toString): Added documentation.
	(getByAddress): Fixed documentation.
	(getByName): Added documentation.
	(getAllByName): Added documentation.
	(getLocalHost): Added documentation.

From-SVN: r57814
This commit is contained in:
Michael Koch 2002-10-04 08:49:26 +00:00 committed by Michael Koch
parent 9c826022f9
commit cc40c1e130
2 changed files with 50 additions and 2 deletions

View file

@ -1,3 +1,14 @@
2002-10-04 Michael Koch <konqueror@gmx.de>
* java/net/InetAddress.java:
(isMulticastAddress): Added documentation.
(getHostAddress): Added documentation.
(toString): Added documentation.
(getByAddress): Fixed documentation.
(getByName): Added documentation.
(getAllByName): Added documentation.
(getLocalHost): Added documentation.
2002-10-04 Michael Koch <konqueror@gmx.de> 2002-10-04 Michael Koch <konqueror@gmx.de>
* java/beans/beancontext/BeanContextChildSupport.java: * java/beans/beancontext/BeanContextChildSupport.java:

View file

@ -12,6 +12,7 @@ package java.net;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;
import java.io.ObjectOutputStream; import java.io.ObjectOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.Serializable;
/** /**
* @author Per Bothner * @author Per Bothner
@ -27,7 +28,7 @@ import java.io.IOException;
* @specnote This class is not final since JK 1.4 * @specnote This class is not final since JK 1.4
*/ */
public class InetAddress implements java.io.Serializable public class InetAddress implements Serializable
{ {
// The Serialized Form specifies that an int 'address' is saved/restored. // The Serialized Form specifies that an int 'address' is saved/restored.
// This class uses a byte array internally so we'll just do the conversion // This class uses a byte array internally so we'll just do the conversion
@ -80,6 +81,11 @@ public class InetAddress implements java.io.Serializable
family = getFamily (address); family = getFamily (address);
} }
/**
* Utility routine to check if the InetAddress is an IP multicast address
*
* @since 1.1
*/
public boolean isMulticastAddress () public boolean isMulticastAddress ()
{ {
int len = addr.length; int len = addr.length;
@ -127,6 +133,11 @@ public class InetAddress implements java.io.Serializable
} }
} }
/**
* Returns the IP address as string
*
* @since 1.0.2
*/
public String getHostAddress () public String getHostAddress ()
{ {
StringBuffer sbuf = new StringBuffer(40); StringBuffer sbuf = new StringBuffer(40);
@ -204,6 +215,9 @@ public class InetAddress implements java.io.Serializable
return true; return true;
} }
/**
* Returns then <code>InetAddress</code> as string
*/
public String toString() public String toString()
{ {
return getHostName()+'/'+getHostAddress(); return getHostName()+'/'+getHostAddress();
@ -215,7 +229,7 @@ public class InetAddress implements java.io.Serializable
* The argument is in network byte order: the highest order byte of the * The argument is in network byte order: the highest order byte of the
* address is in getAddress()[0]. * address is in getAddress()[0].
* *
* @exception UnknownHostException If no IP address for the host could * @exception UnknownHostException If IP address has illegal length
* be found * be found
* *
* @since 1.4 * @since 1.4
@ -236,6 +250,14 @@ public class InetAddress implements java.io.Serializable
private static native InetAddress[] lookup private static native InetAddress[] lookup
(String hostname, InetAddress addr, boolean all); (String hostname, InetAddress addr, boolean all);
/**
* Determines the IP address of a host, given the host's name.
*
* @exception UnknownHostException If no IP address for the host could
* be found
* @exception SecurityException If a security manager exists and its
* checkConnect method doesn't allow the operation
*/
public static InetAddress getByName (String host) public static InetAddress getByName (String host)
throws UnknownHostException throws UnknownHostException
{ {
@ -249,6 +271,15 @@ public class InetAddress implements java.io.Serializable
return iaddr; return iaddr;
} }
/**
* Given the name of a host, returns an array of its IP addresses,
* based on the configured name service on the system.
*
* @exception UnknownHostException If no IP address for the host could
* be found
* @exception SecurityException If a security manager exists and its
* checkConnect method doesn't allow the operation
*/
public static InetAddress[] getAllByName (String host) public static InetAddress[] getAllByName (String host)
throws UnknownHostException throws UnknownHostException
{ {
@ -272,6 +303,12 @@ public class InetAddress implements java.io.Serializable
private static InetAddress localhost = null; private static InetAddress localhost = null;
/**
* Returns the local host
*
* @exception UnknownHostException If no IP address for the host could
* be found
*/
public static InetAddress getLocalHost() throws UnknownHostException public static InetAddress getLocalHost() throws UnknownHostException
{ {
SecurityManager s = System.getSecurityManager(); SecurityManager s = System.getSecurityManager();