Package org.jcsp.net2
Class NodeAddress
- java.lang.Object
-
- org.jcsp.net2.NodeAddress
-
- All Implemented Interfaces:
Serializable
,Comparable
- Direct Known Subclasses:
TCPIPNodeAddress
public abstract class NodeAddress extends Object implements Serializable, Comparable
This 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.- Author:
- Kevin Chalmers (updated from Quickstone Technologies)
- See Also:
Node
, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description NodeAddress()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description int
compareTo(Object arg0)
Compares this NodeAddress to anotherprotected abstract Link
createLink()
Creates a Link connected to this addressprotected abstract LinkServer
createLinkServer()
Creates a LinkServer listening on this addressboolean
equals(Object obj)
Checks if this NodeAddress is equal to anotherString
getAddress()
Gets a string representing the addressString
getProtocol()
Gets the string representing the protocolprotected abstract ProtocolID
getProtocolID()
Retrieves the correct protocol handler for the implemented address type.int
hashCode()
Gets the hash code of this objectstatic void
installProtocol(String name, ProtocolID protocol)
Installs a new Protocol on the Nodestatic NodeAddress
parse(String str)
Parses a string representation of a NodeAddress back to its object formString
toString()
Converts the NodeAddress into a String.
-
-
-
Method Detail
-
getProtocol
public String getProtocol()
Gets the string representing the protocol- Returns:
- The String representation of the protocol part of the NodeAddress
-
getAddress
public String getAddress()
Gets a string representing the address- Returns:
- The String representation of the address part of the NodeAddress
-
toString
public String toString()
Converts the NodeAddress into a String. The form is [protocol]\\[address]
-
hashCode
public int hashCode()
Gets the hash code of this object
-
equals
public boolean equals(Object obj)
Checks if this NodeAddress is equal to another
-
compareTo
public int compareTo(Object arg0)
Compares this NodeAddress to another- Specified by:
compareTo
in interfaceComparable
- 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(String str) throws 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:
IllegalArgumentException
- Thrown if the string is not for a recognised protocol.
-
installProtocol
public static void installProtocol(String name, ProtocolID protocol)
Installs a new Protocol on the Node- Parameters:
name
- Name of the protocol to installprotocol
- ProtocolID installed
-
-