org.apache.jdo.impl.fostore
Class OID

java.lang.Object
  extended byorg.apache.jdo.impl.fostore.OID
All Implemented Interfaces:
java.lang.Comparable, java.io.Serializable
Direct Known Subclasses:
AID

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

Represents the identity of a JDO object in the File/Object store. This implementation uses datastore identity. The identity is based on the class of the object and a unique identifier within that class. These OID's are unique only within a single datastore.

This class is public as required by the JDO specification.

Version:
1.0.1
Author:
Dave Bristor
See Also:
Serialized Form

Field Summary
(package private) static long CLID_MASK
           
(package private) static int CLID_SHIFT
           
private  int hashCode
           
private static java.lang.Integer lock
           
(package private) static org.apache.commons.logging.Log logger
          Logger
(package private) static int MAX_CLID
           
(package private) static long MAX_UID
           
(package private) static I18NHelper msg
          I18N support.
private static long nextProvisional
           
 long oid
          The 'value' of this OID.
private  java.lang.Class pcClass
           
(package private) static long PROV_CLID_MASK
           
(package private) static long PROV_UID_MASK
           
(package private) static long RESERVED_MASK
           
(package private) static int RESERVED_SHIFT
           
(package private) static long UID_MASK
           
 
Constructor Summary
  OID()
          Creates an OID with the no value.
private OID(CLID clid)
           
  OID(long oid)
          Creates an OID with the given value.
  OID(java.lang.String str)
          Constructor that takes the result of toString() and creates a new OID.
 
Method Summary
 int compareTo(java.lang.Object obj)
          Compare this OID to another OID.
(package private)  OID copy()
          Returns copy of the requested oid.
(package private)  void copyKeyFieldsToPC(StateManagerInternal sm, FOStorePMF pmf, java.lang.Class pcClass, int[] pkfields)
          Copy key fields from OID into PC instance.
(package private) static OID create(CLID clid)
          Create and return a provisional OID
(package private) static OID create(CLID clid, long uid)
          Provides an OID for the given CLID and UID.
(package private)  OID create(long oid)
          Create and return a based on a given representation.
 boolean equals(java.lang.Object other)
          Determines if this OID is equal to another.
 CLID getCLID()
          Provides the CLID part of this OID.
(package private)  java.lang.Object getExternalObjectId(javax.jdo.spi.PersistenceCapable pc)
          Returns copy of the requested oid to be accessed by the user.
(package private)  java.lang.Class getPCClass(FOStorePMF pmf)
          Returns Class that defined OID.
 long getUID()
          Provides the unique id part of this OID.
 int hashCode()
          Provides a JVM-unique hashCode for this OID.
(package private)  boolean isApplicationIdentity()
          Returns false for application identity type for this OID.
(package private)  boolean isDataStoreIdentity()
          Returns true for datastore identity type for this OID.
 boolean isProvisional()
          Indicates whether this OID is provisional.
(package private)  org.netbeans.mdr.persistence.MOFID keyValue(FOStoreBtreeStorage storage)
          Provides the OID in a form that can be used by the database as a key.
 java.lang.String oidString()
          Returns the id itself in String form, for debugging.
(package private) static OID read(java.io.DataInput in)
           
private  void readObject(java.io.ObjectInputStream in)
          Reads this OID's value from the input stream.
(package private)  void replaceProvisionalOIDWithReal(OID realOID, FOStorePMF pmf, StateManagerInternal sm)
          Replaces provisional oid with real oid (datastore identity only)
(package private) static void skip(java.io.DataInput in)
          Skip OID bytes from the input.
 java.lang.String toString()
          Returns a String representation of this OID.
(package private)  void write(java.io.DataOutput out)
           
private  void writeObject(java.io.ObjectOutputStream out)
          Writes this OID to the output stream.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

RESERVED_MASK

static final long RESERVED_MASK
See Also:
Constant Field Values

PROV_UID_MASK

static final long PROV_UID_MASK
See Also:
Constant Field Values

PROV_CLID_MASK

static final long PROV_CLID_MASK
See Also:
Constant Field Values

CLID_MASK

static final long CLID_MASK
See Also:
Constant Field Values

UID_MASK

static final long UID_MASK
See Also:
Constant Field Values

CLID_SHIFT

static final int CLID_SHIFT
See Also:
Constant Field Values

MAX_CLID

static final int MAX_CLID
See Also:
Constant Field Values

MAX_UID

static final long MAX_UID
See Also:
Constant Field Values

RESERVED_SHIFT

static final int RESERVED_SHIFT
See Also:
Constant Field Values

oid

public long oid
The 'value' of this OID.


hashCode

private int hashCode

nextProvisional

private static long nextProvisional

pcClass

private java.lang.Class pcClass

lock

