Package org.jcsp.net

Class NodeID

All Implemented Interfaces:
Serializable, Cloneable, Comparable

public final class NodeID extends AbstractID implements Serializable, Cloneable, Comparable

A Class whose instances represent a unique identifier for a JCSP.NET Node.

For an explanation of this class, see AbstractID.

Author:
Quickstone Technologies Limited
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns a clone of the instance of NodeID on which this method is being called.
    int
    Compares this NodeID object with another NodeID object.
    int
    This method is equivalent to calling the compareTo(Object) and supplying the local Node's NodeID as a parameter.
    boolean
    Compares this NodeID with another object.
    Returns a clone of the set of NodeAddressID objects that this NodeID holds.
    Get the DomainID of the domain to which the Node represented by this NodeID object belongs.
    Returns a name that has been assigned to the Node represented by this NodeID object.
    Returns this instance's parent AbstractID object.
    int
    Returns a hash code for this NodeID object.
    Returns a human readable String that represents this NodeID object.

    Methods inherited from class java.lang.Object

    finalize, getClass, notify, notifyAll, wait, wait, wait
  • Method Details

    • clone

      public Object clone() throws CloneNotSupportedException

      Returns a clone of the instance of NodeID on which this method is being called.

      Overrides:
      clone in class Object
      Returns:
      a clone of the current instance of NodeID.
      Throws:
      CloneNotSupportedException - if the NodeID cannot be cloned.
    • equals

      public boolean equals(Object o)

      Compares this NodeID with another object. This will only return true if the other object is a NodeID representing the same Node as this NodeID. The comparison is performed by using a Node's unique identifier. This was introduced for efficiency reasons as comparing two NodeID objects' sets of addresses could be quite slow.

      Overrides:
      equals in class Object
      Parameters:
      o - another object to compare with this NodeID.
      Returns:
      true iff the other object is a NodeID representing the same Node as this NodeID.
    • hashCode

      public int hashCode()

      Returns a hash code for this NodeID object.

      Overrides:
      hashCode in class Object
      Returns:
      an int hash code.
    • compareTo

      public int compareTo(Object o) throws ClassCastException

      Compares this NodeID object with another NodeID object. Returns 0 if this NodeID is equal to the other NodeID, a negative int if this NodeID is less than the supplied NodeID or a positive int if this NodeID is greater than the supplied NodeID.

      This comparison is based upon the implementation of NodeUI used.

      Specified by:
      compareTo in interface Comparable
      Parameters:
      o - An object to compare with this NodeID.
      Returns:
      0 if this NodeID is equal to the other NodeID, a negative int if this NodeID is less than the supplied NodeID or a positive int if this NodeID is greater than the supplied NodeID.
      Throws:
      ClassCastException - if the parameter supplied is not a NodeID.
    • compareToLocalNode

      public int compareToLocalNode()

      This method is equivalent to calling the compareTo(Object) and supplying the local Node's NodeID as a parameter.

      Returns:
      an int following the rules of the compareTo(Object) method.
    • getAddresses

      public NodeAddressID[] getAddresses()

      Returns a clone of the set of NodeAddressID objects that this NodeID holds.

      If any held NodeAddressID objects do not support cloning, then the actual object is returned but this should never be the case.

      Returns:
      an array of NodeAddressID objects.
    • getParentID

      public AbstractID getParentID()
      Description copied from class: AbstractID
      Returns this instance's parent AbstractID object.
      Specified by:
      getParentID in class AbstractID
      Returns:
      the parent AbstractID of this object.
    • getDomainID

      public DomainID getDomainID()
      Get the DomainID of the domain to which the Node represented by this NodeID object belongs. If the Node is not a member of a domain then a DomainID object will be returned that will return true when its isNullDomain() method is called.
      Returns:
      this NodeID object's DomainID object.
    • getName

      public String getName()
      Returns a name that has been assigned to the Node represented by this NodeID object. If no name has been assigned, then an empty String is returned. The Node naming feature is not currently implemented.
      Returns:
      the name assigned to this NodeID object's Node.
    • toString

      public String toString()
      Returns a human readable String that represents this NodeID object. This will either include the name of the Node, if assigned, or else a list of the Node's addresses. The String returned by this method is only really intended as a way of supply debugging information to users. The contents is not guaranteed and should not relied upon by a program.
      Overrides:
      toString in class Object
      Returns:
      a human readable String.