Interface StateManager
- All Known Subinterfaces:
DNStateManager<T>
- All Known Implementing Classes:
ReferentialStateManagerImpl
,StateManagerImpl
Persistable
classes and DataNucleus.
It contains the methods used by Persistable
instances to delegate behavior to DataNucleus.
Each managed Persistable
instance contains a reference to a StateManager
.
In principle, a StateManager
might manage one or multiple instances of Persistable
instances.
In reality we only ever manage a single Persistable
instance here, see StateManagerImpl.
-
Method Summary
Modifier and TypeMethodDescriptiondefault boolean
getBooleanField
(Persistable pc, int field, boolean currentValue) Return the value for the field.default byte
getByteField
(Persistable pc, int field, byte currentValue) Return the value for the field.default char
getCharField
(Persistable pc, int field, char currentValue) Return the value for the field.default double
getDoubleField
(Persistable pc, int field, double currentValue) Return the value for the field.Return theExecutionContext
that owns this instance.default float
getFloatField
(Persistable pc, int field, float currentValue) Return the value for the field.default int
getIntField
(Persistable pc, int field, int currentValue) Return the value for the field.default long
getLongField
(Persistable pc, int field, long currentValue) Return the value for the field.default Object
getObjectField
(Persistable pc, int field, Object currentValue) Return the value for the field.Return the object representing the identity of the calling instance.default short
getShortField
(Persistable pc, int field, short currentValue) Return the value for the field.default String
getStringField
(Persistable pc, int field, String currentValue) Return the value for the field.Return the object representing the identity of the calling instance.Return the object representing the version of the calling instance.boolean
isDeleted
(Persistable pc) Tests whether this object has been deleted.boolean
isDirty
(Persistable pc) Tests whether this object is dirty.boolean
isLoaded
(Persistable pc, int field) Returntrue
if the field is cached in the calling instance.boolean
isNew
(Persistable pc) Tests whether this object has been newly made persistent.boolean
Tests whether this object is persistent.boolean
Tests whether this object is transactional.void
makeDirty
(Persistable pc, String fieldName) Mark the associatedPersistable
field dirty.void
Guarantee that the serializable transactional and persistent fields are loaded into the instance.void
providedBooleanField
(Persistable pc, int field, boolean currentValue) The value of the field requested to be provided to theStateManager
.void
providedByteField
(Persistable pc, int field, byte currentValue) The value of the field requested to be provided to theStateManager
.void
providedCharField
(Persistable pc, int field, char currentValue) The value of the field requested to be provided to theStateManager
.void
providedDoubleField
(Persistable pc, int field, double currentValue) The value of the field requested to be provided to theStateManager
.void
providedFloatField
(Persistable pc, int field, float currentValue) The value of the field requested to be provided to theStateManager
.void
providedIntField
(Persistable pc, int field, int currentValue) The value of the field requested to be provided to theStateManager
.void
providedLongField
(Persistable pc, int field, long currentValue) The value of the field requested to be provided to theStateManager
.void
providedObjectField
(Persistable pc, int field, Object currentValue) The value of the field requested to be provided to theStateManager
.void
providedShortField
(Persistable pc, int field, short currentValue) The value of the field requested to be provided to theStateManager
.void
providedStringField
(Persistable pc, int field, String currentValue) The value of the field requested to be provided to theStateManager
.boolean
replacingBooleanField
(Persistable pc, int field) The replacement value of the field in the calling instance.byte
replacingByteField
(Persistable pc, int field) The replacement value of the field in the calling instance.char
replacingCharField
(Persistable pc, int field) The replacement value of the field in the calling instance.Object[]
replacingDetachedState
(Detachable pc, Object[] state) The replacement value of the detached state in the calling instance.double
replacingDoubleField
(Persistable pc, int field) The replacement value of the field in the calling instance.byte
The owningStateManager
uses this method to supply the value of the flags to thePersistable
instance.float
replacingFloatField
(Persistable pc, int field) The replacement value of the field in the calling instance.int
replacingIntField
(Persistable pc, int field) The replacement value of the field in the calling instance.long
replacingLongField
(Persistable pc, int field) The replacement value of the field in the calling instance.replacingObjectField
(Persistable pc, int field) The replacement value of the field in the calling instance.short
replacingShortField
(Persistable pc, int field) The replacement value of the field in the calling instance.Replace the current value ofdnStateManager
.replacingStringField
(Persistable pc, int field) The replacement value of the field in the calling instance.void
setBooleanField
(Persistable pc, int field, boolean currentValue, boolean newValue) Mark the field as modified by the user.void
setByteField
(Persistable pc, int field, byte currentValue, byte newValue) Mark the field as modified by the user.void
setCharField
(Persistable pc, int field, char currentValue, char newValue) Mark the field as modified by the user.void
setDoubleField
(Persistable pc, int field, double currentValue, double newValue) Mark the field as modified by the user.void
setFloatField
(Persistable pc, int field, float currentValue, float newValue) Mark the field as modified by the user.void
setIntField
(Persistable pc, int field, int currentValue, int newValue) Mark the field as modified by the user.void
setLongField
(Persistable pc, int field, long currentValue, long newValue) Mark the field as modified by the user.void
setObjectField
(Persistable pc, int field, Object currentValue, Object newValue) Mark the field as modified by the user.void
setShortField
(Persistable pc, int field, short currentValue, short newValue) Mark the field as modified by the user.void
setStringField
(Persistable pc, int field, String currentValue, String newValue) Mark the field as modified by the user.
-
Method Details
-
getExecutionContextReference
ExecutionContextReference getExecutionContextReference()Return theExecutionContext
that owns this instance.- Returns:
- the
ExecutionContext
that owns this instance
-
replacingFlags
The owningStateManager
uses this method to supply the value of the flags to thePersistable
instance.- Parameters:
pc
- the callingPersistable
instance- Returns:
- the value of
dnFlags
to be stored in thePersistable
instance
-
replacingStateManager
Replace the current value ofdnStateManager
.This method is called by the
Persistable
wheneverdnReplaceStateManager
is called and there is already an owningStateManager
. This is a security precaution to ensure that the owningStateManager
is the only source of any change to its reference in thePersistable
.- Parameters:
pc
- the callingPersistable
instancesm
- the proposed new value for thednStateManager
- Returns:
- the new value for the
dnStateManager
-
isDirty
Tests whether this object is dirty. Instances that have been modified, deleted, or newly made persistent in the current transaction returntrue
.Transient nontransactional instances return
false
.- Parameters:
pc
- the callingPersistable
instance- Returns:
true
if this instance has been modified in the current transaction.- See Also:
-
isTransactional
Tests whether this object is transactional. Instances that respect transaction boundaries returntrue
. These instances include transient instances made transactional as a result of being the target of amakeTransactional
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 callingPersistable
instance- Returns:
true
if this instance is transactional.
-
isPersistent
Tests whether this object is persistent. Instances whose state is stored in the data store returntrue
.Transient instances return
false
.- Parameters:
pc
- the callingPersistable
instance- Returns:
true
if this instance is persistent.
-
isNew
Tests whether this object has been newly made persistent. Instances that have been made persistent in the current transaction returntrue
.Transient instances return
false
.- Parameters:
pc
- the callingPersistable
instance- Returns:
true
if this instance was made persistent in the current transaction.
-
isDeleted
Tests whether this object has been deleted. Instances that have been deleted in the current transaction returntrue
.Transient instances return
false
.- Parameters:
pc
- the callingPersistable
instance- Returns:
true
if this instance was deleted in the current transaction.
-
makeDirty
Mark the associatedPersistable
field dirty.The
StateManager
will make a copy of the field so it can be restored if needed later, and then mark the field as modified in the current transaction.- Parameters:
pc
- the callingPersistable
instancefieldName
- the name of the field
-
getObjectId
Return the object representing the identity of the calling instance. If the identity is being changed in the current transaction, this method returns the identity as of the beginning of the transaction.- Parameters:
pc
- the callingPersistable
instance- Returns:
- the object representing the identity of the calling instance
-
getTransactionalObjectId
Return the object representing the identity of the calling instance. If the identity is being changed in the current transaction, this method returns the current identity as changed in the transaction.- Parameters:
pc
- the callingPersistable
instance- Returns:
- the object representing the identity of the calling instance
-
getVersion
Return the object representing the version of the calling instance.- Parameters:
pc
- the callingPersistable
instance- Returns:
- the object representing the version of the calling instance
-
isLoaded
Returntrue
if the field is cached in the calling instance.- Parameters:
pc
- the callingPersistable
instancefield
- the field number- Returns:
- whether the field is cached in the calling instance
-
preSerialize
Guarantee that the serializable transactional and persistent fields are loaded into the instance. This method is called by the generateddnPreSerialize
method prior to serialization of the instance.- Parameters:
pc
- the callingPersistable
instance
-
getBooleanField
Return the value for the field. Never called since isLoaded always returns null.- Parameters:
pc
- the callingPersistable
instancefield
- the field numbercurrentValue
- the current value of the field- Returns:
- the new value for the field
-
getCharField
Return the value for the field. Never called since isLoaded always returns null.- Parameters:
pc
- the callingPersistable
instancefield
- the field numbercurrentValue
- the current value of the field- Returns:
- the new value for the field
-
getByteField
Return the value for the field. Never called since isLoaded always returns null.- Parameters:
pc
- the callingPersistable
instancefield
- the field numbercurrentValue
- the current value of the field- Returns:
- the new value for the field
-
getShortField
Return the value for the field. Never called since isLoaded always returns null.- Parameters:
pc
- the callingPersistable
instancefield
- the field numbercurrentValue
- the current value of the field- Returns:
- the new value for the field
-
getIntField
Return the value for the field. Never called since isLoaded always returns null.- Parameters:
pc
- the callingPersistable
instancefield
- the field numbercurrentValue
- the current value of the field- Returns:
- the new value for the field
-
getLongField
Return the value for the field. Never called since isLoaded always returns null.- Parameters:
pc
- the callingPersistable
instancefield
- the field numbercurrentValue
- the current value of the field- Returns:
- the new value for the field
-
getFloatField
Return the value for the field. Never called since isLoaded always returns null.- Parameters:
pc
- the callingPersistable
instancefield
- the field numbercurrentValue
- the current value of the field- Returns:
- the new value for the field
-
getDoubleField
Return the value for the field. Never called since isLoaded always returns null.- Parameters:
pc
- the callingPersistable
instancefield
- the field numbercurrentValue
- the current value of the field- Returns:
- the new value for the field
-
getStringField
Return the value for the field. Never called since isLoaded always returns null.- Parameters:
pc
- the callingPersistable
instancefield
- the field numbercurrentValue
- the current value of the field- Returns:
- the new value for the field
-
getObjectField
Return the value for the field. Never called since isLoaded always returns null.- Parameters:
pc
- the callingPersistable
instancefield
- the field numbercurrentValue
- the current value of the field- Returns:
- the new value for the field
-
setBooleanField
Mark the field as modified by the user.- Parameters:
pc
- the callingPersistable
instancefield
- the field numbercurrentValue
- the current value of the fieldnewValue
- the proposed new value of the field
-
setCharField
Mark the field as modified by the user.- Parameters:
pc
- the callingPersistable
instancefield
- the field numbercurrentValue
- the current value of the fieldnewValue
- the proposed new value of the field
-
setByteField
Mark the field as modified by the user.- Parameters:
pc
- the callingPersistable
instancefield
- the field numbercurrentValue
- the current value of the fieldnewValue
- the proposed new value of the field
-
setShortField
Mark the field as modified by the user.- Parameters:
pc
- the callingPersistable
instancefield
- the field numbercurrentValue
- the current value of the fieldnewValue
- the proposed new value of the field
-
setIntField
Mark the field as modified by the user.- Parameters:
pc
- the callingPersistable
instancefield
- the field numbercurrentValue
- the current value of the fieldnewValue
- the proposed new value of the field
-
setLongField
Mark the field as modified by the user.- Parameters:
pc
- the callingPersistable
instancefield
- the field numbercurrentValue
- the current value of the fieldnewValue
- the proposed new value of the field
-
setFloatField
Mark the field as modified by the user.- Parameters:
pc
- the callingPersistable
instancefield
- the field numbercurrentValue
- the current value of the fieldnewValue
- the proposed new value of the field
-
setDoubleField
Mark the field as modified by the user.- Parameters:
pc
- the callingPersistable
instancefield
- the field numbercurrentValue
- the current value of the fieldnewValue
- the proposed new value of the field
-
setStringField
Mark the field as modified by the user.- Parameters:
pc
- the callingPersistable
instancefield
- the field numbercurrentValue
- the current value of the fieldnewValue
- the proposed new value of the field
-
setObjectField
Mark the field as modified by the user.- Parameters:
pc
- the callingPersistable
instancefield
- the field numbercurrentValue
- the current value of the fieldnewValue
- the proposed new value of the field
-
providedBooleanField
The value of the field requested to be provided to theStateManager
.- Parameters:
pc
- the callingPersistable
instancefield
- the field numbercurrentValue
- the current value of the field
-
providedCharField
The value of the field requested to be provided to theStateManager
.- Parameters:
pc
- the callingPersistable
instancefield
- the field numbercurrentValue
- the current value of the field
-
providedByteField
The value of the field requested to be provided to theStateManager
.- Parameters:
pc
- the callingPersistable
instancefield
- the field numbercurrentValue
- the current value of the field
-
providedShortField
The value of the field requested to be provided to theStateManager
.- Parameters:
pc
- the callingPersistable
instancefield
- the field numbercurrentValue
- the current value of the field
-
providedIntField
The value of the field requested to be provided to theStateManager
.- Parameters:
pc
- the callingPersistable
instancefield
- the field numbercurrentValue
- the current value of the field
-
providedLongField
The value of the field requested to be provided to theStateManager
.- Parameters:
pc
- the callingPersistable
instancefield
- the field numbercurrentValue
- the current value of the field
-
providedFloatField
The value of the field requested to be provided to theStateManager
.- Parameters:
pc
- the callingPersistable
instancefield
- the field numbercurrentValue
- the current value of the field
-
providedDoubleField
The value of the field requested to be provided to theStateManager
.- Parameters:
pc
- the callingPersistable
instancefield
- the field numbercurrentValue
- the current value of the field
-
providedStringField
The value of the field requested to be provided to theStateManager
.- Parameters:
pc
- the callingPersistable
instancefield
- the field numbercurrentValue
- the current value of the field
-
providedObjectField
The value of the field requested to be provided to theStateManager
.- Parameters:
pc
- the callingPersistable
instancefield
- the field numbercurrentValue
- the current value of the field
-
replacingBooleanField
The replacement value of the field in the calling instance.- Parameters:
pc
- the callingPersistable
instancefield
- the field number- Returns:
- the new value for the field
-
replacingCharField
The replacement value of the field in the calling instance.- Parameters:
pc
- the callingPersistable
instancefield
- the field number- Returns:
- the new value for the field
-
replacingByteField
The replacement value of the field in the calling instance.- Parameters:
pc
- the callingPersistable
instancefield
- the field number- Returns:
- the new value for the field
-
replacingShortField
The replacement value of the field in the calling instance.- Parameters:
pc
- the callingPersistable
instancefield
- the field number- Returns:
- the new value for the field
-
replacingIntField
The replacement value of the field in the calling instance.- Parameters:
pc
- the callingPersistable
instancefield
- the field number- Returns:
- the new value for the field
-
replacingLongField
The replacement value of the field in the calling instance.- Parameters:
pc
- the callingPersistable
instancefield
- the field number- Returns:
- the new value for the field
-
replacingFloatField
The replacement value of the field in the calling instance.- Parameters:
pc
- the callingPersistable
instancefield
- the field number- Returns:
- the new value for the field
-
replacingDoubleField
The replacement value of the field in the calling instance.- Parameters:
pc
- the callingPersistable
instancefield
- the field number- Returns:
- the new value for the field
-
replacingStringField
The replacement value of the field in the calling instance.- Parameters:
pc
- the callingPersistable
instancefield
- the field number- Returns:
- the new value for the field
-
replacingObjectField
The replacement value of the field in the calling instance.- Parameters:
pc
- the callingPersistable
instancefield
- the field number- Returns:
- the new value for the field
-
replacingDetachedState
The replacement value of the detached state in the calling instance.- Parameters:
pc
- the callingDetachable
instancestate
- the current value of the detached state- Returns:
- the replacement value for the detached state
-