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 Object
clone()
Returns a clone of the instance ofNodeID
on which this method is being called.int
compareTo(Object o)
Compares thisNodeID
object with anotherNodeID
object.int
compareToLocalNode()
This method is equivalent to calling thecompareTo(Object)
and supplying the local Node'sNodeID
as a parameter.boolean
equals(Object o)
Compares thisNodeID
with another object.NodeAddressID[]
getAddresses()
Returns a clone of the set ofNodeAddressID
objects that thisNodeID
holds.DomainID
getDomainID()
Get theDomainID
of the domain to which the Node represented by thisNodeID
object belongs.String
getName()
Returns a name that has been assigned to the Node represented by thisNodeID
object.AbstractID
getParentID()
Returns this instance's parentAbstractID
object.int
hashCode()
Returns a hash code for thisNodeID
object.String
toString()
Returns a human readableString
that represents thisNodeID
object.
-
-
-
Method Detail
-
clone
public Object clone() throws CloneNotSupportedException
Returns a clone of the instance of
NodeID
on which this method is being called.- Overrides:
clone
in classObject
- Returns:
- a clone of the current instance of
NodeID
. - Throws:
CloneNotSupportedException
- if theNodeID
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 aNodeID
representing the same Node as thisNodeID
. The comparison is performed by using a Node's unique identifier. This was introduced for efficiency reasons as comparing twoNodeID
objects' sets of addresses could be quite slow.
-
hashCode
public int hashCode()
Returns a hash code for this
NodeID
object.
-
compareTo
public int compareTo(Object o) throws ClassCastException
Compares this
NodeID
object with anotherNodeID
object. Returns 0 if thisNodeID
is equal to the otherNodeID
, a negativeint
if thisNodeID
is less than the suppliedNodeID
or a positiveint
if thisNodeID
is greater than the suppliedNodeID
.This comparison is based upon the implementation of
NodeUI
used.- Specified by:
compareTo
in interfaceComparable
- Parameters:
o
- An object to compare with thisNodeID
.- Returns:
- 0 if this
NodeID
is equal to the otherNodeID
, a negativeint
if thisNodeID
is less than the suppliedNodeID
or a positiveint
if thisNodeID
is 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'sNodeID
as a parameter.- Returns:
- an
int
following the rules of thecompareTo(Object)
method.
-
getAddresses
public NodeAddressID[] getAddresses()
Returns a clone of the set of
NodeAddressID
objects that thisNodeID
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 parentAbstractID
object.- Specified by:
getParentID
in classAbstractID
- Returns:
- the parent
AbstractID
of this object.
-
getDomainID
public DomainID getDomainID()
Get theDomainID
of the domain to which the Node represented by thisNodeID
object belongs. If the Node is not a member of a domain then aDomainID
object will be returned that will returntrue
when itsisNullDomain()
method is called.- Returns:
- this
NodeID
object'sDomainID
object.
-
getName
public String getName()
Returns a name that has been assigned to the Node represented by thisNodeID
object. If no name has been assigned, then an emptyString
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 readableString
that represents thisNodeID
object. This will either include the name of the Node, if assigned, or else a list of the Node's addresses. TheString
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.
-
-