org.xins.common.net
Class IPAddressUtils

java.lang.Object
  extended byorg.xins.common.net.IPAddressUtils

public final class IPAddressUtils
extends Object

IP address-related utility functions.

Since:
XINS 1.0.0
Version:
$Revision: 1.24 $ $Date: 2006/08/28 09:12:36 $
Author:
Ernst de Haan

Method Summary
static String getLocalHost()
          Retrieves the localhost host name.
static String getLocalHostIPAddress()
          Retrieves the localhost IP address.
static String getLocalHostJava13()
          Retrieves the localhost host name, on Java 1.3.
static String getLocalHostJava14()
          Retrieves the localhost host name, on Java 1.4 and up.
static int ipToInt(String ip)
          Converts an IP address in the form a.b.c.d to an int.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

ipToInt

public static int ipToInt(String ip)
                   throws IllegalArgumentException,
                          ParseException
Converts an IP address in the form a.b.c.d to an int.

Parameters:
ip - the IP address, must be in the form: a.a.a.a., where a is a number between 0 and 255, with no leading zeroes; cannot be null.
Returns:
the IP address as an int.
Throws:
IllegalArgumentException - if ip == null.
ParseException - if ip cannot be parsed as an IP address.

getLocalHostIPAddress

public static String getLocalHostIPAddress()
Retrieves the localhost IP address.

Returns:
if possible the IP address for localhost, otherwise the string "127.0.0.1".
Since:
XINS 1.3.0

getLocalHost

public static String getLocalHost()
Retrieves the localhost host name. This method applies several techniques to attempt to retrieve the localhost host name.

Returns:
if possible the fully qualified host name for localhost, otherwise if possible the non-qualified host name for the localhost, otherwise the string "localhost".

getLocalHostJava13

public static String getLocalHostJava13()
Retrieves the localhost host name, on Java 1.3.

Returns:
if possible the fully qualified host name for localhost, otherwise if possible the non-qualified host name for the localhost, otherwise the string "localhost".

getLocalHostJava14

public static String getLocalHostJava14()
Retrieves the localhost host name, on Java 1.4 and up. This method applies several techniques to attempt to retrieve the localhost host name.

Returns:
if possible the fully qualified host name for localhost, otherwise if possible the non-qualified host name for the localhost, otherwise the string "localhost".


See http://www.xins.org/.