anthill.antnet
Class UdpNid

java.lang.Object
  |
  +--anthill.antnet.UdpNid
All Implemented Interfaces:
java.io.Externalizable, NestId, java.io.Serializable

public class UdpNid
extends java.lang.Object
implements NestId, java.io.Externalizable

An UDP anthill identifier is composed by an IP address plus an UDP port. This information is used to contact an UDP anthill. Methods equals(), hashcode() and toString() are implemented opportunely.

Version:
$Revision$
Author:
Alberto Montresor
See Also:
Serialized Form

Constructor Summary
UdpNid()
          Default constructor needed for externalization.
UdpNid(java.net.InetAddress address, int port)
          Instantiates a new UDP anthill id and sets both the address and the port number.
UdpNid(int port)
          Instantiates a new UDP anthill id with the specified port number, using the local address as IP address.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Check if two UdpNid objects are equals.
 java.net.InetAddress getAddress()
          Returns the address contained in this id.
 int getPort()
          Returns the port number contained in this id.
 int hashCode()
          Returns a hash code value for the object.
 void readExternal(java.io.ObjectInput in)
          Read a UdpNid from a stream.
 java.lang.String toString()
          Returns a string representation of the object.
 void writeExternal(java.io.ObjectOutput out)
          Write a UdpNid to a stream.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UdpNid

public UdpNid()
Default constructor needed for externalization.

UdpNid

public UdpNid(int port)
       throws java.net.UnknownHostException
Instantiates a new UDP anthill id with the specified port number, using the local address as IP address.

UdpNid

public UdpNid(java.net.InetAddress address,
              int port)
Instantiates a new UDP anthill id and sets both the address and the port number.
Method Detail

getAddress

public java.net.InetAddress getAddress()
Returns the address contained in this id.

getPort

public int getPort()
Returns the port number contained in this id.

equals

public boolean equals(java.lang.Object obj)
Check if two UdpNid objects are equals.
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Returns a hash code value for the object.
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Returns a string representation of the object.
Overrides:
toString in class java.lang.Object

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Read a UdpNid from a stream.
Specified by:
readExternal in interface java.io.Externalizable

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Write a UdpNid to a stream.
Specified by:
writeExternal in interface java.io.Externalizable