Package org.jcsp.net
Class NodeUI
- java.lang.Object
-
- org.jcsp.net.NodeUI
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable
- Direct Known Subclasses:
NodeUIImpl
public abstract class NodeUI extends java.lang.Object implements java.io.Serializable, java.lang.ComparableA Unique Identifier for a Node. This class is different from
NodeIDin that it does not describe the Node's location.Implementations of this class should provide a constructor that takes a
Stringparameter which is in the format of theStringreturned from thegetImplStringForm()method.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description NodeUI()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract booleancheckEqual(NodeUI other)An abstract method to be implemented to return whether anotherNodeUIobject is equal to this instance.intcompareTo(java.lang.Object o)Compares thisNodeUIwith another object.static NodeUIcreateFromStringForm(java.lang.String stringForm)Creates a NodeUI from a String in the format of that returned from thegetImplStringForm()method.booleanequals(java.lang.Object o)Compares thisNodeUIwith another object.protected abstract java.lang.StringgetComparisonString()This is an abstract method that should be implemented to return aStringthat can be used by thecompareTo(Object)method in order to compare twoNodeUIobjects.protected abstract java.lang.StringgetImplStringForm()Returns aStringthat can be supplied to the staticcreateFromStringForm(String)method in order to create an equalNodeUIobject.(package private) java.lang.StringgetStringForm()abstract inthashCode()Returns aninthash code for this object.
-
-
-
Method Detail
-
getStringForm
final java.lang.String getStringForm()
-
getImplStringForm
protected abstract java.lang.String getImplStringForm()
Returns aStringthat can be supplied to the staticcreateFromStringForm(String)method in order to create an equalNodeUIobject.- Returns:
- a
Stringcontaining the necessary information to recreate thisNodeUIobject.
-
createFromStringForm
public static final NodeUI createFromStringForm(java.lang.String stringForm)
Creates a NodeUI from a String in the format of that returned from thegetImplStringForm()method.- Parameters:
stringForm- theStringto use in creating theNodeUIobject.- Returns:
- a newly created
NodeUIobject.
-
equals
public final boolean equals(java.lang.Object o)
Compares thisNodeUIwith another object. This method checks that the supplied object is aNodeUIobject and then calls the implementation of thecheckEqual(NodeUI)method and returns its result value as the result of this method.- Overrides:
equalsin classjava.lang.Object- Parameters:
o- an object to compare with this object.- Returns:
trueiff the supplied object is aNodeUIand the result of a call to thecheckEqual(NodeUI)method istrue.
-
compareTo
public final int compareTo(java.lang.Object o) throws java.lang.ClassCastExceptionCompares thisNodeUIwith another object. This method calls the implementation of thegetComparisonString()method on both thisNodeUIobject and theNodeUIobject supplied. TheStringclass'compareTo(Object)is used to perform the comparison. The method is called on theStringreturned by this object and theStringreturned by the other object is supplied as the parameter.- Specified by:
compareToin interfacejava.lang.Comparable- Parameters:
o- another object to compare with this object.- Returns:
- an
intvalue that follows the rules of thecompareTo(Object)method in theStringclass. - Throws:
java.lang.ClassCastException- if the supplied object is not aNodeUIobject.
-
checkEqual
protected abstract boolean checkEqual(NodeUI other)
An abstract method to be implemented to return whether anotherNodeUIobject is equal to this instance. If the theNodeUIis of a different implementation class, the method should returnfalse.- Parameters:
other- aNodeUIto compare with thisNodeUI.- Returns:
trueiff the suppliedNodeUIis equal to this one.
-
getComparisonString
protected abstract java.lang.String getComparisonString()
This is an abstract method that should be implemented to return aStringthat can be used by thecompareTo(Object)method in order to compare twoNodeUIobjects. TwoNodeUIobjects should return equalStringobjects iff the twoNodeUIobjects are equal.- Returns:
- a
Stringthat follows the above rules.
-
hashCode
public abstract int hashCode()
Returns aninthash code for this object. TwoNodeUIobjects will return equal hash codes if the two objects are equal.- Overrides:
hashCodein classjava.lang.Object- Returns:
- an
inthash code.
-
-