Package org.datanucleus.identity
Class ObjectId
- All Implemented Interfaces:
Externalizable
,Serializable
,Comparable<ObjectId>
This class is for identity with a single Object type field.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Construct an instance of a key class using a String as input. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static DateFormat
The default DateFormat instance for handling java.util.Date instances.private Object
(package private) static final Map
<Class, ObjectId.StringConstructor> Special StringConstructor instances for use with specific classes that have no public String constructor.Fields inherited from class org.datanucleus.identity.SingleFieldId
hashCode, STRING_DELIMITER, targetClassName
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
static Object
constructKey
(String className, String keyString) Construct an instance of the parameter class, using the keyString as an argument to the constructor.getKey()
Accessor for the keyprotected boolean
void
Read this object.static Object
Register special StringConstructor instances.toString()
Return the String form of the object id.void
Write this object.Methods inherited from class org.datanucleus.identity.SingleFieldId
assertKeyNotNull, compare, equals, getTargetClassName, hashCode
-
Field Details
-
key
-
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
The default DateFormat instance for handling java.util.Date instances.
-
-
Constructor Details
-
ObjectId
Constructor with class and key.- Parameters:
pcClass
- the classparam
- the key
-
ObjectId
public ObjectId()
-
-
Method Details
-
getKey
-
getKeyAsObject
Description copied from class:SingleFieldId
Accessor for the key- Specified by:
getKeyAsObject
in classSingleFieldId<Object,
ObjectId> - Returns:
- The key
-
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. -
keyEquals
- Specified by:
keyEquals
in classSingleFieldId<Object,
ObjectId>
-
compareTo
-
writeExternal
Write this object. Write the superclass first.- Specified by:
writeExternal
in interfaceExternalizable
- Overrides:
writeExternal
in classSingleFieldId<Object,
ObjectId> - Parameters:
out
- the output- Throws:
IOException
-
readExternal
Read this object. Read the superclass first.- Specified by:
readExternal
in interfaceExternalizable
- Overrides:
readExternal
in classSingleFieldId<Object,
ObjectId> - Parameters:
in
- the input- Throws:
IOException
ClassNotFoundException
-
registerStringConstructor
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 forsc
- the StringConstructor instance- Returns:
- the previous StringConstructor registered for this class
-
constructKey
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 classkeyString
- the String parameter for the constructor- Returns:
- the result of construction
-