net.vattp.data
Class NetAddr

java.lang.Object
  |
  +--net.vattp.data.NetAddr

public class NetAddr
extends Object

Untamed:


Field Summary
private  InetAddress myOptIP
          null means a port associated with all local IP addresses
private  int myPortNumber
           
 
Constructor Summary
NetAddr(InetAddress optIP, int portNumber)
          Enabled: Construct a new NetAddr given an IP address and a port number.
NetAddr(String optAddr)
          Enabled: Construct a NetAddr from a string in the form: hostname:portnumber or hostname.
 
Method Summary
 boolean equals(Object other)
          Suppressed: Test if another object is an NetAddr denoting the same address as this.
 int getPort()
          Enabled: Return my port number.
 int hashCode()
          Suppressed: @return A hash code that accounts for both the IP address and port.
 InetAddress optInetAddress()
          Enabled: Return my IP address, or null indicating all local IP addresses.
 String toString()
          Suppressed: Produce a printable representation of this.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

myOptIP

private final InetAddress myOptIP
null means a port associated with all local IP addresses


myPortNumber

private final int myPortNumber
Constructor Detail

NetAddr

public NetAddr(String optAddr)
        throws UnknownHostException
Enabled: Construct a NetAddr from a string in the form: hostname:portnumber or hostname. If the :portnumber is omitted, port number 0 will be assumed. The hostname may be either a DNS name or an IP number in dotted decimal format. It may be both of these separated by a slash, in which case only the part after the slash is significant. If the significant part of the hostname is absent, then the port is associated with all local IP addresses.

Examples:

   "the-earth.communities.com/205.162.51.187:4568"
   "the-earth.communities.com:4568"
   "205.162.51.187:4568"
   "the-earth.communities.com"
   ":4568"
   ""
   null
 

Parameters:
optAddr - is the network address.
Throws:
UnknownHostException - is thrown if the host name can not be resolved.

NetAddr

public NetAddr(InetAddress optIP,
               int portNumber)
Enabled: Construct a new NetAddr given an IP address and a port number.

Parameters:
optIP - An IP address, or null meaning all local IP addresses
portNumber - A port at that IP address
Method Detail

equals

public boolean equals(Object other)
Suppressed: Test if another object is an NetAddr denoting the same address as this.

Overrides:
equals in class Object
Parameters:
other - The other object to test for equality.
Returns:
true iff this and other denote the same net address.
See Also:
Object.hashCode(), java.util.Hashtable

hashCode

public int hashCode()
Suppressed: @return A hash code that accounts for both the IP address and port.

Overrides:
hashCode in class Object
Returns:
a hash code value for this object.
See Also:
java.lang.Object#equals(java.lang.Object), java.util.Hashtable

optInetAddress

public InetAddress optInetAddress()
Enabled: Return my IP address, or null indicating all local IP addresses.

Returns:
my IP address

getPort

public int getPort()
Enabled: Return my port number.

Returns:
my port number

toString

public String toString()
Suppressed: Produce a printable representation of this.

Overrides:
toString in class Object
Returns:
A nicely formatted string representing this address.


comments?