org.datanucleus.state
Class ObjectProviderImpl

java.lang.Object
  extended by org.datanucleus.state.ObjectProviderImpl
All Implemented Interfaces:
ObjectProvider

public class ObjectProviderImpl
extends java.lang.Object
implements ObjectProvider

Implementation of ObjectProvider for StateManager


Field Summary
 
Fields inherited from interface org.datanucleus.store.ObjectProvider
EMBEDDED_COLLECTION_ELEMENT_PC, EMBEDDED_MAP_KEY_PC, EMBEDDED_MAP_VALUE_PC, EMBEDDED_PC, PC
 
Constructor Summary
ObjectProviderImpl(StateManager sm)
           
 
Method Summary
 void addEmbeddedOwner(ObjectProvider ownerSM, int ownerFieldNumber)
          Method to register an owner StateManager with this embedded/serialised object.
 boolean becomingDeleted()
           
 void changeActivityState(ActivityState inserting)
           
 void copyFieldsFromObject(java.lang.Object pc, int[] fieldNumbers)
          Convenience method to update our object with the field values from the passed object.
 void flush()
           
 boolean getAllFieldsLoaded()
           
 java.lang.Object getAssociatedValue(JavaTypeMapping mapping)
           
 AbstractClassMetaData getClassMetaData()
           
 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.
 ObjectProvider[] getEmbeddedOwners()
           
 ExecutionContext getExecutionContext()
           
 java.lang.Object getExternalObjectId()
           
 java.lang.Object getInternalObjectId()
           
 LifeCycleState getLifecycleState()
           
 java.lang.String[] getLoadedFieldNames()
           
 int[] getLoadedFieldNumbers()
           
 boolean[] getLoadedFields()
           
 java.lang.Object getObject()
          TODO remove this
 java.lang.Object getObjectId()
           
 short getPcObjectType()
           
 java.lang.Object getReferencedPC()
           
 RelationshipManager getRelationshipManager()
           
 StateManager getStateManager()
           
 java.lang.Object getTransactionalVersion()
           
 java.lang.Object getVersion()
           
 boolean isDeleting()
           
 boolean isEmbedded()
           
 boolean isInserting()
           
 boolean isLoaded(java.lang.Object pc, int fieldNumber)
           
 boolean isWaitingToBeFlushedToDatastore()
           
 void loadField(int fieldNumber)
           
 void loadFieldFromDatastore(int fieldNumber)
           
 void loadFieldsInFetchPlan(FetchPlanState state)
           
 void loadFieldValues(FieldValues2 fieldValues)
           
 void loadUnloadedFields()
          Fetch from the database all fields that are not currently loaded regardless of whether they are in the current fetch group or not.
 void makeDirty(int fieldNumber)
          Marks the given field dirty.
 java.lang.Object provideField(int fieldNumber)
           
 void provideFields(int[] fieldNumbers, FieldManager fm)
           
 void replaceAllLoadedSCOFieldsWithValues()
           
 void replaceAllLoadedSCOFieldsWithWrappers()
           
 void replaceField(int fieldNumber, java.lang.Object value)
          Method to change the value of the specified field.
 void replaceFieldMakeDirty(int fieldNumber, java.lang.Object value)
           
 void replaceFields(int[] fieldNumbers, FieldManager fm)
           
 void replaceFields(int[] fieldNumbers, FieldManager fm, boolean replaceWhenDirty)
           
 void replaceManagedPC(java.lang.Object pc2)
           
 void replaceNonLoadedFields(int[] fieldNumbers, FieldManager fm)
           
 void runReachability(java.util.Set reachables)
           
 void setAssociatedValue(java.lang.Object key, java.lang.Object value)
          Method to set an associated value stored with this object.
 void setObjectField(java.lang.Object pc, int fieldNumber, java.lang.Object oldValue, java.lang.Object newValue)
           
 void setPcObjectType(short embeddedType)
           
 void setPostStoreNewObjectId(java.lang.Object id)
           
 void setStoringPC()
           
 void setTransactionalVersion(java.lang.Object optimisticTransactionalVersion)
           
 void setVersion(java.lang.Object version)
           
 java.lang.String toPrintableID()
           
 void unloadField(java.lang.String name)
           
 void unsetStoringPC()
           
 java.lang.Object unwrapSCOField(int fieldNumber, java.lang.Object value, boolean replaceFieldIfChanged)
           
 void updateFieldAfterInsert(java.lang.Object pc, int fieldNumber)
           
 java.lang.Object wrapSCOField(int fieldNumber, java.lang.Object value, boolean forInsert, boolean forUpdate, boolean replaceFieldIfChanged)
          TODO should not need this method from the store perspective Method to create a new SCO wrapper for the specified field.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectProviderImpl

public ObjectProviderImpl(StateManager sm)
Method Detail

getStateManager

public StateManager getStateManager()

getClassMetaData

public AbstractClassMetaData getClassMetaData()
Specified by:
getClassMetaData in interface ObjectProvider

provideField

public java.lang.Object provideField(int fieldNumber)
Specified by:
provideField in interface ObjectProvider

provideFields

