org.datanucleus.identity
Class DatastoreUniqueOID

java.lang.Object
  extended by org.datanucleus.identity.DatastoreUniqueOID
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable, OID

public class DatastoreUniqueOID
extends java.lang.Object
implements java.io.Serializable, OID, java.lang.Comparable

Identity for use with datastore-identity where the datastore provides a unique "identity" key per object and hence doesn't need the class name. The behaviour of this class is governed by JDO spec 5.4.3. Main benefit over OIDImpl is size.

See Also:
Serialized Form

Field Summary
 long key
          The key value.
 
Constructor Summary
DatastoreUniqueOID()
          Creates an OID with no value.
DatastoreUniqueOID(long key)
          Constructor taking the long form of the key.
DatastoreUniqueOID(java.lang.String str)
          Constructs an OID from its string representation that is consistent with the output of toString().
 
Method Summary
 int compareTo(java.lang.Object o)
          Comparator method.
 boolean equals(java.lang.Object obj)
          Equality operator.
 long getKey()
          Convenience accessor for the long form of the key.
 java.lang.Object getKeyValue()
          Accessor for the key value.
 java.lang.String getPcClass()
          Accessor for the PersistenceCapable class name.
 int hashCode()
          Accessor for the hashcode
 java.lang.String toString()
          Creates a String representation of the datastore identity, formed from the key value.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

key

public final long key
The key value.

Constructor Detail

DatastoreUniqueOID

public DatastoreUniqueOID()
Creates an OID with no value. Required by the JDO spec.


DatastoreUniqueOID

public DatastoreUniqueOID(long key)
Constructor taking the long form of the key.

Parameters:
key - The key

DatastoreUniqueOID

public DatastoreUniqueOID(java.lang.String str)
                   throws java.lang.IllegalArgumentException
Constructs an OID from its string representation that is consistent with the output of toString().

Parameters:
str - the string representation of an OID
Throws:
java.lang.IllegalArgumentException - if the given string representation is not valid.
See Also:
toString()
Method Detail

getKeyValue

public java.lang.Object getKeyValue()
Accessor for the key value.

Specified by:
getKeyValue in interface OID
Returns:
The key value

getKey

public long getKey()
Convenience accessor for the long form of the key.

Returns:
long primitive form of the key

getPcClass

public java.lang.String getPcClass()
Accessor for the PersistenceCapable class name.

Specified by:
getPcClass in interface OID
Returns:
PC class name

equals

public boolean equals(java.lang.Object obj)
Equality operator.

Specified by:
equals in interface OID
Overrides:
equals in class java.lang.Object
Parameters:
obj - Object to compare against
Returns:
Whether they are equal

compareTo

public int compareTo(java.lang.Object o)
Comparator method.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - The object to compare against
Returns:
The comparison result

hashCode

public int hashCode()
Accessor for the hashcode

Specified by:
hashCode in interface OID
Overrides:
hashCode in class java.lang.Object
Returns:
Hashcode for this object

toString

public java.lang.String toString()
Creates a String representation of the datastore identity, formed from the key value. This will be something like
3254

Specified by:
toString in interface OID
Overrides:
toString in class java.lang.Object
Returns:
The String form of the identity


Copyright © 2009. All Rights Reserved.