001: package org.apache.ojb.odmg.states;
002:
003: /* Copyright 2002-2005 The Apache Software Foundation
004: *
005: * Licensed under the Apache License, Version 2.0 (the "License");
006: * you may not use this file except in compliance with the License.
007: * You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: import java.io.Serializable;
019:
020: import org.apache.ojb.broker.PersistenceBrokerException;
021: import org.apache.ojb.odmg.ObjectEnvelope;
022:
023: /**
024: * Describes an objects transactional state regarding commiting and rollbacking
025: */
026: public abstract class ModificationState implements Serializable {
027: static final long serialVersionUID = 4182870857709997816L;
028:
029: public ModificationState() {
030: }
031:
032: /**
033: * return resulting state after marking clean
034: */
035: public abstract ModificationState markClean();
036:
037: /**
038: * return resulting state after marking delete
039: */
040: public abstract ModificationState markDelete();
041:
042: /**
043: * return resulting state after marking dirty
044: */
045: public abstract ModificationState markDirty();
046:
047: /**
048: * return resulting state after marking new
049: */
050: public abstract ModificationState markNew();
051:
052: /**
053: * return resulting state after marking old
054: */
055: public abstract ModificationState markOld();
056:
057: /**
058: *
059: */
060: public abstract void checkpoint(ObjectEnvelope mod)
061: throws PersistenceBrokerException;
062:
063: /**
064: *
065: */
066: public abstract void commit(ObjectEnvelope mod)
067: throws PersistenceBrokerException;
068:
069: /**
070: *
071: */
072: public abstract void rollback(ObjectEnvelope mod);
073:
074: /**
075: * return a String representation
076: * @return java.lang.String
077: */
078: public String toString() {
079: return this .getClass().getName();
080: }
081:
082: /**
083: * returns true is this state requires INSERT
084: * @return boolean
085: */
086: public boolean needsInsert() {
087: return false;
088: }
089:
090: /**
091: * returns true is this state requires UPDATE
092: * @return boolean
093: */
094: public boolean needsUpdate() {
095: return false;
096: }
097:
098: /**
099: * returns true is this state requires DELETE
100: * @return boolean
101: */
102: public boolean needsDelete() {
103: return false;
104: }
105:
106: public boolean isTransient() {
107: return false;
108: }
109: }
|