Package org.datanucleus.state
Class LifeCycleState
- java.lang.Object
-
- org.datanucleus.state.LifeCycleState
-
public abstract class LifeCycleState extends Object
Base Class representing the life cycle state. Implemented for individual states.
-
-
Field Summary
Fields Modifier and Type Field Description static intDETACHED_CLEANDetached-Cleanstatic intDETACHED_DIRTYDetached-Dirtystatic intHOLLOWHollowstatic intILLEGAL_STATEillegal stateprotected booleanisDeletedprotected booleanisDirtyprotected booleanisNewprotected booleanisPersistentprotected booleanisTransactionalstatic intP_CLEANPersistent-Cleanstatic intP_DELETEDPersistent-Deletedstatic intP_DIRTYPersistent-Dirtystatic intP_NEWPersistent-Newstatic intP_NEW_DELETEDPersistent-New-Deletedstatic intP_NONTRANSPersistent-NonTransactionalstatic intP_NONTRANS_DIRTYPersistent-NonTransactionalDirtyprotected intstateTypestatic intT_CLEANTransaction-Cleanstatic intT_DIRTYTransaction-Dirtystatic intTOTALtotal number of statesstatic intTRANSIENTtransient
-
Constructor Summary
Constructors Constructor Description LifeCycleState()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected LifeCycleStatechangeState(ObjectProvider op, int newStateType)Utility to change state to a new state.protected LifeCycleStatechangeTransientState(ObjectProvider op, int newStateType)Utility to change state to a new state.booleanisDeleted()Return whether the object is deleted.booleanisDirty()Return whether the object is dirty, ie has been changed (created, updated, deleted) in this Tx.booleanisNew()Return whether the object was newly created.booleanisPersistent()Return whether the object is persistent.booleanisTransactional()Return whether the object is transactional.intstateType()Returns the type of the life cycle stateabstract StringtoString()Method to return a string version of this object.LifeCycleStatetransitionAttach(ObjectProvider op)Method to transition to persistent-clean.LifeCycleStatetransitionBegin(ObjectProvider op, Transaction tx)Method to transition to transaction begin state.LifeCycleStatetransitionCommit(ObjectProvider op, Transaction tx)Method to transition to commit state.LifeCycleStatetransitionDeletePersistent(ObjectProvider op)Method to transition to delete persistent state.LifeCycleStatetransitionDetach(ObjectProvider op)Method to transition to detached-clean.LifeCycleStatetransitionEvict(ObjectProvider op)Method to transition to evict state.LifeCycleStatetransitionMakeNontransactional(ObjectProvider op)Method to transition to nontransactional state.LifeCycleStatetransitionMakePersistent(ObjectProvider op)Method to transition to persistent state.LifeCycleStatetransitionMakeTransactional(ObjectProvider op, boolean refreshFields)Method to transition to transactional state.LifeCycleStatetransitionMakeTransient(ObjectProvider op, boolean useFetchPlan, boolean detachAllOnCommit)Method to transition to transient state.LifeCycleStatetransitionReadField(ObjectProvider op, boolean isLoaded)Method to transition to read-field state.LifeCycleStatetransitionRefresh(ObjectProvider op)Method to transition to refresh state.LifeCycleStatetransitionRetrieve(ObjectProvider op, boolean fgOnly)Method to transition to retrieve state.LifeCycleStatetransitionRetrieve(ObjectProvider op, FetchPlan fetchPlan)Method to transition to retrieve state.LifeCycleStatetransitionRollback(ObjectProvider op, Transaction tx)Method to transition to rollback state.LifeCycleStatetransitionSerialize(ObjectProvider op)Method to transition when serialised.LifeCycleStatetransitionWriteField(ObjectProvider op)Method to transition to write-field state.
-
-
-
Field Detail
-
TRANSIENT
public static final int TRANSIENT
transient- See Also:
- Constant Field Values
-
P_NEW
public static final int P_NEW
Persistent-New- See Also:
- Constant Field Values
-
P_CLEAN
public static final int P_CLEAN
Persistent-Clean- See Also:
- Constant Field Values
-
P_DIRTY
public static final int P_DIRTY
Persistent-Dirty- See Also:
- Constant Field Values
-
HOLLOW
public static final int HOLLOW
Hollow- See Also:
- Constant Field Values
-
T_CLEAN
public static final int T_CLEAN
Transaction-Clean- See Also:
- Constant Field Values
-
T_DIRTY
public static final int T_DIRTY
Transaction-Dirty- See Also:
- Constant Field Values
-
P_NEW_DELETED
public static final int P_NEW_DELETED
Persistent-New-Deleted- See Also:
- Constant Field Values
-
P_DELETED
public static final int P_DELETED
Persistent-Deleted- See Also:
- Constant Field Values
-
P_NONTRANS
public static final int P_NONTRANS
Persistent-NonTransactional- See Also:
- Constant Field Values
-
P_NONTRANS_DIRTY
public static final int P_NONTRANS_DIRTY
Persistent-NonTransactionalDirty- See Also:
- Constant Field Values
-
DETACHED_CLEAN
public static final int DETACHED_CLEAN
Detached-Clean- See Also:
- Constant Field Values
-
DETACHED_DIRTY
public static final int DETACHED_DIRTY
Detached-Dirty- See Also:
- Constant Field Values
-
TOTAL
public static final int TOTAL
total number of states- See Also:
- Constant Field Values
-
ILLEGAL_STATE
public static final int ILLEGAL_STATE
illegal state- See Also:
- Constant Field Values
-
isDirty
protected boolean isDirty
-
isNew
protected boolean isNew
-
isDeleted
protected boolean isDeleted
-
isTransactional
protected boolean isTransactional
-
isPersistent
protected boolean isPersistent
-
stateType
protected int stateType
-
-
Method Detail
-
stateType
public final int stateType()
Returns the type of the life cycle state- Returns:
- the type of this life cycle state
-
changeState
protected final LifeCycleState changeState(ObjectProvider op, int newStateType)
Utility to change state to a new state.- Parameters:
op- ObjectProvidernewStateType- The new state- Returns:
- new LifeCycle state.
-
changeTransientState
protected final LifeCycleState changeTransientState(ObjectProvider op, int newStateType)
Utility to change state to a new state.- Parameters:
op- ObjectProvidernewStateType- The new state- Returns:
- new LifeCycle state.
-
transitionMakePersistent
public LifeCycleState transitionMakePersistent(ObjectProvider op)
Method to transition to persistent state.- Parameters:
op- ObjectProvider.- Returns:
- new LifeCycle state.
-
transitionDeletePersistent
public LifeCycleState transitionDeletePersistent(ObjectProvider op)
Method to transition to delete persistent state.- Parameters:
op- ObjectProvider.- Returns:
- new LifeCycle state.
-
transitionMakeTransactional
public LifeCycleState transitionMakeTransactional(ObjectProvider op, boolean refreshFields)
Method to transition to transactional state.- Parameters:
op- ObjectProvider.refreshFields- Whether to refresh loaded fields- Returns:
- new LifeCycle state.
-
transitionMakeNontransactional
public LifeCycleState transitionMakeNontransactional(ObjectProvider op)
Method to transition to nontransactional state.- Parameters:
op- ObjectProvider.- Returns:
- new LifeCycle state.
-
transitionMakeTransient
public LifeCycleState transitionMakeTransient(ObjectProvider op, boolean useFetchPlan, boolean detachAllOnCommit)
Method to transition to transient state.- Parameters:
op- ObjectProvider.useFetchPlan- to make transient the fields in the fetch plandetachAllOnCommit- Whether to detach on commit- Returns:
- new LifeCycle state.
-
transitionBegin
public LifeCycleState transitionBegin(ObjectProvider op, Transaction tx)
Method to transition to transaction begin state.- Parameters:
op- ObjectProvider.tx- Transaction.- Returns:
- new LifeCycle state.
-
transitionCommit
public LifeCycleState transitionCommit(ObjectProvider op, Transaction tx)
Method to transition to commit state.- Parameters:
op- ObjectProvider.tx- the Transaction been committed.- Returns:
- new LifeCycle state.
-
transitionRollback
public LifeCycleState transitionRollback(ObjectProvider op, Transaction tx)
Method to transition to rollback state.- Parameters:
op- ObjectProvider.tx- Transaction.- Returns:
- new LifeCycle state.
-
transitionRefresh
public LifeCycleState transitionRefresh(ObjectProvider op)
Method to transition to refresh state.- Parameters:
op- ObjectProvider.- Returns:
- new LifeCycle state.
-
transitionEvict
public LifeCycleState transitionEvict(ObjectProvider op)
Method to transition to evict state.- Parameters:
op- ObjectProvider.- Returns:
- new LifeCycle state.
-
transitionReadField
public LifeCycleState transitionReadField(ObjectProvider op, boolean isLoaded)
Method to transition to read-field state.- Parameters:
op- ObjectProvider.isLoaded- if the field was previously loaded- Returns:
- new LifeCycle state.
-
transitionWriteField
public LifeCycleState transitionWriteField(ObjectProvider op)
Method to transition to write-field state.- Parameters:
op- ObjectProvider.- Returns:
- new LifeCycle state.
-
transitionRetrieve
public LifeCycleState transitionRetrieve(ObjectProvider op, boolean fgOnly)
Method to transition to retrieve state.- Parameters:
op- ObjectProvider.fgOnly- only retrieve the current fetch group fields- Returns:
- new LifeCycle state.
-
transitionRetrieve
public LifeCycleState transitionRetrieve(ObjectProvider op, FetchPlan fetchPlan)
Method to transition to retrieve state.- Parameters:
op- ObjectProvider.fetchPlan- the fetch plan to load fields- Returns:
- new LifeCycle state.
-
transitionDetach
public LifeCycleState transitionDetach(ObjectProvider op)
Method to transition to detached-clean.- Parameters:
op- ObjectProvider.- Returns:
- new LifeCycle state.
-
transitionAttach
public LifeCycleState transitionAttach(ObjectProvider op)
Method to transition to persistent-clean.- Parameters:
op- ObjectProvider.- Returns:
- new LifeCycle state.
-
transitionSerialize
public LifeCycleState transitionSerialize(ObjectProvider op)
Method to transition when serialised.- Parameters:
op- ObjectProvider- Returns:
- The new LifeCycle state
-
isDirty
public final boolean isDirty()
Return whether the object is dirty, ie has been changed (created, updated, deleted) in this Tx.- Returns:
- Whether the object is dirty.
-
isNew
public final boolean isNew()
Return whether the object was newly created.- Returns:
- Whether the object is new.
-
isDeleted
public final boolean isDeleted()
Return whether the object is deleted.- Returns:
- Whether the object is deleted.
-
isTransactional
public final boolean isTransactional()
Return whether the object is transactional.- Returns:
- Whether the object is transactional.
-
isPersistent
public final boolean isPersistent()
Return whether the object is persistent.- Returns:
- Whether the object is persistent.
-
-