org.apache.jdo.impl.fostore
Class AID

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

public class AID
extends OID

Represents the identity of a JDO object in the File/Object store. This implementation uses application identity. The identity is based on the class of the object and a byte[] buffer that represents values in the user object Id instance which creates a unique identifier within that class. These ID's are unique only within a single datastore.

Author:
Marina Vatkina
See Also:
Serialized Form

Field Summary
private  byte[] buffer
           
private  int hashCode
           
private static char[] hexDigit
          A table of hex digits
private static javax.jdo.spi.JDOImplHelper jdoImplHelper
          JDOImplHelper instance
private static org.apache.jdo.util.I18NHelper msg
          I18N support.
private  long sCLIDBits
           
 
Fields inherited from class org.apache.jdo.impl.fostore.OID
CLID_MASK, CLID_SHIFT, logger, MAX_CLID, MAX_UID, oid, PROV_CLID_MASK, PROV_UID_MASK, RESERVED_MASK, RESERVED_SHIFT, UID_MASK
 
Constructor Summary
AID()
          Default constructor.
AID(long oid)
          Creates an AID with the given value.
 
Method Summary
private  long computeUID()
          Compute unique user Id from the buffer.
(package private)  OID copy()
          Returns copy of the requested oid.
(package private)  void copyKeyFieldsToPC(org.apache.jdo.state.StateManagerInternal sm, FOStorePMF pmf, java.lang.Class pcClass, int[] pkfields)
          Copy key fields from OID into PC instance.
(package private) static AID create(java.lang.Class pcClass, javax.jdo.spi.PersistenceCapable pc, java.lang.Object userOid, org.apache.jdo.pm.PersistenceManagerInternal pm, FOStorePMF pmf)
          Create and return a new instance of AID.
private  void createBuffer(java.lang.Object userOid, java.lang.Class pcClass, FOStorePMF pmf, boolean fromPC, javax.jdo.spi.PersistenceCapable pc)
           
 boolean equals(java.lang.Object other)
          Determines if this AID is equal to another.
(package private)  java.lang.Object getExternalObjectId(javax.jdo.spi.PersistenceCapable pc)
          Returns copy of the requested oid to be accessed by the user.
 int hashCode()
          Provides a unique hashCode for this AID.
(package private)  boolean isApplicationIdentity()
          Returns true for application identity type for this OID.
(package private)  boolean isDataStoreIdentity()
          Returns false for datastore identity type for this OID.
 java.lang.String oidString()
          Returns the id itself in String form, for debugging.
(package private)  void readBuffer(java.io.DataInput in)
          Reads AID buffer's value from the input stream.
 void readObject(java.io.ObjectInputStream in)
          Reads this AID's value from the input stream.
(package private)  void replaceProvisionalOIDWithReal(OID realOID, FOStorePMF pmf, org.apache.jdo.state.StateManagerInternal sm)
          Replaces provisional oid with real oid (datastore identity only)
private  void setSuperCLIDBits(java.lang.Class pcClass, java.lang.Class keyClass, org.apache.jdo.pm.PersistenceManagerInternal pm, FOStorePMF pmf)
          Sets CLID bits for the superclass that corresponds to the user defined key class.
private static java.lang.String toHexString(int b)
          Covert byte into 2-digit hexadecimal String.
 java.lang.String toString()
          Returns a String representation of this AID.
(package private)  void write(java.io.DataOutput out)
          Writes this AID to the output stream.
 void writeObject(java.io.ObjectOutputStream out)
          Writes this AID to the output stream.
 
Methods inherited from class org.apache.jdo.impl.fostore.OID
compareTo, create, create, create, getCLID, getPCClass, getUID, isProvisional, keyValue, read, skip
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

buffer

private byte[] buffer

hashCode

private int hashCode

sCLIDBits

private long sCLIDBits

msg

private static final org.apache.jdo.util.I18NHelper msg
I18N support.


jdoImplHelper

private static final javax.jdo.spi.JDOImplHelper jdoImplHelper
JDOImplHelper instance


hexDigit

private static final char[] hexDigit
A table of hex digits

Constructor Detail

AID

public AID()
Default constructor.


AID

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

Method Detail

create

static AID create(java.lang.Class pcClass,
                  javax.jdo.spi.PersistenceCapable pc,
                  java.lang.Object userOid,
                  org.apache.jdo.pm.PersistenceManagerInternal pm,
                  FOStorePMF pmf)
Create and return a new instance of AID.

Returns:
a new instance of AID.

equals

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

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

toString

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

Overrides:
toString in class OID

oidString

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

Overrides:
oidString in class OID

hashCode

public int hashCode()
Provides a unique hashCode for this AID.

Overrides:
hashCode in class OID

isApplicationIdentity

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

Overrides:
isApplicationIdentity in class OID

isDataStoreIdentity

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

Overrides:
isDataStoreIdentity in class OID

getExternalObjectId

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

Overrides:
getExternalObjectId in class OID

writeObject

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

Throws:
java.io.IOException

readObject

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

Throws:
java.io.IOException

write

void write(java.io.DataOutput out)
     throws java.io.IOException
Writes this AID to the output stream.

Overrides:
write in class OID
Throws:
java.io.IOException

readBuffer

void readBuffer(java.io.DataInput in)
          throws java.io.IOException
Reads AID buffer's value from the input stream.

Throws:
java.io.IOException

replaceProvisionalOIDWithReal

void replaceProvisionalOIDWithReal(OID realOID,
                                   FOStorePMF pmf,
                                   org.apache.jdo.state.StateManagerInternal sm)
Replaces provisional oid with real oid (datastore identity only)

Overrides:
replaceProvisionalOIDWithReal in class OID
Parameters:
realOID - as OID instance
pmf - as FOStorePMF
sm - as StateManagerInternal

copy

OID copy()
Returns copy of the requested oid.

Overrides:
copy in class OID

copyKeyFieldsToPC

void copyKeyFieldsToPC(org.apache.jdo.state.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.

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

createBuffer

private void createBuffer(java.lang.Object userOid,
                          java.lang.Class pcClass,
                          FOStorePMF pmf,
                          boolean fromPC,
                          javax.jdo.spi.PersistenceCapable pc)

setSuperCLIDBits

private void setSuperCLIDBits(java.lang.Class pcClass,
                              java.lang.Class keyClass,
                              org.apache.jdo.pm.PersistenceManagerInternal pm,
                              FOStorePMF pmf)
Sets CLID bits for the superclass that corresponds to the user defined key class.

Parameters:
pcClass - the class of the persisntence-capable instance or null if not known.
keyClass - the class of the user defined key or null if not known.
pm - the PersistenceManagerInternal that requested the operation.
pmf - the FOStorePMF that requested the operation.

computeUID

private long computeUID()
Compute unique user Id from the buffer.


toHexString

private static java.lang.String toHexString(int b)
Covert byte into 2-digit hexadecimal String.