public void provideFields(int[] fieldNumbers,
                          FieldManager fm)
Specified by:
provideFields in interface ObjectProvider

replaceFields

public void replaceFields(int[] fieldNumbers,
                          FieldManager fm)
Specified by:
replaceFields in interface ObjectProvider

replaceField

public void replaceField(int fieldNumber,
                         java.lang.Object value)
Description copied from interface: ObjectProvider
Method to change the value of the specified field. This will not make the field dirty

Specified by:
replaceField in interface ObjectProvider
Parameters:
fieldNumber - (absolute) field number of the field
value - The new value.

replaceNonLoadedFields

public void replaceNonLoadedFields(int[] fieldNumbers,
                                   FieldManager fm)
Specified by:
replaceNonLoadedFields in interface ObjectProvider

toPrintableID

public java.lang.String toPrintableID()
Specified by:
toPrintableID in interface ObjectProvider

wrapSCOField

public java.lang.Object wrapSCOField(int fieldNumber,
                                     java.lang.Object value,
                                     boolean forInsert,
                                     boolean forUpdate,
                                     boolean replaceFieldIfChanged)
Description copied from interface: ObjectProvider
TODO should not need this method from the store perspective Method to create a new SCO wrapper for the specified field. If the field is not a SCO field will just return the value.

Specified by:
wrapSCOField in interface ObjectProvider
Parameters:
fieldNumber - The field number
value - The value to initialise the wrapper with (if any)
forInsert - Whether the creation of any wrapper should insert this value into the datastore
forUpdate - Whether the creation of any wrapper should update the datastore with this value
replaceFieldIfChanged - Whether to replace the field in the object if wrapping the value
Returns:
The wrapper (or original value if not wrappable)

getObject

public java.lang.Object getObject()
Description copied from interface: ObjectProvider
TODO remove this

Specified by:
getObject in interface ObjectProvider

getInternalObjectId

public java.lang.Object getInternalObjectId()
Specified by:
getInternalObjectId in interface ObjectProvider

getExternalObjectId

public java.lang.Object getExternalObjectId()
Specified by:
getExternalObjectId in interface ObjectProvider

getDirtyFieldNames

public java.lang.String[] getDirtyFieldNames()
Description copied from interface: ObjectProvider
Accessor for the names of the fields that are dirty.

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

getDirtyFieldNumbers

public int[] getDirtyFieldNumbers()
Description copied from interface: ObjectProvider
Accessor for the field numbers of all dirty fields.

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

getEmbeddedOwners

public ObjectProvider[] getEmbeddedOwners()
Specified by:
getEmbeddedOwners in interface ObjectProvider

isInserting

public boolean isInserting()
Specified by:
isInserting in interface ObjectProvider

loadUnloadedFields

public void loadUnloadedFields()
Description copied from interface: ObjectProvider
Fetch from the database all fields that are not currently loaded regardless of whether they are in the current fetch group or not. Called by lifecycle transitions.

Specified by:
loadUnloadedFields in interface ObjectProvider

makeDirty

public void makeDirty(int fieldNumber)
Description copied from interface: ObjectProvider
Marks the given field dirty.

Specified by:
makeDirty in interface ObjectProvider
Parameters:
fieldNumber - The no of field to mark as dirty.

setAssociatedValue

public void setAssociatedValue(java.lang.Object key,
                               java.lang.Object value)
Description copied from interface: ObjectProvider
Method to set an associated value stored with this object. This is for a situation such as in ORM where this object can have an "external" foreign-key provided by an owning object (e.g 1-N uni relation and this is the element with no knowledge of the owner, so the associated value is the FK value).

Specified by:
setAssociatedValue in interface ObjectProvider
Parameters:
key - Key for the value
value - The associated value

getLifecycleState

public LifeCycleState getLifecycleState()
Specified by:
getLifecycleState in interface ObjectProvider

addEmbeddedOwner

public void addEmbeddedOwner(ObjectProvider ownerSM,
                             int ownerFieldNumber)
Method to register an owner StateManager with this embedded/serialised object.

Specified by:
addEmbeddedOwner in interface ObjectProvider
Parameters:
ownerSM - The owning State Manager.
ownerFieldNumber - The field number in the owner that the embedded/serialised object is stored as

isEmbedded

public boolean isEmbedded()
Specified by:
isEmbedded in interface ObjectProvider

copyFieldsFromObject

public void copyFieldsFromObject(java.lang.Object pc,
                                 int[] fieldNumbers)
Description copied from interface: ObjectProvider
Convenience method to update our object with the field values from the passed object. Objects need to be of the same type, and the other object should not have a StateManager.

Specified by:
copyFieldsFromObject in interface ObjectProvider
Parameters:
pc - The object that we should copy fields from

getTransactionalVersion

public java.lang.Object getTransactionalVersion()
Specified by:
getTransactionalVersion in interface ObjectProvider

getExecutionContext

public ExecutionContext getExecutionContext()
Specified by:
getExecutionContext in interface ObjectProvider

unwrapSCOField

public java.lang.Object unwrapSCOField(int fieldNumber,
                                       java.lang.Object value,
                                       boolean replaceFieldIfChanged)
