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


Constructor Summary
ObjectProviderImpl(StateManager sm)
           
 
Method Summary
 void addEmbeddedOwner(ObjectProvider ownerSM, int ownerFieldNumber)
          Method to register an owner StateManager with this embedded/serialised object.
 void copyFieldsFromObject(java.lang.Object pc, int[] fieldNumbers)
          Convenience method to update our object with the field values from the passed object.
 void deletePersistent()
           
 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.Object getObject()
          TODO remove this
 boolean isEmbedded()
           
 boolean isInserting()
           
 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 replaceField(int fieldNumber, java.lang.Object value)
          Method to change the value of the specified field.
 void replaceFields(int[] fieldNumbers, FieldManager fm)
           
 void replaceNonLoadedFields(int[] fieldNumbers, FieldManager fm)
           
 void setAssociatedValue(java.lang.Object key, java.lang.Object value)
          Method to set an associated value stored with this object.
 java.lang.String toPrintableID()
           
 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

getClassMetaData

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

getExecutionContext

public ExecutionContext getExecutionContext()
Specified by:
getExecutionContext 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
Returns:

getInternalObjectId

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

getExternalObjectId

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

deletePersistent

public void deletePersistent()
Specified by:
deletePersistent 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


Copyright © 2010. All Rights Reserved.