001: /**********************************************************************
002: Copyright (c) 2002 Kelly Grizzle and others. All rights reserved.
003: Licensed under the Apache License, Version 2.0 (the "License");
004: you may not use this file except in compliance with the License.
005: You may obtain a copy of the License at
006:
007: http://www.apache.org/licenses/LICENSE-2.0
008:
009: Unless required by applicable law or agreed to in writing, software
010: distributed under the License is distributed on an "AS IS" BASIS,
011: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012: See the License for the specific language governing permissions and
013: limitations under the License.
014:
015: Contributors:
016: 2002 Mike Martin - unknown changes
017: 2003 Andy Jefferson - commented
018: 2003 Andy Jefferson - added localiser
019: ...
020: **********************************************************************/package org.jpox.jdo.state;
021:
022: import javax.jdo.JDOUserException;
023:
024: import org.jpox.Transaction;
025: import org.jpox.state.LifeCycleState;
026: import org.jpox.StateManager;
027:
028: /**
029: * Class representing the life cycle state of PersistentDeleted.
030: *
031: * @version $Revision: 1.3 $
032: **/
033: class PersistentDeleted extends LifeCycleState {
034: /** Protected Constructor to prevent external instantiation. */
035: protected PersistentDeleted() {
036: isPersistent = true;
037: isDirty = true;
038: isNew = false;
039: isDeleted = true;
040: isTransactional = true;
041:
042: stateType = P_DELETED;
043: }
044:
045: /**
046: * Method to transition to non-transactional.
047: * @param sm StateManager.
048: * @return new LifeCycle state.
049: **/
050: public LifeCycleState transitionMakeNontransactional(StateManager sm) {
051: throw new JDOUserException(LOCALISER.msg("027007"), sm
052: .getInternalObjectId());
053: }
054:
055: /**
056: * Method to transition to transient.
057: * @param sm StateManager.
058: * @param useFetchPlan to make transient the fields in the fetch plan
059: * @return new LifeCycle state.
060: **/
061: public LifeCycleState transitionMakeTransient(StateManager sm,
062: boolean useFetchPlan, boolean detachAllOnCommit) {
063: throw new JDOUserException(LOCALISER.msg("027008"), sm
064: .getInternalObjectId());
065: }
066:
067: /**
068: * Method to transition to commit state.
069: * @param sm StateManager.
070: * @param tx the Transaction been committed.
071: * @return new LifeCycle state.
072: **/
073: public LifeCycleState transitionCommit(StateManager sm,
074: Transaction tx) {
075: sm.clearFields();
076: return changeState(sm, TRANSIENT);
077: }
078:
079: /**
080: * Method to transition to rollback state.
081: * @param sm StateManager.
082: * @param tx The transaction
083: * @return new LifeCycle state.
084: **/
085: public LifeCycleState transitionRollback(StateManager sm,
086: Transaction tx) {
087: if (tx.getRetainValues()) {
088: if (tx.getRestoreValues()) {
089: sm.restoreFields();
090: }
091:
092: return changeState(sm, P_NONTRANS);
093: } else {
094: sm.clearNonPrimaryKeyFields();
095: sm.clearSavedFields();
096: return changeState(sm, HOLLOW);
097: }
098:
099: }
100:
101: /**
102: * Method to transition to read-field state.
103: * @param sm StateManager.
104: * @param isLoaded if the field was previously loaded.
105: * @return new LifeCycle state.
106: **/
107: public LifeCycleState transitionReadField(StateManager sm,
108: boolean isLoaded) {
109: throw new JDOUserException(LOCALISER.msg("027009"), sm
110: .getInternalObjectId());
111: }
112:
113: /**
114: * Method to transition to write-field state.
115: * @param sm StateManager.
116: * @return new LifeCycle state.
117: **/
118: public LifeCycleState transitionWriteField(StateManager sm) {
119: throw new JDOUserException(LOCALISER.msg("027010"), sm
120: .getInternalObjectId());
121: }
122:
123: /**
124: * Method to return a string version of this object.
125: * @return The string "P_DELETED".
126: **/
127: public String toString() {
128: return "P_DELETED";
129: }
130: }
|