Package org.jcsp.net2
Class NodeAddress
java.lang.Object
org.jcsp.net2.NodeAddress
- All Implemented Interfaces:
Serializable
,Comparable
- Direct Known Subclasses:
TCPIPNodeAddress
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.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
Compares this NodeAddress to anotherprotected abstract Link
Creates a Link connected to this addressprotected abstract LinkServer
Creates a LinkServer listening on this addressboolean
Checks if this NodeAddress is equal to anotherGets a string representing the addressGets the string representing the protocolprotected abstract ProtocolID
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
Parses a string representation of a NodeAddress back to its object formtoString()
Converts the NodeAddress into a String.
-
Field Details
-
protocol
String representing the protocol in used -
address
String representation of the address -
installedProtocols
The table of installed protocols on this Node
-
-
Constructor Details
-
NodeAddress
public NodeAddress()
-
-
Method Details
-
getProtocol
Gets the string representing the protocol- Returns:
- The String representation of the protocol part of the NodeAddress
-
getAddress
Gets a string representing the address- Returns:
- The String representation of the address part of the NodeAddress
-
toString
Converts the NodeAddress into a String. The form is [protocol]\\[address] -
hashCode
public int hashCode()Gets the hash code of this object -
equals
Checks if this NodeAddress is equal to another -
compareTo
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
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
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
Retrieves the correct protocol handler for the implemented address type. This is used during Node initialisation- Returns:
- the ProtocolID for this address type
-
parse
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
Installs a new Protocol on the Node- Parameters:
name
- Name of the protocol to installprotocol
- ProtocolID installed
-