org.lwes.util
Class IPAddress

java.lang.Object
  extended by org.lwes.util.IPAddress
All Implemented Interfaces:
java.io.Serializable

public class IPAddress
extends java.lang.Object
implements java.io.Serializable

This is a wrapper class for InetAddress, which allows the setting of an InetAddress with a byte arrays. As well as other useful functions.

Author:
Anthony Molinaro
See Also:
Serialized Form

Constructor Summary
IPAddress()
          Defaut constructor
IPAddress(byte[] anIPAddress)
          Construct an IPAddress object with a byte array containing the InetAddress in little-endian notation.
IPAddress(java.net.InetAddress anIPAddress)
          Construct an IPAddress object with an InetAddress.
IPAddress(java.lang.String anIPAddress)
          Construct an IPAddress object with a string of the form "%d.%d.%d.%d" representing an InetAddress.
 
Method Summary
 int bytesStoreSize()
          return the size that an IPAddress takes up in a serialized byte array
 boolean equals(java.lang.Object o)
           
 byte[] getInetAddressAsBytes()
          Return the IPAddress in a byte array in network order
 int hashcode()
           
 java.net.InetAddress toInetAddress()
          Get the InetAddress representing this IPAddress
 int toInt()
          Return the IPAddress in as an integer
 java.lang.String toString()
          return a string representation of an IPAddress in the following format "%d.%d.%d.%d".
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IPAddress

public IPAddress()
Defaut constructor


IPAddress

public IPAddress(java.lang.String anIPAddress)
Construct an IPAddress object with a string of the form "%d.%d.%d.%d" representing an InetAddress. The address defaults to 0.0.0.0 if an invalid address is given.

Parameters:
anIPAddress - the string representing the IPAddress

IPAddress

public IPAddress(byte[] anIPAddress)
Construct an IPAddress object with a byte array containing the InetAddress in little-endian notation.

Parameters:
anIPAddress - the byte array representing the IPAddress

IPAddress

public IPAddress(java.net.InetAddress anIPAddress)
Construct an IPAddress object with an InetAddress.

Parameters:
anIPAddress - the InetAddress to set this IPAddress to
Method Detail

toInetAddress

public java.net.InetAddress toInetAddress()
Get the InetAddress representing this IPAddress

Returns:
the InetAddress representing this IPAddress

getInetAddressAsBytes

public byte[] getInetAddressAsBytes()
Return the IPAddress in a byte array in network order

Returns:
a byte array containing the IPAddress in network order

toInt

public int toInt()
Return the IPAddress in as an integer

Returns:
an integer representing the IPAddress in network order

toString

public java.lang.String toString()
return a string representation of an IPAddress in the following format "%d.%d.%d.%d".

Overrides:
toString in class java.lang.Object
Returns:
a string representation of an IPAddress.

bytesStoreSize

public int bytesStoreSize()
return the size that an IPAddress takes up in a serialized byte array


equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashcode

public int hashcode()