FileDocCategorySizeDatePackage
LifeCycleState.javaAPI DocGlassfish v2 API15246Fri May 04 22:35:16 BST 2007com.sun.jdo.spi.persistence.support.sqlstore.state

LifeCycleState

public abstract class LifeCycleState extends Object

Fields Summary
protected static final ResourceBundle
messages
I18N message handler
protected boolean
isPersistent
protected boolean
isAutoPersistent
protected boolean
isPersistentInDataStore
protected boolean
isTransactional
protected boolean
isDirty
protected boolean
isNew
protected boolean
isDeleted
protected boolean
isFlushed
protected boolean
isNavigable
protected boolean
isRefreshable
protected boolean
isBeforeImageUpdatable
protected boolean
needsRegister
protected boolean
needsReload
protected boolean
needsRestoreOnRollback
protected boolean
needMerge
protected int
updateAction
protected int
stateType
protected static final int
NO_OP
Constants to specify database operation to be executed
protected static final int
INSERT_OP
protected static final int
UPDATE_OP
protected static final int
DELETE_OP
public static final int
HOLLOW
Constants to specify the life cycle state type
public static final int
P_NON_TX
public static final int
P_CLEAN
public static final int
P_DIRTY
public static final int
P_NEW
public static final int
P_NEW_FLUSHED
public static final int
P_NEW_FLUSHED_DELETED
public static final int
P_NEW_DELETED
public static final int
P_DELETED
public static final int
P_DELETED_FLUSHED
public static final int
AP_NEW
public static final int
AP_NEW_PENDING
public static final int
AP_NEW_FLUSHED
public static final int
AP_NEW_FLUSHED_PENDING
public static final int
AP_NEW_FLUSHED_DELETED
public static final int
AP_NEW_DELETED
public static final int
TRANSIENT
public static final int
TOTAL
private static LifeCycleState[]
stateTypes
private static com.sun.jdo.spi.persistence.utility.logging.Logger
logger
Constructors Summary
Methods Summary
protected voidassertTransaction(boolean transactionActive)

        if (!transactionActive) {
            throw new JDOUserException(I18NHelper.getMessage(messages,
                    "jdo.lifecycle.xactnotactive")); // NOI18N
        }
    
