org.datanucleus.state
Class AbstractStateManager

java.lang.Object
  extended by org.datanucleus.state.AbstractStateManager
All Implemented Interfaces:
StateManager
Direct Known Subclasses:
JDOStateManagerImpl

public abstract class AbstractStateManager
extends java.lang.Object
implements StateManager

Abstract representation of a StateManager. Provides some of the basic StateManager methods that do very little.


Field Summary
protected  AbstractClassMetaData cmd
          the metadata for the class.
protected  FieldManager currFM
          Current FieldManager.
protected  java.lang.Object currFMmonitor
          monitor to synchronize execution when replacing/providing fields
protected  boolean dirty
          Indicator for whether the persistable instance is dirty.
protected  boolean[] dirtyFields
          indicators for which fields are currently dirty in the persistable instance.
protected  boolean[] loadedFields
          indicators for which fields are currently loaded in the persistable instance.
protected static Localiser LOCALISER
          Localiser for messages.
protected  FetchPlanForClass myFP
          Fetch plan for the class of the managed object.
protected  java.lang.Object myID
          The object identity in the datastore
protected  java.lang.Object myInternalID
          The object identity in the JVM.
protected  LifeCycleState myLC
          The actual LifeCycleState for the persistable instance
protected  ObjectManager myOM
          the Object Manager for this StateManager
protected  javax.jdo.spi.PersistenceCapable myPC
          The PersistenceCapable instance managed by this StateManager
protected  java.lang.Object myVersion
          version field for optimistic transactions
