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.
See Also:
  • Field Details

    • protocol

      protected String protocol
      String representing the protocol in used
    • address

      protected String address
      String representation of the address
    • installedProtocols

      private static Hashtable installedProtocols
      The table of installed protocols on this Node
  • Constructor Details

    • NodeAddress

      public NodeAddress()
  • Method Details

    • 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]
      Overrides:
      toString in class Object
      Returns:
      A String representation of this NodeAddress
    • hashCode

      public int hashCode()
      Gets the hash code of this object
      Overrides:
      hashCode in class Object
      Returns:
      Hashcode for this NodeAddress
    • equals

      public boolean equals(Object obj)
      Checks if this NodeAddress is equal to another
      Overrides:
      equals in class Object
      Parameters:
      obj - The NodeAddress to compare to
      Returns:
      True if object is equal to this NodeAddress, false otherwise
    • compareTo

      public int compareTo(Object arg0)
      Compares this NodeAddress to another
      Specified by:
      compareTo in interface 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(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 install
      protocol - ProtocolID installed