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    {
028            static final long serialVersionUID = 4182870857709997816L;
029        public ModificationState()
030        {
031        }
032    
033        /**
034         * return resulting state after marking clean
035         */
036        public abstract ModificationState markClean();
037    
038        /**
039         * return resulting state after marking delete
040         */
041        public abstract ModificationState markDelete();
042    
043        /**
044         * return resulting state after marking dirty
045         */
046        public abstract ModificationState markDirty();
047    
048        /**
049         * return resulting state after marking new
050         */
051        public abstract ModificationState markNew();
052    
053        /**
054         * return resulting state after marking old
055         */
056        public abstract ModificationState markOld();
057    
058        /**
059         *
060         */
061        public abstract void checkpoint(ObjectEnvelope mod)
062                throws PersistenceBrokerException;
063    
064        /**
065         *
066         */
067        public abstract void commit(ObjectEnvelope mod)
068                throws PersistenceBrokerException;
069    
070        /**
071         *
072         */
073        public abstract void rollback(ObjectEnvelope mod);
074    
075        /**
076         * return a String representation
077         * @return java.lang.String
078         */
079        public String toString()
080        {
081            return this.getClass().getName();
082        }
083    
084    
085        /**
086         * returns true is this state requires INSERT
087         * @return boolean
088         */
089        public boolean needsInsert()
090        {
091            return false;
092        }
093    
094        /**
095         * returns true is this state requires UPDATE
096         * @return boolean
097         */
098        public boolean needsUpdate()
099        {
100            return false;
101        }
102    
103        /**
104         * returns true is this state requires DELETE
105         * @return boolean
106         */
107        public boolean needsDelete()
108        {
109            return false;
110        }
111    
112        public boolean isTransient()
113        {
114            return false;
115        }
116    }