Specified by:
unwrapSCOField in interface ObjectProvider

replaceFieldMakeDirty

public void replaceFieldMakeDirty(int fieldNumber,
                                  java.lang.Object value)
Specified by:
replaceFieldMakeDirty in interface ObjectProvider

getLoadedFields

public boolean[] getLoadedFields()
Specified by:
getLoadedFields in interface ObjectProvider

runReachability

public void runReachability(java.util.Set reachables)
Specified by:
runReachability in interface ObjectProvider

setPcObjectType

public void setPcObjectType(short embeddedType)
Specified by:
setPcObjectType in interface ObjectProvider

getPcObjectType

public short getPcObjectType()
Specified by:
getPcObjectType in interface ObjectProvider

setStoringPC

public void setStoringPC()
Specified by:
setStoringPC in interface ObjectProvider

flush

public void flush()
Specified by:
flush in interface ObjectProvider

isWaitingToBeFlushedToDatastore

public boolean isWaitingToBeFlushedToDatastore()
Specified by:
isWaitingToBeFlushedToDatastore in interface ObjectProvider

isDeleting

public boolean isDeleting()
Specified by:
isDeleting in interface ObjectProvider

loadFieldValues

public void loadFieldValues(FieldValues2 fieldValues)
Specified by:
loadFieldValues in interface ObjectProvider

getRelationshipManager

public RelationshipManager getRelationshipManager()
Specified by:
getRelationshipManager in interface ObjectProvider

getReferencedPC

public java.lang.Object getReferencedPC()
Specified by:
getReferencedPC in interface ObjectProvider

unsetStoringPC

public void unsetStoringPC()
Specified by:
unsetStoringPC in interface ObjectProvider

setObjectField

public void setObjectField(java.lang.Object pc,
                           int fieldNumber,
                           java.lang.Object oldValue,
                           java.lang.Object newValue)
Specified by:
setObjectField in interface ObjectProvider

loadField

public void loadField(int fieldNumber)
Specified by:
loadField in interface ObjectProvider

isLoaded

public boolean isLoaded(java.lang.Object pc,
                        int fieldNumber)
Specified by:
isLoaded in interface ObjectProvider

setTransactionalVersion

public void setTransactionalVersion(java.lang.Object optimisticTransactionalVersion)
Specified by:
setTransactionalVersion in interface ObjectProvider

replaceFields

public void replaceFields(int[] fieldNumbers,
                          FieldManager fm,
                          boolean replaceWhenDirty)
Specified by:
replaceFields in interface ObjectProvider

setVersion

public void setVersion(java.lang.Object version)
Specified by:
setVersion in interface ObjectProvider

getLoadedFieldNumbers

public int[] getLoadedFieldNumbers()
Specified by:
getLoadedFieldNumbers in interface ObjectProvider

updateFieldAfterInsert

public void updateFieldAfterInsert(java.lang.Object pc,
                                   int fieldNumber)
Specified by:
updateFieldAfterInsert in interface ObjectProvider

setPostStoreNewObjectId

public void setPostStoreNewObjectId(java.lang.Object id)
Specified by:
setPostStoreNewObjectId in interface ObjectProvider

changeActivityState

public void changeActivityState(ActivityState inserting)
Specified by:
changeActivityState in interface ObjectProvider

getAssociatedValue

public java.lang.Object getAssociatedValue(JavaTypeMapping mapping)
Specified by:
getAssociatedValue in interface ObjectProvider

becomingDeleted

public boolean becomingDeleted()
Specified by:
becomingDeleted in interface ObjectProvider

loadFieldsInFetchPlan

public void loadFieldsInFetchPlan(FetchPlanState state)
Specified by:
loadFieldsInFetchPlan in interface ObjectProvider

loadFieldFromDatastore

public void loadFieldFromDatastore(int fieldNumber)
Specified by:
loadFieldFromDatastore in interface ObjectProvider

getObjectId

public java.lang.Object getObjectId()
Specified by:
getObjectId in interface ObjectProvider

getVersion

public java.lang.Object getVersion()
Specified by:
getVersion in interface ObjectProvider

unloadField

public void unloadField(java.lang.String name)
Specified by:
unloadField in interface ObjectProvider

replaceAllLoadedSCOFieldsWithWrappers

public void replaceAllLoadedSCOFieldsWithWrappers()
Specified by:
replaceAllLoadedSCOFieldsWithWrappers in interface ObjectProvider

replaceAllLoadedSCOFieldsWithValues

public void replaceAllLoadedSCOFieldsWithValues()
Specified by:
replaceAllLoadedSCOFieldsWithValues in interface ObjectProvider

getAllFieldsLoaded

public boolean getAllFieldsLoaded()
Specified by:
getAllFieldsLoaded in interface ObjectProvider

replaceManagedPC

public void replaceManagedPC(java.lang.Object pc2)
Specified by:
replaceManagedPC in interface ObjectProvider

getLoadedFieldNames

public java.lang.String[] getLoadedFieldNames()
Specified by:
getLoadedFieldNames in interface ObjectProvider


Copyright © 2011. All Rights Reserved.