public com.sun.jdo.spi.persistence.support.sqlstore.state.LifeCycleStatechangeState(int newStateType)
/ /** Life Cycle State change

        if (logger.isLoggable(Logger.FINER)) {
            Object[] items = new Object[] {this,stateTypes[newStateType]};
            logger.finer("sqlstore.state.lifecyclestate.changestate",items); // NOI18N
        }

        return (stateTypes[newStateType]);
    
public static com.sun.jdo.spi.persistence.support.sqlstore.state.LifeCycleStategetLifeCycleState(int state)
Returns the LifeCycleState for the state constant.

param
op the type as integer
return
the type as LifeCycleState object

        if (logger.isLoggable(Logger.FINER)) {
            logger.finer("sqlstore.state.lifecyclestate.initial",stateTypes[state]); // NOI18N
        }

        return stateTypes[state];
    
public intgetUpdateAction()

        return updateAction;
    
protected static voidinitLifeCycleState()
Initialises the objects. This class implements the "state pattern".


    // ******************************************************************
    // Initialisation stuff
    // ******************************************************************

               
     
        initLifeCycleState();
    
        stateTypes = new LifeCycleState[TOTAL];
        stateTypes[HOLLOW] = new Hollow();
        stateTypes[P_NON_TX] = new PersistentNonTransactional();
        stateTypes[P_CLEAN] = new PersistentClean();
        stateTypes[P_DIRTY] = new PersistentDirty();
        stateTypes[P_NEW] = new PersistentNew();
        stateTypes[P_NEW_FLUSHED] = new PersistentNewFlushed();
        stateTypes[P_NEW_DELETED] = new PersistentNewDeleted();
        stateTypes[P_NEW_FLUSHED_DELETED] = new PersistentNewFlushedDeleted();
        stateTypes[P_DELETED] = new PersistentDeleted();
        stateTypes[P_DELETED_FLUSHED] = new PersistentDeletedFlushed();
        stateTypes[AP_NEW] = new AutoPersistentNew();
        stateTypes[AP_NEW_PENDING] = new AutoPersistentNewPending();
        stateTypes[AP_NEW_FLUSHED] = new AutoPersistentNewFlushed();
        stateTypes[AP_NEW_FLUSHED_PENDING] = new AutoPersistentNewFlushedPending();
        stateTypes[AP_NEW_FLUSHED_DELETED] = new AutoPersistentNewFlushedDeleted();
        stateTypes[AP_NEW_DELETED] = new AutoPersistentNewDeleted();
        stateTypes[TRANSIENT] = null;
    
public booleanisAutoPersistent()
Return whether the object is auto-persistent.

        return isAutoPersistent;
    
public booleanisBeforeImageUpdatable()

        return isBeforeImageUpdatable;
    
public booleanisDeleted()
Return whether the object is deleted.

        return isDeleted;
    
public booleanisDirty()
Return whether the object is dirty, i.e. has been changed (created, updated, deleted) in this Tx.

        return isDirty;
    
public booleanisNavigable()
Return whether the object can dynamically navigate to fields that are not present.

        return isNavigable;
    
public booleanisNew()
Return whether the object was newly created.

        return isNew;
    
public booleanisPersistent()
/ /** Return whether the object is persistent.

        return isPersistent;
    
public booleanisPersistentInDataStore()
Return whether the object is persistent in data store.

        return isPersistentInDataStore;
    
public booleanisRefreshable()
Return whether the object can be refreshed from the database.

        return isRefreshable;
    
public booleanisTransactional()
Return whether the object is transactional.

        return isTransactional;
    
public booleanneedMerge()

        return needMerge;
    
public booleanneedsRegister()
Return whether the object is registered with the persistence manager.

        return needsRegister;
    
public booleanneedsReload(boolean optimistic, boolean nontransactionalRead, boolean transactionActive)

        return needsReload;
    
public booleanneedsRestoreOnRollback(boolean retainValues)

        //
        // The default behavior is if retainValues is true, we always
        // restore the state. Otherwise, the behavior is determined
        // by needsRetoreOnRollback.
        //
        if (retainValues) {
            return true;
        }

        return needsRestoreOnRollback;
    
public intstateType()
Returns the type of the life cycle state

return
the type of this life cycle state

        return stateType;
    
public java.lang.StringtoString()

        switch (stateType) {
            case HOLLOW:
                return "HOLLOW"; // NOI18N
            case P_NON_TX:
                return "P_NON_TX"; // NOI18N
            case P_CLEAN:
                return "P_CLEAN"; // NOI18N
            case P_DIRTY:
                return "P_DIRTY"; // NOI18N
            case P_NEW:
                return "P_NEW"; // NOI18N
            case P_NEW_FLUSHED:
                return "P_NEW_FLUSHED"; // NOI18N
            case P_NEW_FLUSHED_DELETED:
                return "P_NEW_FLUSHED_DELETED"; // NOI18N
            case P_NEW_DELETED:
                return "P_NEW_DELETED"; // NOI18N
            case P_DELETED:
                return "P_DELETED"; // NOI18N
            case P_DELETED_FLUSHED:
                return "P_DELETED_FLUSHED"; // NOI18N
            case AP_NEW:
                return "AP_NEW"; // NOI18N
            case AP_NEW_PENDING:
                return "AP_NEW_PENDING"; // NOI18N
            case AP_NEW_FLUSHED:
                return "AP_NEW_FLUSHED"; // NOI18N
            case AP_NEW_FLUSHED_PENDING:
                return "AP_NEW_FLUSHED_PENDING"; // NOI18N
            case AP_NEW_FLUSHED_DELETED:
                return "AP_NEW_FLUSHED_DELETED"; // NOI18N
            case AP_NEW_DELETED:
                return "AP_NEW_DELETED"; //NOI18N
        }

        return null;
    
public com.sun.jdo.spi.persistence.support.sqlstore.state.LifeCycleStatetransitionCommit(boolean retainValues)

        return this;
    
public com.sun.jdo.spi.persistence.support.sqlstore.state.LifeCycleStatetransitionDeletePersistent()

        return this;
    
public com.sun.jdo.spi.persistence.support.sqlstore.state.LifeCycleStatetransitionFlushed()

        return this;
    
public com.sun.jdo.spi.persistence.support.sqlstore.state.LifeCycleStatetransitionMakePending()

        return this;
    
public com.sun.jdo.spi.persistence.support.sqlstore.state.LifeCycleStatetransitionMakePersistent()

        return this;
    
public com.sun.jdo.spi.persistence.support.sqlstore.state.LifeCycleStatetransitionReadField(boolean optimisitic, boolean nontransactionalRead, boolean transactionActive)

        if (!nontransactionalRead) {
            assertTransaction(transactionActive);
        }

        return this;
    
public com.sun.jdo.spi.persistence.support.sqlstore.state.LifeCycleStatetransitionRefreshPersistent()

        return this;
    
public com.sun.jdo.spi.persistence.support.sqlstore.state.LifeCycleStatetransitionReload(boolean transactionActive)

        return this;
    
public com.sun.jdo.spi.persistence.support.sqlstore.state.LifeCycleStatetransitionRollback(boolean retainValues)

        return this;
    
public com.sun.jdo.spi.persistence.support.sqlstore.state.LifeCycleStatetransitionWriteField(boolean transactionActive)

        assertTransaction(transactionActive);
        return this;