Class NodeID
- java.lang.Object
-
- org.jcsp.net.AbstractID
-
- org.jcsp.net.NodeID
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.lang.Comparable
public final class NodeID extends AbstractID implements java.io.Serializable, java.lang.Cloneable, java.lang.Comparable
A Class whose instances represent a unique identifier for a JCSP.NET Node.
For an explanation of this class, see
.AbstractID- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private NodeAddressID[]addressIDsThis is a set of addresses of LinkServers that the Node, represented by this NodeID, is running.private DomainIDdomainIDThe Domain of which the Node represented by this NodeID is a member.private java.lang.StringnameA name assigned to this Node.private NodeUInodeUIA unique identifier for this node.private java.util.HashSetunrecognisedAddressIDsThis is the set of addresses of LinkServers that the Node, represented by this NodeID, is running but this JVM does not recognise.
-
Constructor Summary
Constructors Modifier Constructor Description privateNodeID(java.lang.String stringRep)(package private)NodeID(NodeUI nodeUI)(package private)NodeID(NodeUI nodeUI, NodeAddressID[] addressIDs, DomainID domainID)(package private)NodeID(NodeUI nodeUI, NodeAddressID addressID, DomainID domainID)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description (package private) voidaddAddress(NodeAddressID addressID)java.lang.Objectclone()Returns a clone of the instance ofNodeIDon which this method is being called.intcompareTo(java.lang.Object o)Compares thisNodeIDobject with anotherNodeIDobject.intcompareToLocalNode()This method is equivalent to calling thecompareTo(Object)and supplying the local Node'sNodeIDas a parameter.(package private) static NodeIDcreateFromStringForm(java.lang.String stringForm)Deprecated.Not needed now channel names have been abstractedbooleanequals(java.lang.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.java.lang.StringgetName()Returns a name that has been assigned to the Node represented by thisNodeIDobject.AbstractIDgetParentID()Returns this instance's parentAbstractIDobject.(package private) java.lang.StringgetStringForm()Deprecated.Not needed now channel names have been abstractedinthashCode()Returns a hash code for thisNodeIDobject.(package private) booleanonSameBranch(AbstractID abstractID)This tests whether another ID is on the same branch of a hierachy.private voidreadObject(java.io.ObjectInputStream in)(package private) voidremoveAddress(NodeAddressID addressID)(package private) voidsetDomainID(DomainID domainID)(package private) voidsetName(java.lang.String name)java.lang.StringtoString()Returns a human readableStringthat represents thisNodeIDobject.private voidwriteObject(java.io.ObjectOutputStream out)
-
-
-
Field Detail
-
addressIDs
private NodeAddressID[] addressIDs
This is a set of addresses of LinkServers that the Node, represented by this NodeID, is running.
-
unrecognisedAddressIDs
private java.util.HashSet unrecognisedAddressIDs
This is the set of addresses of LinkServers that the Node, represented by this NodeID, is running but this JVM does not recognise. The serialized forms of the addresses are stored here so that
-
domainID
private DomainID domainID
The Domain of which the Node represented by this NodeID is a member.
-
nodeUI
private NodeUI nodeUI
A unique identifier for this node.
-
name
private java.lang.String name
A name assigned to this Node.
-
-
Constructor Detail
-
NodeID
NodeID(NodeUI nodeUI)
-
NodeID
NodeID(NodeUI nodeUI, NodeAddressID addressID, DomainID domainID)
-
NodeID
NodeID(NodeUI nodeUI, NodeAddressID[] addressIDs, DomainID domainID)
-
NodeID
private NodeID(java.lang.String stringRep) throws java.lang.IllegalArgumentException- Throws:
java.lang.IllegalArgumentException
-
-
Method Detail
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedExceptionReturns a clone of the instance of
NodeIDon which this method is being called.- Overrides:
clonein classjava.lang.Object- Returns:
- a clone of the current instance of
NodeID. - Throws:
java.lang.CloneNotSupportedException- if theNodeIDcannot be cloned.
-
equals
public boolean equals(java.lang.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.- Overrides:
equalsin classjava.lang.Object- Parameters:
o- another object to compare with thisNodeID.- Returns:
trueiff the other object is aNodeIDrepresenting the same Node as thisNodeID.
-
hashCode
public int hashCode()
Returns a hash code for this
NodeIDobject.- Overrides:
hashCodein classjava.lang.Object- Returns:
- an
inthash code.
-
compareTo
public int compareTo(java.lang.Object o) throws java.lang.ClassCastExceptionCompares 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 interfacejava.lang.Comparable- 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:
java.lang.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.
-
onSameBranch
boolean onSameBranch(AbstractID abstractID)
Description copied from class:AbstractIDThis tests whether another ID is on the same branch of a hierachy. Returns true if either the supplied object is a child (or a child of child etc.) of this object or if the supplied object is a parent (or a parent of a parent etc.) of this object.- Specified by:
onSameBranchin classAbstractID- Returns:
- a
booleanindicating whether or not the supplied object is on the same branch.
-
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.
-
addAddress
void addAddress(NodeAddressID addressID)
-
removeAddress
void removeAddress(NodeAddressID addressID)
-
createFromStringForm
static NodeID createFromStringForm(java.lang.String stringForm) throws java.lang.IllegalArgumentException
Deprecated.Not needed now channel names have been abstracted- Throws:
java.lang.IllegalArgumentException
-
getStringForm
java.lang.String getStringForm()
Deprecated.Not needed now channel names have been abstractedThis gets a String form of this NodeID. This is only intended to be called for NodeID's representing the current JVM as any NodeAddressIDs in serialized form in the unrecognisedAddressIDs HashSet will not be saved. This HashSet should be empty for NodeID's representing the current JVM.- Returns:
- the String form that can be used to reconstruct this NodeID.
-
setDomainID
void setDomainID(DomainID domainID)
-
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 java.lang.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 java.lang.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.- Overrides:
toStringin classjava.lang.Object- Returns:
- a human readable
String.
-
setName
void setName(java.lang.String name)
-
readObject
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
writeObject
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException- Throws:
java.io.IOException
-
-