Package org.jcsp.net

Class NodeAddressID

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable
    Direct Known Subclasses:
    TCPIPAddressID

    public abstract class NodeAddressID
    extends java.lang.Object
    implements java.io.Serializable, java.lang.Cloneable

    JCSP.NET communication protocol implementations must provide a concrete implementation of this class. The instances of the class implementations should hold address information for JCSP Node LinkServer processes. For example, a TCP/IP implementation would most likely hold an IP address and port number.

    There is no defined way in this class as to how NodeAddressID objects should be created. The JCSP infrastructure never looks at the underlying address information, it simply needs to be able compare one address with another. The equals(Object) should be implemented in such a way that this can be achieved.

    Implementations of the ProtocolID class should implement the createAddressID(String, boolean) method so that NodeAddressID objects for that protocol can be created from a String. The boolean parameter indicates whether or not the address is globally unique.

    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      NodeAddressID()  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      java.lang.Object clone()
      Returns a clone of the instance of the class implementing this interface.
      abstract boolean equals​(java.lang.Object obj)
      Compares the instance of the class implementing this interface with another object.
      protected static NodeAddressID getAddressIDFromString​(java.lang.String stringForm)
      This is is a static method that should be overriden by concrete implementations of this class.
      abstract ProtocolID getProtocolID()
      Returns the ProtocolID for the protocol that is associated with this NodeAddressID.
      protected abstract java.lang.String getStringForm()
      Deprecated.
      This is going to be removed from the API.
      abstract int hashCode()
      Returns a hash code for this object.
      abstract boolean isGloballyUnique()
      Returns true if this NodeAddressID is known to be unique within the global org.jcsp.net domain.
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • NodeAddressID

        public NodeAddressID()
    • Method Detail

      • equals

        public abstract boolean equals​(java.lang.Object obj)

        Compares the instance of the class implementing this interface with another object. This should return true if the other object represents the same address.

        Overrides:
        equals in class java.lang.Object
        Parameters:
        obj - another object that should be another NodeAddressID.
        Returns:
        true if the other object is another NodeAddressID representing the same address.
      • hashCode

        public abstract int hashCode()

        Returns a hash code for this object. Two NodeAddressID objects should return the same hash code if they equal as governed by the rules for the equals(Object) method.

        Overrides:
        hashCode in class java.lang.Object
        Returns:
        an int hash code.
      • clone

        public java.lang.Object clone()
                               throws java.lang.CloneNotSupportedException

        Returns a clone of the instance of the class implementing this interface.

        Overrides:
        clone in class java.lang.Object
        Returns:
        a clone of the object that this is being called on.
        Throws:
        java.lang.CloneNotSupportedException - if the implementation class does not support the clone method.
      • getProtocolID

        public abstract ProtocolID getProtocolID()
        Returns the ProtocolID for the protocol that is associated with this NodeAddressID.
        Returns:
        this NodeAddressID object's ProtocolID.
      • isGloballyUnique

        public abstract boolean isGloballyUnique()

        Returns true if this NodeAddressID is known to be unique within the global org.jcsp.net domain.

        A Node may have several addresses. If a Node is on an internal network that is connected to the Internet, it may have one local address and one address that is accessible from the Internet. The Internet address may be globally unique whereas the local address may be duplicated in other internal networks. The NodeAddressID object representing the Internet address should return true when this method is called whereas the NodeAddressID representing the local address should return false.

        Returns:
        true iff this NodeAddressID is globally unique.
      • getStringForm

        protected abstract java.lang.String getStringForm()
        Deprecated.
        This is going to be removed from the API. The purpose of this mechanism was so that channel information could be encoded into anonymous channels' channel names.

        Returns a String that contains all information necessary for reconstucting this object from a String. The object is reconstructed by calling the static getAddressIDFromString(String) method.

        Returns:
        a String that can be passed to the static getAddressIDFromString(String) method in order to reconstuct the object.
      • getAddressIDFromString

        protected static NodeAddressID getAddressIDFromString​(java.lang.String stringForm)
                                                       throws java.lang.IllegalArgumentException

        This is is a static method that should be overriden by concrete implementations of this class. Ideally this method would be abstract but the language does not allow abstract static methods.

        The method constructs a NodeAddressID object from a String that is in the form of that returned by the getStringForm() method. The object returned by this method should equal the object that returned the String when its getStringForm() methdo was called.

        Parameters:
        stringForm - the String used to construct the NodeAddressID.
        Returns:
        a newly constructed NodeAddressID object.
        Throws:
        java.lang.IllegalArgumentException - if the String supplied is invalid.