Class ObjectId

All Implemented Interfaces:
Externalizable, Serializable, Comparable<ObjectId>

public class ObjectId extends SingleFieldId<Object,ObjectId>
This class is for identity with a single Object type field.
See Also:
  • Field Details

    • key

      private Object key
    • stringConstructorMap

      static final Map<Class,ObjectId.StringConstructor> stringConstructorMap
      Special StringConstructor instances for use with specific classes that have no public String constructor. The Map is keyed on class instance and the value is an instance of StringConstructor.
    • dateFormat

      private static DateFormat dateFormat
      The default DateFormat instance for handling java.util.Date instances.
  • Constructor Details

    • ObjectId

      public ObjectId(Class<?> pcClass, Object param)
      Constructor with class and key.
      Parameters:
      pcClass - the class
      param - the key
    • ObjectId

      public ObjectId()
  • Method Details

    • getKey

      public Object getKey()
    • getKeyAsObject

      public Object getKeyAsObject()
      Description copied from class: SingleFieldId
      Accessor for the key
      Specified by:
      getKeyAsObject in class SingleFieldId<Object,ObjectId>
      Returns:
      The key
    • toString

      public String toString()
      Return the String form of the object id. The class of the object id is written as the first part of the result so that the class can be reconstructed later. Then the toString of the key instance is appended. During construction, this process is reversed. The class is extracted from the first part of the String, and the String constructor of the key is used to construct the key itself.
      Overrides:
      toString in class Object
      Returns:
      the String form of the key
    • keyEquals

      protected boolean keyEquals(ObjectId obj)
      Specified by:
      keyEquals in class SingleFieldId<Object,ObjectId>
    • compareTo

      public int compareTo(ObjectId other)
    • writeExternal

      public void writeExternal(ObjectOutput out) throws IOException
      Write this object. Write the superclass first.
      Specified by:
      writeExternal in interface Externalizable
      Overrides:
      writeExternal in class SingleFieldId<Object,ObjectId>
      Parameters:
      out - the output
      Throws:
      IOException
    • readExternal

      public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
      Read this object. Read the superclass first.
      Specified by:
      readExternal in interface Externalizable
      Overrides:
      readExternal in class SingleFieldId<Object,ObjectId>
      Parameters:
      in - the input
      Throws:
      IOException
      ClassNotFoundException
    • registerStringConstructor

      public static Object registerStringConstructor(Class cls, ObjectId.StringConstructor sc)
      Register special StringConstructor instances. These instances are for constructing instances from String parameters where there is no String constructor for them.
      Parameters:
      cls - the class to register a StringConstructor for
      sc - the StringConstructor instance
      Returns:
      the previous StringConstructor registered for this class
    • constructKey

      public static Object constructKey(String className, String keyString)
      Construct an instance of the parameter class, using the keyString as an argument to the constructor. If the class has a StringConstructor instance registered, use it. If not, try to find a constructor for the class with a single String argument. Otherwise, throw a NucleusUserException.
      Parameters:
      className - the name of the class
      keyString - the String parameter for the constructor
      Returns:
      the result of construction