protected  int pcObjectType
          The type of the managed object (0 = PC, 1 = embedded PC, 2 = embedded element, 3 = embedded key, 4 = embedded value.
protected  boolean restoreValues
          Whether to restore values at StateManager.
protected  java.lang.Object transactionalVersion
          version field for optimistic transactions, after a insert/update but not yet committed.
 
Fields inherited from interface org.datanucleus.StateManager
EMBEDDED_COLLECTION_ELEMENT_PC, EMBEDDED_MAP_KEY_PC, EMBEDDED_MAP_VALUE_PC, EMBEDDED_PC, PC
 
Constructor Summary
AbstractStateManager(ObjectManager om, AbstractClassMetaData cmd)
          Constructor.
 
Method Summary
protected  void clearDirtyFlags()
          Method to clear all dirty flags on the object.
protected  void clearDirtyFlags(int[] fields)
          Method to clear all dirty flags on the object.
protected static void clearFlags(boolean[] flags)
          Utility to clear the supplied flags.
protected static void clearFlags(boolean[] flags, int[] fields)
          Utility to clear the supplied flags.
protected abstract  boolean disconnectClone(javax.jdo.spi.PersistenceCapable pc)
          Method to disconnect any cloned persistence capable objects from their StateManager.
protected static boolean equals(java.lang.Object o1, java.lang.Object o2)
          Compares two objects for equality, where one or both of the object references may be null.
 void evict()
          Method to change the object state to evicted.
protected  int[] getAllFieldNumbers()
          returns field numbers of all fields.
 boolean getAllFieldsLoaded()
          Returns whether all fields are loaded.
 boolean getBooleanField(javax.jdo.spi.PersistenceCapable pc, int field, boolean currentValue)
          This method is called by the associated persistable if the value for the specified field is not cached (StateManager.isLoaded() fails).
 byte getByteField(javax.jdo.spi.PersistenceCapable pc, int field, byte currentValue)
          This method is called by the associated PersistenceCapable if the value for the specified field is not cached (StateManager.isLoaded() fails).
protected  CallbackHandler getCallbackHandler()
          returns the handler for callback events.
 char getCharField(javax.jdo.spi.PersistenceCapable pc, int field, char currentValue)
          This method is called by the associated persistable if the value for the specified field is not cached (StateManager.isLoaded() fails).
 AbstractClassMetaData getClassMetaData()
          Accessor for the ClassMetaData for this object.
 java.lang.String[] getDirtyFieldNames()
          Accessor for the names of the fields that are dirty.
 int[] getDirtyFieldNumbers()
          Accessor for the field numbers of all dirty fields.
 boolean[] getDirtyFields()
          Creates a copy of the dirtyFields bitmap.
 double getDoubleField(javax.jdo.spi.PersistenceCapable pc, int field, double currentValue)
          This method is called by the associated persistable if the value for the specified field is not cached (StateManager.isLoaded() fails).
static int[] getFlagsSetTo(boolean[] flags, boolean state)
          Returns an array of integers containing the indices of all elements in flags that are in the state passed as argument.
protected static int[] getFlagsSetTo(boolean[] flags, int[] indices, boolean state)
          Returns an array of integers containing the indices of all elements in flags whose index occurs in indices and whose value is state.
 float getFloatField(javax.jdo.spi.PersistenceCapable pc, int field, float currentValue)
          This method is called by the associated persistable if the value for the specified field is not cached (StateManager.isLoaded() fails).
 int getHighestFieldNumber()
          Accessor for the highest field number in this class
 java.lang.Object getInternalObjectId()
          Accessor for the internal object id of the object we are managing.
 int getIntField(javax.jdo.spi.PersistenceCapable pc, int field, int currentValue)
          This method is called by the associated persistable if the value for the specified field is not cached (StateManager.isLoaded() fails).
 LifeCycleState getLifecycleState()
          Accessor for the LifeCycleState
 java.lang.String[] getLoadedFieldNames()
          Accessor for the names of the fields that are loaded.
 int[] getLoadedFieldNumbers()
          Accessor for the field numbers of all loaded fields in this managed instance.
 boolean[] getLoadedFields()
          Accessor for the fields
 long getLongField(javax.jdo.spi.PersistenceCapable pc, int field, long currentValue)
          This method is called by the associated persistable if the value for the specified field is not cached (StateManager.isLoaded() fails).
 MetaDataManager getMetaDataManager()
          Accessor for the MetaDataManager to use for this object.
protected  int[] getNonPrimaryKeyFieldNumbers()
          returns field numbers of all non-primary-key fields.
protected  boolean[] getNonPrimaryKeyFields()
          returns indicators for which fields are non-primary key fields.
 java.lang.Object getObject()
          Accessor for the Persistent Capable object.
 java.lang.Object getObjectField(javax.jdo.spi.PersistenceCapable pc, int field, java.lang.Object currentValue)
          This method is called by the associated persistable if the value for the specified field is not cached (StateManager.isLoaded() fails).
 ObjectManager getObjectManager()
          Accessor for the ObjectManager for this object.
 int getPcObjectType()
          Accessor for the PC object type (whether it is PC, embedded PC, etc).
protected  int[] getSecondClassMutableFieldNumbers()
          returns field numbers of all second class mutable fields.
protected  boolean[] getSecondClassMutableFields()
          returns indicators for which fields are second-class mutable.
 short getShortField(javax.jdo.spi.PersistenceCapable pc, int field, short currentValue)
          This method is called by the associated persistable if the value for the specified field is not cached (StateManager.isLoaded() fails).
 StoreManager getStoreManager()
          Accessor for the StoreManager used for this object.
 java.lang.String getStringField(javax.jdo.spi.PersistenceCapable pc, int field, java.lang.String currentValue)
          This method is called by the associated persistable if the value for the specified field is not cached (StateManager.isLoaded() fails).
 java.lang.Object getTransactionalVersion(java.lang.Object pc)
          Return the object representing the transactional version of the calling instance.
 java.lang.Object getVersion(javax.jdo.spi.PersistenceCapable pc)
          Return the object representing the version of the calling instance.
protected  void initialiseFieldInformation()
          Convenience method to initialise the field information.
protected  boolean isDefaultFetchGroupLoaded()
          Accessor for whether the DFG fields are loaded.
 boolean isDeleted(javax.jdo.spi.PersistenceCapable pc)
          Tests whether this object has been deleted.
 boolean isDirty(javax.jdo.spi.PersistenceCapable pc)
          Tests whether this object is dirty.
 boolean isEmbedded()
          Convenience accessor for whether this StateManager manages an embedded/serialised object.
protected  boolean isFetchPlanLoaded()
          Accessor for whether the current fetch plan fields are loaded.
 boolean isFieldLoaded(int fieldNumber)
          Accessor for whether a field is currently loaded.
 boolean isNew(javax.jdo.spi.PersistenceCapable pc)
          Tests whether this object has been newly made persistent.
 boolean isPersistent(javax.jdo.spi.PersistenceCapable pc)
          Tests whether this object is persistent.
 boolean isRestoreValues()
          Accessor for the Restore Values flag
 boolean isTransactional(javax.jdo.spi.PersistenceCapable pc)
          Tests whether this object is transactional.
 void makeNontransactional()
          Method to change the object state to nontransactional.
 void makePersistentTransactionalTransient()
          Makes Transactional Transient instances persistent.
protected static java.lang.Object peekField(java.lang.Object obj, java.lang.String fieldName)
          Utility to take a peek at a field in the persistable object.
 void postCommit(Transaction tx)
          This method is invoked just after a commit is performed in a Transaction involving the persistable object managed by this StateManager
protected abstract  void postStateChange()
          Method called after a change in state.
 void preBegin(Transaction tx)
          Method invoked just before a transaction starts for the ObjectManager managing us.
 void preRollback(Transaction tx)
          This method is invoked just before a rollback is performed in a Transaction involving the persistable object managed by this StateManager.
protected abstract  void preStateChange()
          Method called before a change in state.
 void providedBooleanField(javax.jdo.spi.PersistenceCapable pc, int field, boolean currentValue)
          This method is called from the associated persistable when its PersistenceCapable.jdoProvideFields() method is invoked.
 void providedByteField(javax.jdo.spi.PersistenceCapable pc, int field, byte currentValue)
          This method is called from the associated persistable when its PersistenceCapable.jdoProvideFields() method is invoked.
 void providedCharField(javax.jdo.spi.PersistenceCapable pc, int field, char currentValue)
          This method is called from the associated PersistenceCapable when its PersistenceCapable.jdoProvideFields() method is invoked.
 void providedDoubleField(javax.jdo.spi.PersistenceCapable pc, int field, double currentValue)
          This method is called from the associated PersistenceCapable when its PersistenceCapable.jdoProvideFields() method is invoked.
 void providedFloatField(javax.jdo.spi.PersistenceCapable pc, int field, float currentValue)
          This method is called from the associated PersistenceCapable when its PersistenceCapable.jdoProvideFields() method is invoked.
 void providedIntField(javax.jdo.spi.PersistenceCapable pc, int field, int currentValue)
          This method is called from the associated PersistenceCapable when its PersistenceCapable.jdoProvideFields() method is invoked.
 void providedLongField(javax.jdo.spi.PersistenceCapable pc, int field, long currentValue)
          This method is called from the associated PersistenceCapable when its PersistenceCapable.jdoProvideFields() method is invoked.
 void providedObjectField(javax.jdo.spi.PersistenceCapable pc, int fieldNumber, java.lang.Object currentValue)
          This method is called from the associated persistable when its PersistenceCapable.jdoProvideFields() method is invoked.
 void providedShortField(javax.jdo.spi.PersistenceCapable pc, int field, short currentValue)
          This method is called from the associated PersistenceCapable when its PersistenceCapable.jdoProvideFields() method is invoked.
 void providedStringField(javax.jdo.spi.PersistenceCapable pc, int field, java.lang.String currentValue)
          This method is called from the associated persistable when its PersistenceCapable.jdoProvideFields() method is invoked.
 void refresh()
          Method to refresh the object.
 boolean replacingBooleanField(javax.jdo.spi.PersistenceCapable pc, int field)
          This method is invoked by the PersistenceCapable object's jdoReplaceField() method to refresh the value of a boolean field.
 byte replacingByteField(javax.jdo.spi.PersistenceCapable obj, int field)
          This method is invoked by the PersistenceCapable object's jdoReplaceField() method to refresh the value of a byte field.
 char replacingCharField(javax.jdo.spi.PersistenceCapable obj, int field)
          This method is invoked by the PersistenceCapable object's jdoReplaceField() method to refresh the value of a char field.
 double replacingDoubleField(javax.jdo.spi.PersistenceCapable obj, int field)
          This method is invoked by the PersistenceCapable object's jdoReplaceField() method to refresh the value of a double field.
 float replacingFloatField(javax.jdo.spi.PersistenceCapable obj, int field)
          This method is invoked by the PersistenceCapable object's jdoReplaceField() method to refresh the value of a float field.
 int replacingIntField(javax.jdo.spi.PersistenceCapable obj, int field)
          This method is invoked by the persistable object's jdoReplaceField() method to refresh the value of a int field.
 long replacingLongField(javax.jdo.spi.PersistenceCapable obj, int field)
          This method is invoked by the persistable object's jdoReplaceField() method to refresh the value of a long field.
 java.lang.Object replacingObjectField(javax.jdo.spi.PersistenceCapable obj, int field)
          This method is invoked by the persistable object's jdoReplaceField() method to refresh the value of an Object field.
 short replacingShortField(javax.jdo.spi.PersistenceCapable obj, int field)
          This method is invoked by the persistable object's jdoReplaceField() method to refresh the value of a short field.
 java.lang.String replacingStringField(javax.jdo.spi.PersistenceCapable obj, int field)
          This method is invoked by the persistable object's jdoReplaceField() method to refresh the value of a String field.
 void retrieve(boolean fgOnly)
          Method to retrieve the object.
 void retrieve(FetchPlan fetchPlan)
          Method to retrieve the object.
 void setPcObjectType(int embeddedType)
          Method to set this StateManager as managing an embedded/serialised object.
protected  void setRestoreValues(boolean restore_values)
          Mutator for the Restore Values flag
 void setTransactionalVersion(java.lang.Object version)
          Sets the value for the version column in a transaction not yet committed
 void setVersion(java.lang.Object version)
          Sets the value for the version column in the datastore
 java.lang.String toString()
          Stringifier method.
protected  void transitionReadField(boolean isLoaded)
          Method to change the object state to read-field.
protected  void transitionWriteField()
          Method to change the object state to write-field.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.datanucleus.StateManager
addEmbeddedOwner, attach, attachCopy, becomingDeleted, cache, changeActivityState, checkInheritance, checkManagedRelations, clearFields, clearLoadedFlags, clearManagedRelations, clearNonPrimaryKeyFields, clearSavedFields, copyFieldsFromObject, deletePersistent, detach, detachCopy, disconnect, dump, enlistInTransaction, evictFromTransaction, flush, getAssociatedValue, getEmbeddedOwners, getExternalObjectId, getObjectId, getObjectProvider, getReferencedPC, getRelationshipManager, initialiseForCachedPC, initialiseForDetached, initialiseForEmbedded, initialiseForHollow, initialiseForHollowAppId, initialiseForHollowPreConstructed, initialiseForPersistentClean, initialiseForPersistentNew, initialiseForPNewToBeDeleted, initialiseForTransactionalTransient, isDeleting, isDetaching, isInserting, isLoaded, isUpdatingFieldForPostInsert, isWaitingToBeFlushedToDatastore, loadField, loadFieldFromDatastore, loadFieldsInFetchPlan, loadFieldValues, loadUnloadedFields, loadUnloadedFieldsInFetchPlan, loadUnloadedFieldsOfClassInFetchPlan, locate, makeDirty, makePersistent, makeTransactional, makeTransient, markForInheritanceValidation, nullifyFields, processManagedRelations, provideField, provideFields, refreshFieldsInFetchPlan, refreshLoadedFields, registerTransactional, replaceAllLoadedSCOFieldsWithValues, replaceAllLoadedSCOFieldsWithWrappers, replaceField, replaceFields, replaceFields, replaceFieldValue, replaceManagedPC, replaceNonLoadedFields, resetDetachState, restoreFields, retrieveDetachState, runReachability, saveFields, setAssociatedValue, setObjectField, setPostStoreNewObjectId, setStoringPC, unloadField, unloadNonFetchPlanFields, unsetStoringPC, unwrapSCOField, updateFieldAfterInsert, validate, wrapSCOField
 

Field Detail

LOCALISER

protected static final Localiser LOCALISER
Localiser for messages.


myOM

protected ObjectManager myOM
the Object Manager for this StateManager


myPC

protected javax.jdo.spi.PersistenceCapable myPC
The PersistenceCapable instance managed by this StateManager


cmd

protected AbstractClassMetaData cmd
the metadata for the class.


myInternalID

protected java.lang.Object myInternalID
The object identity in the JVM. Will be "myID" (if set) or otherwise a temporary id based on this StateManager.


myID

protected java.lang.Object myID
The object identity in the datastore


myLC

protected LifeCycleState myLC
The actual LifeCycleState for the persistable instance


myVersion

protected java.lang.Object myVersion
version field for optimistic transactions


transactionalVersion

protected java.lang.Object transactionalVersion
version field for optimistic transactions, after a insert/update but not yet committed.


myFP

protected FetchPlanForClass myFP
Fetch plan for the class of the managed object.


dirty

protected boolean dirty
Indicator for whether the persistable instance is dirty. Note that "dirty" in this case is not equated to being in the P_DIRTY state. The P_DIRTY state means that at least one field in the object has been written by the user during the current transaction, whereas for this parameter, a field is "dirty" if it's been written by the user but not yet updated in the data store. The difference is, it's possible for an object's state to be P_DIRTY, yet have no "dirty" fields because flush() has been called at least once during the transaction.


dirtyFields

protected boolean[] dirtyFields
indicators for which fields are currently dirty in the persistable instance.


loadedFields

protected boolean[] loadedFields
indicators for which fields are currently loaded in the persistable instance.


restoreValues

protected boolean restoreValues
Whether to restore values at StateManager. If true, overwrites the restore values at tx level.


currFM

protected FieldManager currFM
Current FieldManager.


currFMmonitor

protected java.lang.Object currFMmonitor
monitor to synchronize execution when replacing/providing fields


pcObjectType

protected int pcObjectType
The type of the managed object (0 = PC, 1 = embedded PC, 2 = embedded element, 3 = embedded key, 4 = embedded value.

Constructor Detail

AbstractStateManager

public AbstractStateManager(ObjectManager om,
                            AbstractClassMetaData cmd)
Constructor.

Parameters:
om - ObjectManager
cmd - the metadata for the class.
Method Detail

initialiseFieldInformation

protected void initialiseFieldInformation()
Convenience method to initialise the field information.


getCallbackHandler

protected CallbackHandler getCallbackHandler()
returns the handler for callback events.

Returns:
the handler for callback events.

getSecondClassMutableFields

protected boolean[] getSecondClassMutableFields()
returns indicators for which fields are second-class mutable.

Returns:
indicators for which fields are second-class mutable.

getNonPrimaryKeyFields

protected boolean[] getNonPrimaryKeyFields()
returns indicators for which fields are non-primary key fields.

Returns:
indicators for which fields are non-primary key fields.

getAllFieldNumbers

protected int[] getAllFieldNumbers()
returns field numbers of all fields.

Returns:
field numbers of all fields.

getNonPrimaryKeyFieldNumbers

protected int[] getNonPrimaryKeyFieldNumbers()
returns field numbers of all non-primary-key fields.

Returns:
field numbers of all non-primary-key fields.

getSecondClassMutableFieldNumbers

protected int[] getSecondClassMutableFieldNumbers()
returns field numbers of all second class mutable fields.

Returns:
field numbers of all second class mutable fields.

getStoreManager

public StoreManager getStoreManager()
Accessor for the StoreManager used for this object.

Specified by:
getStoreManager in interface StateManager
Returns:
The StoreManager.

getClassMetaData

public AbstractClassMetaData getClassMetaData()
Accessor for the ClassMetaData for this object.

Specified by:
getClassMetaData in interface StateManager
Returns:
The ClassMetaData.

getMetaDataManager

public MetaDataManager getMetaDataManager()
Accessor for the MetaDataManager to use for this object. Simply a wrapper accessor method.

Specified by:
getMetaDataManager in interface StateManager
Returns:
The MetaDataManager.

getObjectManager

public ObjectManager getObjectManager()
Accessor for the ObjectManager for this object.

Specified by:
getObjectManager in interface StateManager
Returns:
The Object Manager.

getObject

public java.lang.Object getObject()
Accessor for the Persistent Capable object.

Specified by:
getObject in interface StateManager
Returns:
The PersistentCapable object

getLifecycleState

public LifeCycleState getLifecycleState()
Accessor for the LifeCycleState

Returns:
the LifeCycleState

isRestoreValues

public boolean isRestoreValues()
Accessor for the Restore Values flag

Specified by:
isRestoreValues in interface StateManager
Returns:
Whether to restore values

setRestoreValues

protected void setRestoreValues(boolean restore_values)
Mutator for the Restore Values flag

Parameters:
restore_values - Whether to restore values

getInternalObjectId

public java.lang.Object getInternalObjectId()
Accessor for the internal object id of the object we are managing. This will return the "id" if it has been set, otherwise a temporary id based on this StateManager.

Specified by:
getInternalObjectId in interface StateManager
Returns:
The internal object id

disconnectClone

protected abstract boolean disconnectClone(javax.jdo.spi.PersistenceCapable pc)
Method to disconnect any cloned persistence capable objects from their StateManager.

Parameters:
pc - The persistable object
Returns:
Whether the object was disconnected.

isDirty

public boolean isDirty(javax.jdo.spi.PersistenceCapable pc)
Tests whether this object is dirty. Instances that have been modified, deleted, or newly made persistent in the current transaction return true.

Transient nontransactional instances return false (JDO spec), but the JPOX implementation does not currently support the transient transactional state.

Parameters:
pc - the calling persistable instance
Returns:
true if this instance has been modified in current transaction.
See Also:
PersistenceCapable.jdoMakeDirty(String fieldName)

isTransactional

public boolean isTransactional(javax.jdo.spi.PersistenceCapable pc)
Tests whether this object is transactional. Instances that respect transaction boundaries return true. These instances include transient instances made transactional as a result of being the target of a makeTransactional method call; newly made persistent or deleted persistent instances; persistent instances read in data store transactions; and persistent instances modified in optimistic transactions.

Transient nontransactional instances return false.

Parameters:
pc - the calling persistable instance
Returns:
true if this instance is transactional.

isPersistent

public boolean isPersistent(javax.jdo.spi.PersistenceCapable pc)
Tests whether this object is persistent. Instances whose state is stored in the data store return true. Transient instances return false.

Parameters:
pc - the calling persistable instance
Returns:
true if this instance is persistent.

isNew

public boolean isNew(javax.jdo.spi.PersistenceCapable pc)
Tests whether this object has been newly made persistent. Instances that have been made persistent in the current transaction return true.

Transient instances return false.

Specified by:
isNew in interface StateManager
Parameters:
pc - the calling persistable instance
Returns:
true if this instance was made persistent in the current transaction.

isDeleted

public boolean isDeleted(javax.jdo.spi.PersistenceCapable pc)
Tests whether this object has been deleted. Instances that have been deleted in the current transaction return true.

Transient instances return false.

Specified by:
isDeleted in interface StateManager
Parameters:
pc - the calling persistable instance
Returns:
true if this instance was deleted in the current transaction.

evict

public void evict()
Method to change the object state to evicted.

Specified by:
evict in interface StateManager

refresh

public void refresh()
Method to refresh the object.

Specified by:
refresh in interface StateManager

retrieve

public void retrieve(boolean fgOnly)
Method to retrieve the object.

Specified by:
retrieve in interface StateManager
Parameters:
fgOnly - Only load the current fetch group fields

retrieve

public void retrieve(FetchPlan fetchPlan)
Method to retrieve the object.

Specified by:
retrieve in interface StateManager
Parameters:
fetchPlan - the fetch plan to load fields

makePersistentTransactionalTransient

public void makePersistentTransactionalTransient()
Makes Transactional Transient instances persistent.

Specified by:
makePersistentTransactionalTransient in interface StateManager

makeNontransactional

public void makeNontransactional()
Method to change the object state to nontransactional.

Specified by:
makeNontransactional in interface StateManager

transitionReadField

protected void transitionReadField(boolean isLoaded)
Method to change the object state to read-field.

Parameters:
isLoaded - if the field was previously loaded

transitionWriteField

protected void transitionWriteField()
Method to change the object state to write-field.


preBegin

public void preBegin(Transaction tx)
Method invoked just before a transaction starts for the ObjectManager managing us.

Specified by:
preBegin in interface StateManager
Parameters:
tx - The transaction

postCommit

public void postCommit(Transaction tx)
This method is invoked just after a commit is performed in a Transaction involving the persistable object managed by this StateManager

Specified by:
postCommit in interface StateManager
Parameters:
tx - The transaction

preRollback

public void preRollback(Transaction tx)
This method is invoked just before a rollback is performed in a Transaction involving the persistable object managed by this StateManager.

Specified by:
preRollback in interface StateManager
Parameters:
tx - The transaction

preStateChange

protected abstract void preStateChange()
Method called before a change in state.


postStateChange

protected abstract void postStateChange()
Method called after a change in state.


getVersion

public java.lang.Object getVersion(javax.jdo.spi.PersistenceCapable pc)
Return the object representing the version of the calling instance.

Specified by:
getVersion in interface StateManager
Parameters:
pc - the calling persistable instance
Returns:
the object representing the version of the calling instance
Since:
JDO 2.0

setTransactionalVersion

public void setTransactionalVersion(java.lang.Object version)
Sets the value for the version column in a transaction not yet committed

Specified by:
setTransactionalVersion in interface StateManager
Parameters:
version - The version

getTransactionalVersion

public java.lang.Object getTransactionalVersion(java.lang.Object pc)
Return the object representing the transactional version of the calling instance.

Specified by:
getTransactionalVersion in interface StateManager
Parameters:
pc - the calling persistable instance
Returns:
the object representing the version of the calling instance
Since:
1.1.1

setVersion

public void setVersion(java.lang.Object version)
Sets the value for the version column in the datastore

Specified by:
setVersion in interface StateManager
Parameters:
version - The version

isEmbedded

public boolean isEmbedded()
Convenience accessor for whether this StateManager manages an embedded/serialised object.

Specified by:
isEmbedded in interface StateManager
Returns:
Whether the managed object is embedded/serialised.

setPcObjectType

public void setPcObjectType(int embeddedType)
Method to set this StateManager as managing an embedded/serialised object.

Specified by:
setPcObjectType in interface StateManager
Parameters:
embeddedType - The type of object being managed

getPcObjectType

public int getPcObjectType()
Accessor for the PC object type (whether it is PC, embedded PC, etc).

Specified by:
getPcObjectType in interface StateManager
Returns:
PC Object Type

getHighestFieldNumber

public int getHighestFieldNumber()
Accessor for the highest field number in this class

Specified by:
getHighestFieldNumber in interface StateManager
Returns:
The highest field number

isFetchPlanLoaded

protected boolean isFetchPlanLoaded()
Accessor for whether the current fetch plan fields are loaded.

Returns:
Whether the fetch plan fields are all loaded.

isDefaultFetchGroupLoaded

protected boolean isDefaultFetchGroupLoaded()
Accessor for whether the DFG fields are loaded.

Returns:
Whether the DFG fields are all loaded.

getDirtyFields

public boolean[] getDirtyFields()
Creates a copy of the dirtyFields bitmap.

Specified by:
getDirtyFields in interface StateManager
Returns:
a copy of the dirtyFields bitmap.

getDirtyFieldNumbers

public int[] getDirtyFieldNumbers()
Accessor for the field numbers of all dirty fields.

Specified by:
getDirtyFieldNumbers in interface StateManager
Returns:
Absolute field numbers of the dirty fields in this instance.

getLoadedFields

public boolean[] getLoadedFields()
Accessor for the fields

Specified by:
getLoadedFields in interface StateManager
Returns:
boolean array of loaded state in order of absolute field numbers

getLoadedFieldNumbers

public int[] getLoadedFieldNumbers()
Accessor for the field numbers of all loaded fields in this managed instance.

Specified by:
getLoadedFieldNumbers in interface StateManager
Returns:
Field numbers of all (currently) loaded fields

getAllFieldsLoaded

public boolean getAllFieldsLoaded()
Returns whether all fields are loaded.

Specified by:
getAllFieldsLoaded in interface StateManager
Returns:
Returns true if all fields are loaded.

getDirtyFieldNames

public java.lang.String[] getDirtyFieldNames()
Accessor for the names of the fields that are dirty.

Specified by:
getDirtyFieldNames in interface StateManager
Returns:
Names of the dirty fields

getLoadedFieldNames

public java.lang.String[] getLoadedFieldNames()
Accessor for the names of the fields that are loaded.

Specified by:
getLoadedFieldNames in interface StateManager
Returns:
Names of the loaded fields

isFieldLoaded

public boolean isFieldLoaded(int fieldNumber)
Accessor for whether a field is currently loaded. Just returns the status, unlike "isLoaded" which also loads it if not.

Specified by:
isFieldLoaded in interface StateManager
Parameters:
fieldNumber - The (absolute) field number
Returns:
Whether it is loaded

clearDirtyFlags

protected void clearDirtyFlags()
Method to clear all dirty flags on the object.


clearDirtyFlags

protected void clearDirtyFlags(int[] fields)
Method to clear all dirty flags on the object.

Parameters:
fields - the fields to clear

providedBooleanField

public void providedBooleanField(javax.jdo.spi.PersistenceCapable pc,
                                 int field,
                                 boolean currentValue)
This method is called from the associated persistable when its PersistenceCapable.jdoProvideFields() method is invoked. Its purpose is to provide the value of the specified field to the StateManager.

Parameters:
pc - the calling persistable instance
field - the field number
currentValue - the current value of the field

providedByteField

public void providedByteField(javax.jdo.spi.PersistenceCapable pc,
                              int field,
                              byte currentValue)
This method is called from the associated persistable when its PersistenceCapable.jdoProvideFields() method is invoked. Its purpose is to provide the value of the specified field to the StateManager.

Parameters:
pc - the calling persistable instance
field - the field number
currentValue - the current value of the field

providedCharField

public void providedCharField(javax.jdo.spi.PersistenceCapable pc,
                              int field,
                              char currentValue)
This method is called from the associated PersistenceCapable when its PersistenceCapable.jdoProvideFields() method is invoked. Its purpose is to provide the value of the specified field to the StateManager.

Parameters:
pc - the calling persistable instance
field - the field number
currentValue - the current value of the field

providedDoubleField

public void providedDoubleField(javax.jdo.spi.PersistenceCapable pc,
                                int field,
                                double currentValue)
This method is called from the associated PersistenceCapable when its PersistenceCapable.jdoProvideFields() method is invoked. Its purpose is to provide the value of the specified field to the StateManager.

Parameters:
pc - the calling persistable instance
field - the field number
currentValue - the current value of the field

providedFloatField

public void providedFloatField(javax.jdo.spi.PersistenceCapable pc,
                               int field,
                               float currentValue)
This method is called from the associated PersistenceCapable when its PersistenceCapable.jdoProvideFields() method is invoked. Its purpose is to provide the value of the specified field to the StateManager.

Parameters:
pc - the calling persistable instance
field - the field number
currentValue - the current value of the field

providedIntField

public void providedIntField(javax.jdo.spi.PersistenceCapable pc,
                             int field,
                             int currentValue)
This method is called from the associated PersistenceCapable when its PersistenceCapable.jdoProvideFields() method is invoked. Its purpose is to provide the value of the specified field to the StateManager.

Parameters:
pc - the calling persistable instance
field - the field number
currentValue - the current value of the field

providedLongField

public void providedLongField(javax.jdo.spi.PersistenceCapable pc,
                              int field,
                              long currentValue)
This method is called from the associated PersistenceCapable when its PersistenceCapable.jdoProvideFields() method is invoked. Its purpose is to provide the value of the specified field to the StateManager.

Parameters:
pc - the calling persistable instance
field - the field number
currentValue - the current value of the field

providedShortField

public void providedShortField(javax.jdo.spi.PersistenceCapable pc,
                               int field,
                               short currentValue)
This method is called from the associated PersistenceCapable when its PersistenceCapable.jdoProvideFields() method is invoked. Its purpose is to provide the value of the specified field to the StateManager.

Parameters:
pc - the calling persistable instance
field - the field number
currentValue - the current value of the field

providedStringField

public void providedStringField(javax.jdo.spi.PersistenceCapable pc,
                                int field,
                                java.lang.String currentValue)
This method is called from the associated persistable when its PersistenceCapable.jdoProvideFields() method is invoked. Its purpose is to provide the value of the specified field to the StateManager.

Parameters:
pc - the calling persistable instance
field - the field number
currentValue - the current value of the field

providedObjectField

public void providedObjectField(javax.jdo.spi.PersistenceCapable pc,
                                int fieldNumber,
                                java.lang.Object currentValue)
This method is called from the associated persistable when its PersistenceCapable.jdoProvideFields() method is invoked. Its purpose is to provide the value of the specified field to the StateManager.

Parameters:
pc - the calling PersistenceCapable instance
fieldNumber - the field number
currentValue - the current value of the field

replacingBooleanField

public boolean replacingBooleanField(javax.jdo.spi.PersistenceCapable pc,
                                     int field)
This method is invoked by the PersistenceCapable object's jdoReplaceField() method to refresh the value of a boolean field.

Parameters:
pc - the calling persistable instance
field - the field number
Returns:
the new value for the field

replacingByteField

public byte replacingByteField(javax.jdo.spi.PersistenceCapable obj,
                               int field)
This method is invoked by the PersistenceCapable object's jdoReplaceField() method to refresh the value of a byte field.

Parameters:
obj - the calling persistable instance
field - the field number
Returns:
the new value for the field

replacingCharField

public char replacingCharField(javax.jdo.spi.PersistenceCapable obj,
                               int field)
This method is invoked by the PersistenceCapable object's jdoReplaceField() method to refresh the value of a char field.

Parameters:
obj - the calling persistable instance
field - the field number
Returns:
the new value for the field

replacingDoubleField

public double replacingDoubleField(javax.jdo.spi.PersistenceCapable obj,
                                   int field)
This method is invoked by the PersistenceCapable object's jdoReplaceField() method to refresh the value of a double field.

Parameters:
obj - the calling PersistenceCapable instance
field - the field number
Returns:
the new value for the field

replacingFloatField

public float replacingFloatField(javax.jdo.spi.PersistenceCapable obj,
                                 int field)
This method is invoked by the PersistenceCapable object's jdoReplaceField() method to refresh the value of a float field.

Parameters:
obj - the calling PersistenceCapable instance
field - the field number
Returns:
the new value for the field

replacingIntField

public int replacingIntField(javax.jdo.spi.PersistenceCapable obj,
                             int field)
This method is invoked by the persistable object's jdoReplaceField() method to refresh the value of a int field.

Parameters:
obj - the calling persistable instance
field - the field number
Returns:
the new value for the field

replacingLongField

public long replacingLongField(javax.jdo.spi.PersistenceCapable obj,
                               int field)
This method is invoked by the persistable object's jdoReplaceField() method to refresh the value of a long field.

Parameters:
obj - the calling persistable instance
field - the field number
Returns:
the new value for the field

replacingShortField

public short replacingShortField(javax.jdo.spi.PersistenceCapable obj,
                                 int field)
This method is invoked by the persistable object's jdoReplaceField() method to refresh the value of a short field.

Parameters:
obj - the calling persistable instance
field - the field number
Returns:
the new value for the field

replacingStringField

public java.lang.String replacingStringField(javax.jdo.spi.PersistenceCapable obj,
                                             int field)
This method is invoked by the persistable object's jdoReplaceField() method to refresh the value of a String field.

Parameters:
obj - the calling persistable instance
field - the field number
Returns:
the new value for the field

replacingObjectField

public java.lang.Object replacingObjectField(javax.jdo.spi.PersistenceCapable obj,
                                             int field)
This method is invoked by the persistable object's jdoReplaceField() method to refresh the value of an Object field.

Parameters:
obj - the calling persistable instance
field - the field number
Returns:
the new value for the field

getBooleanField

public boolean getBooleanField(javax.jdo.spi.PersistenceCapable pc,
                               int field,
                               boolean currentValue)
This method is called by the associated persistable if the value for the specified field is not cached (StateManager.isLoaded() fails). In this implementation of the StateManager, isLoaded() has a side effect of loading unloaded information and will always return true. As such, this method should never be called.

Parameters:
pc - the calling persistable instance
field - the field number
currentValue - the current value of the field
Returns:
the new value for the field

getByteField

public byte getByteField(javax.jdo.spi.PersistenceCapable pc,
                         int field,
                         byte currentValue)
This method is called by the associated PersistenceCapable if the value for the specified field is not cached (StateManager.isLoaded() fails). In this implementation of the StateManager, isLoaded() has a side effect of loading unloaded information and will always return true. As such, this method should never be called.

Parameters:
pc - the calling PersistenceCapable instance
field - the field number
currentValue - the current value of the field
Returns:
the new value for the field

getCharField

public char getCharField(javax.jdo.spi.PersistenceCapable pc,
                         int field,
                         char currentValue)
This method is called by the associated persistable if the value for the specified field is not cached (StateManager.isLoaded() fails). In this implementation of the StateManager, isLoaded() has a side effect of loading unloaded information and will always return true. As such, this method should never be called.

Parameters:
pc - the calling persistable instance
field - the field number
currentValue - the current value of the field
Returns:
the new value for the field

getDoubleField

public double getDoubleField(javax.jdo.spi.PersistenceCapable pc,
                             int field,
                             double currentValue)
This method is called by the associated persistable if the value for the specified field is not cached (StateManager.isLoaded() fails). In this implementation of the StateManager, isLoaded() has a side effect of loading unloaded information and will always return true. As such, this method should never be called.

Parameters:
pc - the calling persistable instance
field - the field number
currentValue - the current value of the field
Returns:
the new value for the field

getFloatField

public float getFloatField(javax.jdo.spi.PersistenceCapable pc,
                           int field,
                           float currentValue)
This method is called by the associated persistable if the value for the specified field is not cached (StateManager.isLoaded() fails). In this implementation of the StateManager, isLoaded() has a side effect of loading unloaded information and will always return true. As such, this method should never be called.

Parameters:
pc - the calling persistable instance
field - the field number
currentValue - the current value of the field
Returns:
the new value for the field

getIntField

public int getIntField(javax.jdo.spi.PersistenceCapable pc,
                       int field,
                       int currentValue)
This method is called by the associated persistable if the value for the specified field is not cached (StateManager.isLoaded() fails). In this implementation of the StateManager, isLoaded() has a side effect of loading unloaded information and will always return true. As such, this method should never be called.

Parameters:
pc - the calling persistable instance
field - the field number
currentValue - the current value of the field
Returns:
the new value for the field

getLongField

public long getLongField(javax.jdo.spi.PersistenceCapable pc,
                         int field,
                         long currentValue)
This method is called by the associated persistable if the value for the specified field is not cached (StateManager.isLoaded() fails). In this implementation of the StateManager, isLoaded() has a side effect of loading unloaded information and will always return true. As such, this method should never be called.

Parameters:
pc - the calling persistable instance
field - the field number
currentValue - the current value of the field
Returns:
the new value for the field

getShortField

public short getShortField(javax.jdo.spi.PersistenceCapable pc,
                           int field,
                           short currentValue)
This method is called by the associated persistable if the value for the specified field is not cached (StateManager.isLoaded() fails). In this implementation of the StateManager, isLoaded() has a side effect of loading unloaded information and will always return true. As such, this method should never be called.

Parameters:
pc - the calling persistable instance
field - the field number
currentValue - the current value of the field
Returns:
the new value for the field

getStringField

public java.lang.String getStringField(javax.jdo.spi.PersistenceCapable pc,
                                       int field,
                                       java.lang.String currentValue)
This method is called by the associated persistable if the value for the specified field is not cached (StateManager.isLoaded() fails). In this implementation of the StateManager, isLoaded() has a side effect of loading unloaded information and will always return true. As such, this method should never be called.

Parameters:
pc - the calling persistable instance
field - the field number
currentValue - the current value of the field
Returns:
the new value for the field

getObjectField

public java.lang.Object getObjectField(javax.jdo.spi.PersistenceCapable pc,
                                       int field,
                                       java.lang.Object currentValue)
This method is called by the associated persistable if the value for the specified field is not cached (StateManager.isLoaded() fails). In this implementation of the StateManager, isLoaded() has a side effect of loading unloaded information and will always return true. As such, this method should never be called.

Parameters:
pc - the calling persistable instance
field - the field number
currentValue - the current value of the field
Returns:
the new value for the field

equals

protected static boolean equals(java.lang.Object o1,
                                java.lang.Object o2)
Compares two objects for equality, where one or both of the object references may be null.

Returns:
true if the objects are both null or compare equal according to their equals() method, false otherwise.

clearFlags

protected static void clearFlags(boolean[] flags)
Utility to clear the supplied flags.

Parameters:
flags -

clearFlags

protected static void clearFlags(boolean[] flags,
                                 int[] fields)
Utility to clear the supplied flags.

Parameters:
flags -
fields - fields numbers where the flags will be cleared

getFlagsSetTo

public static int[] getFlagsSetTo(boolean[] flags,
                                  boolean state)
Returns an array of integers containing the indices of all elements in flags that are in the state passed as argument.

Parameters:
flags - Array of flags (true or false)
state - The state to search (true or false)
Returns:
The settings of the flags

getFlagsSetTo

protected static int[] getFlagsSetTo(boolean[] flags,
                                     int[] indices,
                                     boolean state)
Returns an array of integers containing the indices of all elements in flags whose index occurs in indices and whose value is state.


peekField

protected static java.lang.Object peekField(java.lang.Object obj,
                                            java.lang.String fieldName)
Utility to take a peek at a field in the persistable object.

Parameters:
obj - The persistable object
fieldName - The field to peek at
Returns:
The value of the field.

toString

public java.lang.String toString()
Stringifier method.

Overrides:
toString in class java.lang.Object
Returns:
String form of the StateManager


Copyright © 2010. All Rights Reserved.