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.Comparable
A Unique Identifier for a Node. This class is different from
NodeID
in that it does not describe the Node's location.Implementations of this class should provide a constructor that takes a
String
parameter which is in the format of theString
returned 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 boolean
checkEqual(NodeUI other)
An abstract method to be implemented to return whether anotherNodeUI
object is equal to this instance.int
compareTo(java.lang.Object o)
Compares thisNodeUI
with another object.static NodeUI
createFromStringForm(java.lang.String stringForm)
Creates a NodeUI from a String in the format of that returned from thegetImplStringForm()
method.boolean
equals(java.lang.Object o)
Compares thisNodeUI
with another object.protected abstract java.lang.String
getComparisonString()
This is an abstract method that should be implemented to return aString
that can be used by thecompareTo(Object)
method in order to compare twoNodeUI
objects.protected abstract java.lang.String
getImplStringForm()
Returns aString
that can be supplied to the staticcreateFromStringForm(String)
method in order to create an equalNodeUI
object.(package private) java.lang.String
getStringForm()
abstract int
hashCode()
Returns anint
hash code for this object.
-
-
-
Method Detail
-
getStringForm
final java.lang.String getStringForm()
-
getImplStringForm
protected abstract java.lang.String getImplStringForm()
Returns aString
that can be supplied to the staticcreateFromStringForm(String)
method in order to create an equalNodeUI
object.- Returns:
- a
String
containing the necessary information to recreate thisNodeUI
object.
-
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
- theString
to use in creating theNodeUI
object.- Returns:
- a newly created
NodeUI
object.
-
equals
public final boolean equals(java.lang.Object o)
Compares thisNodeUI
with another object. This method checks that the supplied object is aNodeUI
object and then calls the implementation of thecheckEqual(NodeUI)
method and returns its result value as the result of this method.- Overrides:
equals
in classjava.lang.Object
- Parameters:
o
- an object to compare with this object.- Returns:
true
iff the supplied object is aNodeUI
and the result of a call to thecheckEqual(NodeUI)
method istrue
.
-
compareTo
public final int compareTo(java.lang.Object o) throws java.lang.ClassCastException
Compares thisNodeUI
with another object. This method calls the implementation of thegetComparisonString()
method on both thisNodeUI
object and theNodeUI
object supplied. TheString
class'compareTo(Object)
is used to perform the comparison. The method is called on theString
returned by this object and theString
returned by the other object is supplied as the parameter.- Specified by:
compareTo
in interfacejava.lang.Comparable
- Parameters:
o
- another object to compare with this object.- Returns:
- an
int
value that follows the rules of thecompareTo(Object)
method in theString
class. - Throws:
java.lang.ClassCastException
- if the supplied object is not aNodeUI
object.
-
checkEqual
protected abstract boolean checkEqual(NodeUI other)
An abstract method to be implemented to return whether anotherNodeUI
object is equal to this instance. If the theNodeUI
is of a different implementation class, the method should returnfalse
.- Parameters:
other
- aNodeUI
to compare with thisNodeUI
.- Returns:
true
iff the suppliedNodeUI
is equal to this one.
-
getComparisonString
protected abstract java.lang.String getComparisonString()
This is an abstract method that should be implemented to return aString
that can be used by thecompareTo(Object)
method in order to compare twoNodeUI
objects. TwoNodeUI
objects should return equalString
objects iff the twoNodeUI
objects are equal.- Returns:
- a
String
that follows the above rules.
-
hashCode
public abstract int hashCode()
Returns anint
hash code for this object. TwoNodeUI
objects will return equal hash codes if the two objects are equal.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- an
int
hash code.
-
-