jpcap
Class IPAddress

java.lang.Object
  |
  +--jpcap.IPAddress

public class IPAddress
extends java.lang.Object

This class represents an IP address.

Either IPv4 and IPv6 addresses can be represented by this class.


Constructor Summary
IPAddress(byte[] address)
          Creates IP address of the specified byte array.
This doesn't check if the address is valid.
IPAddress(int version, byte[] address)
          Creates IP address of the specified version and byte array.
This doesn't check if the address is valid.
IPAddress(int version, java.lang.String address)
          Creates an IP address of the specified version and IP address or domain name.
IPAddress(java.lang.String address)
          Creates IPv4 address of the specified address or domain name.
 
Method Summary
 boolean equals(java.lang.Object p)
          Check if this object is equal to the given object.
 byte[] getAddress()
          Returns the byte array of this object.
 java.lang.String getHostAddress()
          Returns the IP address string "%d.%d.%d.%d" or "%x:%x::%x:%x"
 java.lang.String getHostName()
          Return the domain name of this object.
 java.net.InetAddress getInetAddress()
          Returns the instance of java.net.InetAddress, if this is IPv4 address.
Returns null if this is IPv6.
 java.lang.String toString()
          Returns the IP address string "%d.%d.%d.%d" or "%x:%x::%x:%x"
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IPAddress

public IPAddress(int version,
                 java.lang.String address)
          throws java.net.UnknownHostException
Creates an IP address of the specified version and IP address or domain name.
Parameters:
version - version of this IP address
address - IP address or domain name

IPAddress

public IPAddress(java.lang.String address)
          throws java.net.UnknownHostException
Creates IPv4 address of the specified address or domain name.
Parameters:
address - IP address or domain name

IPAddress

public IPAddress(int version,
                 byte[] address)
Creates IP address of the specified version and byte array.
This doesn't check if the address is valid.
Parameters:
address - byte array of an IP address

IPAddress

public IPAddress(byte[] address)
Creates IP address of the specified byte array.
This doesn't check if the address is valid.
Parameters:
address - byte array of an IP address
Method Detail

getAddress

public byte[] getAddress()
Returns the byte array of this object.

getHostAddress

public java.lang.String getHostAddress()
Returns the IP address string "%d.%d.%d.%d" or "%x:%x::%x:%x"

getHostName

public java.lang.String getHostName()
                             throws java.net.UnknownHostException
Return the domain name of this object.

getInetAddress

public java.net.InetAddress getInetAddress()
                                    throws java.net.UnknownHostException
Returns the instance of java.net.InetAddress, if this is IPv4 address.
Returns null if this is IPv6.

equals

public boolean equals(java.lang.Object p)
Check if this object is equal to the given object.
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Returns the IP address string "%d.%d.%d.%d" or "%x:%x::%x:%x"
Overrides:
toString in class java.lang.Object