private static final java.lang.Integer lock

msg

static final I18NHelper msg
I18N support.


logger

static final org.apache.commons.logging.Log logger
Logger

Constructor Detail

OID

public OID()
Creates an OID with the no value.


OID

public OID(java.lang.String str)
Constructor that takes the result of toString() and creates a new OID. Currently only the CLID and UID are used. The provisional bits are ignored.

See Also:
toString()

OID

public OID(long oid)
Creates an OID with the given value.


OID

private OID(CLID clid)
Method Detail

create

static OID create(CLID clid)
Create and return a provisional OID

Returns:
A Provisional OID.

create

OID create(long oid)
Create and return a based on a given representation.

Returns:
A real, non-provisional OID.
Throws:
javax.jdo.JDOFatalException - Thrown if given oid has its provisional bit set.

create

static OID create(CLID clid,
                  long uid)
Provides an OID for the given CLID and UID. The given CLID must not be provisional, or a JDOFatalException will result.

Parameters:
clid - CLID for the OID.
uid - UID part of the OID.
Returns:
A new OID based on the given clid and uid.
Throws:
javax.jdo.JDOFatalException - Thrown if given CLID is provisional.

isProvisional

public boolean isProvisional()
Indicates whether this OID is provisional.

Returns:
true if this OID is provisional, false otherwise.

getCLID

public CLID getCLID()
Provides the CLID part of this OID. The resulting CLID is provisional if it is provisional within this OID. I.e., this might be a provisional OID, but the CLID part could still be datastore-assigned.

Returns:
The CLID part of this OID.

getUID

public long getUID()
Provides the unique id part of this OID.

Returns:
The unique id part of this OID.

hashCode

public int hashCode()
Provides a JVM-unique hashCode for this OID.


equals

public boolean equals(java.lang.Object other)
Determines if this OID is equal to another.

Parameters:
other - The other OID in the equality comparison.
Returns:
True if they are equal, false otherwise.

toString

public java.lang.String toString()
Returns a String representation of this OID. Includes whether or not the OID is provisional, and its reserved bits, if they are set.


oidString

public java.lang.String oidString()
Returns the id itself in String form, for debugging.


writeObject

private void writeObject(java.io.ObjectOutputStream out)
                  throws java.io.IOException
Writes this OID to the output stream.

Throws:
java.io.IOException

readObject

private void readObject(java.io.ObjectInputStream in)
                 throws java.io.IOException
Reads this OID's value from the input stream.

Throws:
java.io.IOException

write

void write(java.io.DataOutput out)
     throws java.io.IOException
Throws:
java.io.IOException

read

static OID read(java.io.DataInput in)
         throws java.io.IOException
Throws:
java.io.IOException

skip

static void skip(java.io.DataInput in)
          throws java.io.IOException
Skip OID bytes from the input.

Parameters:
in - DataInput.
Throws:
IOException.
java.io.IOException

getExternalObjectId

java.lang.Object getExternalObjectId(javax.jdo.spi.PersistenceCapable pc)
Returns copy of the requested oid to be accessed by the user.


keyValue

org.netbeans.mdr.persistence.MOFID keyValue(FOStoreBtreeStorage storage)
Provides the OID in a form that can be used by the database as a key.


replaceProvisionalOIDWithReal

void replaceProvisionalOIDWithReal(OID realOID,
                                   FOStorePMF pmf,
                                   StateManagerInternal sm)
Replaces provisional oid with real oid (datastore identity only)

Parameters:
realOID - as OID instance
pmf - as FOStorePMF
sm - as StateManagerInternal

copy

OID copy()
Returns copy of the requested oid.


copyKeyFieldsToPC

void copyKeyFieldsToPC(StateManagerInternal sm,
                       FOStorePMF pmf,
                       java.lang.Class pcClass,
                       int[] pkfields)
Copy key fields from OID into PC instance. No-op for the datastore identity type for this OID.

Parameters:
sm - as StateManagerInternal
pmf - as FOStorePMF
pcClass - Class of the PC instance.
pkfields - array of PK field numbers.

getPCClass

java.lang.Class getPCClass(FOStorePMF pmf)
Returns Class that defined OID.

Parameters:
pmf - as FOStorePMF

isApplicationIdentity

boolean isApplicationIdentity()
Returns false for application identity type for this OID.


isDataStoreIdentity

boolean isDataStoreIdentity()
Returns true for datastore identity type for this OID.


compareTo

public int compareTo(java.lang.Object obj)
Compare this OID to another OID. This is needed to implement an absolute ordering of OIDs. The ordering must provide for comparing provisional OIDs to permanent OIDs, with all provisional OIDs comparing greater than all permanent OIDs.

Specified by:
compareTo in interface java.lang.Comparable
Since:
1.0.1