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.40 $ $Date: 2009/04/16 16:00:23 $
Author:
Ernst de Haan

Method Summary
static String getLocalHost()
          Retrieves the localhost host name.
static String getLocalHostIPAddress()
          Retrieves the localhost IP address.
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".


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