Package javax.jdo.identity
Class ObjectIdentity
- java.lang.Object
-
- javax.jdo.identity.SingleFieldIdentity
-
- javax.jdo.identity.ObjectIdentity
-
- All Implemented Interfaces:
Externalizable,Serializable,Comparable
public class ObjectIdentity extends SingleFieldIdentity
This class is for identity with a single Object type field.- Version:
- 2.0
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class javax.jdo.identity.SingleFieldIdentity
hashCode, keyAsObject, msg
-
-
Constructor Summary
Constructors Constructor Description ObjectIdentity()Constructor only for Externalizable.ObjectIdentity(Class pcClass, Object param)Constructor with class and key.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(Object o)Determine the ordering of identity objects.booleanequals(Object obj)Determine if the other object represents the same object id.ObjectgetKey()Return the key.inthashCode()Provide the hash code for this instance.voidreadExternal(ObjectInput in)Read this object.StringtoString()Return the String form of the object id.voidwriteExternal(ObjectOutput out)Write this object.-
Methods inherited from class javax.jdo.identity.SingleFieldIdentity
assertKeyNotNull, compare, createKeyAsObject, getKeyAsObject, getTargetClass, getTargetClassName, hashClassName, setKeyAsObject
-
-
-
-
Method Detail
-
getKey
public Object getKey()
Return the key.- 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.
-
equals
public boolean equals(Object obj)
Determine if the other object represents the same object id.- Overrides:
equalsin classSingleFieldIdentity- Parameters:
obj- the other object- Returns:
- true if both objects represent the same object id
-
hashCode
public int hashCode()
Provide the hash code for this instance. The hash code is the hash code of the contained key.- Overrides:
hashCodein classSingleFieldIdentity- Returns:
- the hash code
-
compareTo
public int compareTo(Object o)
Determine the ordering of identity objects.- Parameters:
o- Other identity- Returns:
- The relative ordering between the objects
- Since:
- 2.2
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
Write this object. Write the superclass first.- Specified by:
writeExternalin interfaceExternalizable- Overrides:
writeExternalin classSingleFieldIdentity- Parameters:
out- the output- Throws:
IOException
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
Read this object. Read the superclass first.- Specified by:
readExternalin interfaceExternalizable- Overrides:
readExternalin classSingleFieldIdentity- Parameters:
in- the input- Throws:
IOExceptionClassNotFoundException
-
-