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.exceptions.JPOXUserException;
026: import org.jpox.state.LifeCycleState;
027: import org.jpox.StateManager;
028:
029: /**
030: * Class representing the life cycle state of PersistentNewDeleted.
031: *
032: * @version $Revision: 1.6 $
033: **/
034: class PersistentNewDeleted extends LifeCycleState {
035: /** Protected Constructor to prevent external instantiation. */
036: protected PersistentNewDeleted() {
037: isPersistent = true;
038: isDirty = true;
039: isNew = true;
040: isDeleted = true;
041: isTransactional = true;
042:
043: stateType = P_NEW_DELETED;
044: }
045:
046: /**
047: * Method to transition to nontransactional.
048: * @param sm StateManager.
049: * @return new LifeCycle state.
050: **/
051: public LifeCycleState transitionMakeNontransactional(StateManager sm) {
052: throw new JPOXUserException(LOCALISER.msg("027003"), sm
053: .getInternalObjectId());
054: }
055:
056: /**
057: * Method to transition to transient.
058: * @param sm StateManager.
059: * @param useFetchPlan to make transient the fields in the fetch plan
060: * @return new LifeCycle state.
061: **/
062: public LifeCycleState transitionMakeTransient(StateManager sm,
063: boolean useFetchPlan, boolean detachAllOnCommit) {
064: throw new JPOXUserException(LOCALISER.msg("027004"), sm
065: .getInternalObjectId());
066: }
067:
068: /**
069: * Method to transition to commit state.
070: * @param sm StateManager.
071: * @param tx the Transaction been committed.
072: * @return new LifeCycle state.
073: **/
074: public LifeCycleState transitionCommit(StateManager sm,
075: Transaction tx) {
076: sm.clearFields();
077: return changeState(sm, TRANSIENT);
078: }
079:
080: /**
081: * Method to transition to rollback state.
082: * @param sm StateManager.
083: * @param tx The transaction
084: * @return new LifeCycle state.
085: **/
086: public LifeCycleState transitionRollback(StateManager sm,
087: Transaction tx) {
088: if (tx.getRestoreValues()) {
089: sm.restoreFields();
090: }
091:
092: return changeState(sm, TRANSIENT);
093: }
094:
095: /**
096: * Method to transition to read-field state.
097: * @param sm StateManager.
098: * @param isLoaded if the field was previously loaded.
099: * @return new LifeCycle state.
100: **/
101: public LifeCycleState transitionReadField(StateManager sm,
102: boolean isLoaded) {
103: throw new JDOUserException(LOCALISER.msg("027005"), sm
104: .getInternalObjectId());
105: }
106:
107: /**
108: * Method to transition to write-field state.
109: * @param sm StateManager.
110: * @return new LifeCycle state.
111: **/
112: public LifeCycleState transitionWriteField(StateManager sm) {
113: throw new JDOUserException(LOCALISER.msg("027006"), sm
114: .getInternalObjectId());
115: }
116:
117: /**
118: * Method to return a string version of this object.
119: * @return The string "P_NEW_DELETED".
120: **/
121: public String toString() {
122: return "P_NEW_DELETED";
123: }
124: }
|