com.eurotech.framework.net
Class IPAddress

java.lang.Object
  extended by com.eurotech.framework.net.IPAddress
Direct Known Subclasses:
IP4Address, IP6Address

public abstract class IPAddress
extends Object

This class represents an Internet Protocol (IP) address.


Field Summary
protected  InetAddress javaNetAddress
           
 
Method Summary
 boolean equals(Object obj)
           
 byte[] getAddress()
          Returns the raw IP address of this InetAddress object.
static IPAddress getByAddress(byte[] addr)
          Returns an InetAddress object given the raw IP address.
static IPAddress getByAddress(int addr)
           
 String getHostAddress()
          Returns the IP address string in textual presentation.
 int hashCode()
           
 boolean isAnyLocalAddress()
          Utility routine to check if the InetAddress in a wildcard address.
 boolean isLinkLocalAddress()
          Utility routine to check if the InetAddress is an link local address.
 boolean isLoopbackAddress()
          Utility routine to check if the InetAddress is a loopback address.
 boolean isMCGlobal()
          Utility routine to check if the multicast address has global scope.
 boolean isMCLinkLocal()
          Utility routine to check if the multicast address has link scope.
 boolean isMCNodeLocal()
          Utility routine to check if the multicast address has node scope.
 boolean isMCOrgLocal()
          Utility routine to check if the multicast address has organization scope.
 boolean isMCSiteLocal()
          Utility routine to check if the multicast address has site scope.
 boolean isMulticastAddress()
          Utility routine to check if the InetAddress is an IP multicast address.
 boolean isSiteLocalAddress()
          Utility routine to check if the InetAddress is a site local address.}
static IPAddress parseHostAddress(String hostAddress)
          Parse a literal representation of an IP address and returns the corresponding IPAddress class.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

javaNetAddress

protected InetAddress javaNetAddress
Method Detail

getByAddress

public static IPAddress getByAddress(byte[] addr)
                              throws UnknownHostException
Returns an InetAddress object given the raw IP address. The argument is in network byte order: the highest order byte of the address is in getAddress()[0]. This method doesn't block, i.e. no reverse name service lookup is performed.
IPv4 address byte array must be 4 bytes long and IPv6 byte array must be 16 bytes long

Parameters:
addr - - the raw IP address in network byte order
Returns:
an InetAddress object created from the raw IP address.
Throws:
UnknownHostException

getByAddress

public static IPAddress getByAddress(int addr)
                              throws UnknownHostException
Throws:
UnknownHostException

parseHostAddress

public static IPAddress parseHostAddress(String hostAddress)
                                  throws UnknownHostException
Parse a literal representation of an IP address and returns the corresponding IPAddress class.

Parameters:
hostAddress -
Returns:
Throws:
UnknownHostException

getAddress

public byte[] getAddress()
Returns the raw IP address of this InetAddress object. The result is in network byte order: the highest order byte of the address is in getAddress()[0].

Returns:
the raw IP address of this object.

getHostAddress

public String getHostAddress()
Returns the IP address string in textual presentation.

Returns:
the raw IP address in a string format.

isAnyLocalAddress

public boolean isAnyLocalAddress()
Utility routine to check if the InetAddress in a wildcard address.

Returns:
a boolean indicating if the Inetaddress is a wildcard address.

isLinkLocalAddress

public boolean isLinkLocalAddress()
Utility routine to check if the InetAddress is an link local address.

Returns:
a boolean indicating if the InetAddress is a link local address; or false if address is not a link local unicast address.

isLoopbackAddress

public boolean isLoopbackAddress()
Utility routine to check if the InetAddress is a loopback address.

Returns:
a boolean indicating if the InetAddress is a loopback address; or false otherwise.

isMCGlobal

public boolean isMCGlobal()
Utility routine to check if the multicast address has global scope.

Returns:
a boolean indicating if the address has is a multicast address of global scope, false if it is not of global scope or it is not a multicast address

isMCLinkLocal

public boolean isMCLinkLocal()
Utility routine to check if the multicast address has link scope.

Returns:
a boolean indicating if the address has is a multicast address of link-local scope, false if it is not of link-local scope or it is not a multicast address

isMCNodeLocal

public boolean isMCNodeLocal()
Utility routine to check if the multicast address has node scope.

Returns:
a boolean indicating if the address has is a multicast address of node-local scope, false if it is not of node-local scope or it is not a multicast address

isMCOrgLocal

public boolean isMCOrgLocal()
Utility routine to check if the multicast address has organization scope.

Returns:
a boolean indicating if the address has is a multicast address of organization-local scope, false if it is not of organization-local scope or it is not a multicast address

isMCSiteLocal

public boolean isMCSiteLocal()
Utility routine to check if the multicast address has site scope.

Returns:
a boolean indicating if the address has is a multicast address of site-local scope, false if it is not of site-local scope or it is not a multicast address

isMulticastAddress

public boolean isMulticastAddress()
Utility routine to check if the InetAddress is an IP multicast address.

Returns:

isSiteLocalAddress

public boolean isSiteLocalAddress()
Utility routine to check if the InetAddress is a site local address.}

Returns:
a boolean indicating if the InetAddress is a site local address; or false if address is not a site local unicast address.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object


Copyright © 2013. All Rights Reserved.