Package org.jcsp.net

Class ProtocolID

  • All Implemented Interfaces:
    java.io.Serializable
    Direct Known Subclasses:
    TCPIPProtocolID

    public abstract class ProtocolID
    extends java.lang.Object
    implements java.io.Serializable

    Abstract class that identifies a protocol. Provides methods for obtaining the protocol's Builder to be installed in the LinkFactory, starting a LinkServer for this protocol and for creating a NodeAddressID for this protocol from a String.

    Protocols must not make use of the NodeID so that protocols can be installed before the node ID is determined. The current definition of TCPIPv4 protocol meets this criteria. Such a change will allow the UIFactory or other initialisation details to be obtained from a central server.

    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int position
      The position in the order of preference of protocols.
    • Constructor Summary

      Constructors 
      Constructor Description
      ProtocolID()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract NodeAddressID createAddressID​(java.lang.String stAddressID, boolean uniqueAddress)
      Constructs a NodeAddressID from a String.
      boolean equals​(java.lang.Object o)
      This tests whether another object is equal to this object.
      protected abstract LinkFactory.Builder getLinkBuilder​(java.util.Hashtable settings)
      Obtains the Builder for this protocol.
      int getPosition()
      Gets the position of this protocol in the order of preference.
      int hashCode()
      Returns a hash code for this object.
      abstract boolean isActive()
      Not currently used.
      abstract boolean requiresUserInteraction()
      Returns whether the protocol requires user interaction in order for data to be delivered.
      (package private) void setPosition​(int position)
      Sets the position of this protocol in the order of general preference.
      protected abstract LinkServer startLinkServer​(NodeAddressID addressID)
      Constructs, starts and returns a LinkServer on a specified NodeAddressID.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • position

        private int position
        The position in the order of preference of protocols.
    • Constructor Detail

      • ProtocolID

        public ProtocolID()
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object o)
        This tests whether another object is equal to this object. Two ProtocolID objects are equal if their classes are the same. This is a default implementation, it is probably more efficient to override this with an implementation that uses the instanceof operator.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        o - an object to compare with this object.
        Returns:
        true iff the supplied object's class is the same as the class of this object.
      • hashCode

        public final int hashCode()
        Returns a hash code for this object.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        the hash code for the object.
      • isActive

        public abstract boolean isActive()

        Not currently used.

        This is envisaged to be used if a protocol that is in use and needs to be removed sometime in the future. This will stop any further use of the protocol.

        Returns:
        boolean indicating whether protocol is active.
      • requiresUserInteraction

        public abstract boolean requiresUserInteraction()

        Returns whether the protocol requires user interaction in order for data to be delivered. There could be a protocol that writes data out to floppy disk or CD-R (see Tanenbaum's example of bandwidth and lorry!).

        Returns:
        boolean indicating whether user interaction is required.
      • setPosition

        final void setPosition​(int position)
        Sets the position of this protocol in the order of general preference.
        Parameters:
        position - the position of this protocol in the order.
      • getPosition

        public final int getPosition()
        Gets the position of this protocol in the order of preference.
        Returns:
        the order of preference as an int.
      • getLinkBuilder

        protected abstract LinkFactory.Builder getLinkBuilder​(java.util.Hashtable settings)
        Obtains the Builder for this protocol. Provides a Hashtable that can can contain settings needed to construct the Link.
        Parameters:
        settings - Hashtable containing settings.
        Returns:
        the Builder for constructing Links.
      • startLinkServer

        protected abstract LinkServer startLinkServer​(NodeAddressID addressID)
                                               throws java.lang.IllegalArgumentException

        Constructs, starts and returns a LinkServer on a specified NodeAddressID.

        Parameters:
        addressID - The address for the server to listen on.
        Returns:
        the constructed LinkServer
        Throws:
        java.lang.IllegalArgumentException - if the supplied NodeAddressID is invalid.
      • createAddressID

        protected abstract NodeAddressID createAddressID​(java.lang.String stAddressID,
                                                         boolean uniqueAddress)
                                                  throws java.lang.IllegalArgumentException
        Constructs a NodeAddressID from a String.
        Parameters:
        stAddressID - The address in String form.
        uniqueAddress - boolean indicating whether address is unique.
        Returns:
        the constructed NodeAddressID
        Throws:
        java.lang.IllegalArgumentException - if the String supplied is invalid.