Package org.jcsp.net2
Class NodeAddress
- java.lang.Object
-
- org.jcsp.net2.NodeAddress
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable
- Direct Known Subclasses:
TCPIPNodeAddress
public abstract class NodeAddress extends java.lang.Object implements java.io.Serializable, java.lang.ComparableThis abstract class defines encapsulates the address of a Node within a JCSP networked system. Specific protocols must provide concrete implementations of this class to allow Node initialisation and connection. One concrete example is provided in the org.jcsp.net2.tcpip package.- See Also:
Node, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.StringaddressString representation of the addressprivate static java.util.HashtableinstalledProtocolsThe table of installed protocols on this Nodeprotected java.lang.StringprotocolString representing the protocol in used
-
Constructor Summary
Constructors Constructor Description NodeAddress()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description intcompareTo(java.lang.Object arg0)Compares this NodeAddress to anotherprotected abstract LinkcreateLink()Creates a Link connected to this addressprotected abstract LinkServercreateLinkServer()Creates a LinkServer listening on this addressbooleanequals(java.lang.Object obj)Checks if this NodeAddress is equal to anotherjava.lang.StringgetAddress()Gets a string representing the addressjava.lang.StringgetProtocol()Gets the string representing the protocolprotected abstract ProtocolIDgetProtocolID()Retrieves the correct protocol handler for the implemented address type.inthashCode()Gets the hash code of this objectstatic voidinstallProtocol(java.lang.String name, ProtocolID protocol)Installs a new Protocol on the Nodestatic NodeAddressparse(java.lang.String str)Parses a string representation of a NodeAddress back to its object formjava.lang.StringtoString()Converts the NodeAddress into a String.
-
-
-
Method Detail
-
getProtocol
public java.lang.String getProtocol()
Gets the string representing the protocol- Returns:
- The String representation of the protocol part of the NodeAddress
-
getAddress
public java.lang.String getAddress()
Gets a string representing the address- Returns:
- The String representation of the address part of the NodeAddress
-
toString
public java.lang.String toString()
Converts the NodeAddress into a String. The form is [protocol]\\[address]- Overrides:
toStringin classjava.lang.Object- Returns:
- A String representation of this NodeAddress
-
hashCode
public int hashCode()
Gets the hash code of this object- Overrides:
hashCodein classjava.lang.Object- Returns:
- Hashcode for this NodeAddress
-
equals
public boolean equals(java.lang.Object obj)
Checks if this NodeAddress is equal to another- Overrides:
equalsin classjava.lang.Object- Parameters:
obj- The NodeAddress to compare to- Returns:
- True if object is equal to this NodeAddress, false otherwise
-
compareTo
public int compareTo(java.lang.Object arg0)
Compares this NodeAddress to another- Specified by:
compareToin interfacejava.lang.Comparable- Parameters:
arg0- The NodeAddress to compare to- Returns:
- 1 if object is greater than this one, 0 if they are equal, -1 otherwise
-
createLink
protected abstract Link createLink() throws JCSPNetworkException
Creates a Link connected to this address- Returns:
- A new Link connected to this address
- Throws:
JCSPNetworkException- If something goes wrong during the creation of the Link
-
createLinkServer
protected abstract LinkServer createLinkServer() throws JCSPNetworkException
Creates a LinkServer listening on this address- Returns:
- A new LinkServer listening on this address
- Throws:
JCSPNetworkException- If something goes wrong during the creation of the LinkServer
-
getProtocolID
protected abstract ProtocolID getProtocolID()
Retrieves the correct protocol handler for the implemented address type. This is used during Node initialisation- Returns:
- the ProtocolID for this address type
-
parse
public static NodeAddress parse(java.lang.String str) throws java.lang.IllegalArgumentException
Parses a string representation of a NodeAddress back to its object form- Parameters:
str- The string to parse- Returns:
- A new NodeAddress created from a String form
- Throws:
java.lang.IllegalArgumentException- Thrown if the string is not for a recognised protocol.
-
installProtocol
public static void installProtocol(java.lang.String name, ProtocolID protocol)Installs a new Protocol on the Node- Parameters:
name- Name of the protocol to installprotocol- ProtocolID installed
-
-