Class StringID

  • All Implemented Interfaces:
    java.lang.Cloneable, java.lang.Comparable<java.lang.Object>, ID

    public class StringID
    extends java.lang.Object
    implements ID
    An implementation of the ID interface providing uniqueness and identifiability through strings. The strings used to establish the uniqueness of this id may differ from the strings specified with the constructor of a StringID object. I.e. although with String s1 and s2 s1.equals(s2) is false (new StringID(s1)).equals(new StringID(s2)) may be true. Two StringID objects are regarded as equal when s1 differs from s2 only in case or the umlaut expansion of s1 equals s2 (or vice versa).
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.String id
      The string used to establish the uniqueness of this ID.
      protected java.lang.String originalString
      The string specified at construction time of this object.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected StringID​(java.lang.String i)
      Creates a new StringID object.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      StringID clone()
      Returns a copy of this string id object.
      int compareTo​(java.lang.Object o)
      Performs a lexicographical comparision between this object and another instance of class StringID.
      static StringID create​(java.lang.String o)
      Returns a (possibly) new StringID object.
      boolean equals​(java.lang.Object o)
      Indicates whether this id is "equal to" some other object.
      int hashCode()
      Returns a hash code based on the identifying string.
      java.lang.String toString()
      Returns the string used to construct this StringID object.
      java.lang.String toString​(java.lang.String delim)
      Returns a String representation of the ID formatted in a user friendly manner with a given separator.
      • Methods inherited from class java.lang.Object

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

      • id

        protected final java.lang.String id
        The string used to establish the uniqueness of this ID.
      • originalString

        protected final java.lang.String originalString
        The string specified at construction time of this object.
    • Constructor Detail

      • StringID

        protected StringID​(java.lang.String i)
        Creates a new StringID object. See the class description on how the specified string is used to establish the uniqueness of this id.
        Throws:
        java.lang.IllegalArgumentException - If i is null or empty
    • Method Detail

      • create

        public static StringID create​(java.lang.String o)
        Returns a (possibly) new StringID object.
        Throws:
        java.lang.NullPointerException - If o==null
      • toString

        public java.lang.String toString()
        Returns the string used to construct this StringID object.
        Specified by:
        toString in interface ID
        Overrides:
        toString in class java.lang.Object
        Returns:
        a String representation of the ID formatted in a user friendly manner.
      • toString

        public java.lang.String toString​(java.lang.String delim)
        Description copied from interface: ID
        Returns a String representation of the ID formatted in a user friendly manner with a given separator. Right now only Coordinate should implement this, all others should invoke toString()!
        Specified by:
        toString in interface ID
        Returns:
        a String representation of the ID formatted in a user friendly manner.
        See Also:
        ID.toString(java.lang.String)
      • equals

        public boolean equals​(java.lang.Object o)
        Indicates whether this id is "equal to" some other object. For equality rules see the class description, of course o must be an instance of StringID.
        Specified by:
        equals in interface ID
        Overrides:
        equals in class java.lang.Object
        Parameters:
        o - the reference object with which to compare.
        Returns:
        true if this object is the same as the obj argument; false otherwise.
      • hashCode

        public int hashCode()
        Returns a hash code based on the identifying string.
        Specified by:
        hashCode in interface ID
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        a hash code value for this object.
      • compareTo

        public int compareTo​(java.lang.Object o)
        Performs a lexicographical comparision between this object and another instance of class StringID.
        Specified by:
        compareTo in interface java.lang.Comparable<java.lang.Object>
        Specified by:
        compareTo in interface ID
      • clone

        public StringID clone()
                       throws java.lang.CloneNotSupportedException
        Returns a copy of this string id object.
        Specified by:
        clone in interface ID
        Overrides:
        clone in class java.lang.Object
        Throws:
        java.lang.CloneNotSupportedException - DOCUMENT-ME