Class NodeID
- java.lang.Object
-
- org.jcsp.net.AbstractID
-
- org.jcsp.net.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:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Objectclone()Returns a clone of the instance ofNodeIDon which this method is being called.intcompareTo(Object o)Compares thisNodeIDobject with anotherNodeIDobject.intcompareToLocalNode()This method is equivalent to calling thecompareTo(Object)and supplying the local Node'sNodeIDas a parameter.booleanequals(Object o)Compares thisNodeIDwith another object.NodeAddressID[]getAddresses()Returns a clone of the set ofNodeAddressIDobjects that thisNodeIDholds.DomainIDgetDomainID()Get theDomainIDof the domain to which the Node represented by thisNodeIDobject belongs.StringgetName()Returns a name that has been assigned to the Node represented by thisNodeIDobject.AbstractIDgetParentID()Returns this instance's parentAbstractIDobject.inthashCode()Returns a hash code for thisNodeIDobject.StringtoString()Returns a human readableStringthat represents thisNodeIDobject.
-
-
-
Method Detail
-
clone
public Object clone() throws CloneNotSupportedException
Returns a clone of the instance of
NodeIDon which this method is being called.- Overrides:
clonein classObject- Returns:
- a clone of the current instance of
NodeID. - Throws:
CloneNotSupportedException- if theNodeIDcannot be cloned.
-
equals
public boolean equals(Object o)
Compares this
NodeIDwith another object. This will only return true if the other object is aNodeIDrepresenting the same Node as thisNodeID. The comparison is performed by using a Node's unique identifier. This was introduced for efficiency reasons as comparing twoNodeIDobjects' sets of addresses could be quite slow.
-
hashCode
public int hashCode()
Returns a hash code for this
NodeIDobject.
-
compareTo
public int compareTo(Object o) throws ClassCastException
Compares this
NodeIDobject with anotherNodeIDobject. Returns 0 if thisNodeIDis equal to the otherNodeID, a negativeintif thisNodeIDis less than the suppliedNodeIDor a positiveintif thisNodeIDis greater than the suppliedNodeID.This comparison is based upon the implementation of
NodeUIused.- Specified by:
compareToin interfaceComparable- Parameters:
o- An object to compare with thisNodeID.- Returns:
- 0 if this
NodeIDis equal to the otherNodeID, a negativeintif thisNodeIDis less than the suppliedNodeIDor a positiveintif thisNodeIDis greater than the suppliedNodeID. - Throws:
ClassCastException- if the parameter supplied is not aNodeID.
-
compareToLocalNode
public int compareToLocalNode()
This method is equivalent to calling the
compareTo(Object)and supplying the local Node'sNodeIDas a parameter.- Returns:
- an
intfollowing the rules of thecompareTo(Object)method.
-
getAddresses
public NodeAddressID[] getAddresses()
Returns a clone of the set of
NodeAddressIDobjects that thisNodeIDholds.If any held
NodeAddressIDobjects do not support cloning, then the actual object is returned but this should never be the case.- Returns:
- an array of
NodeAddressIDobjects.
-
getParentID
public AbstractID getParentID()
Description copied from class:AbstractIDReturns this instance's parentAbstractIDobject.- Specified by:
getParentIDin classAbstractID- Returns:
- the parent
AbstractIDof this object.
-
getDomainID
public DomainID getDomainID()
Get theDomainIDof the domain to which the Node represented by thisNodeIDobject belongs. If the Node is not a member of a domain then aDomainIDobject will be returned that will returntruewhen itsisNullDomain()method is called.- Returns:
- this
NodeIDobject'sDomainIDobject.
-
getName
public String getName()
Returns a name that has been assigned to the Node represented by thisNodeIDobject. If no name has been assigned, then an emptyStringis returned. The Node naming feature is not currently implemented.- Returns:
- the name assigned to this
NodeIDobject's Node.
-
toString
public String toString()
Returns a human readableStringthat represents thisNodeIDobject. This will either include the name of the Node, if assigned, or else a list of the Node's addresses. TheStringreturned 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.
-
-