001    package org.apache.ojb.broker.util;
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    
019    /**
020     * Insert the type's description here.
021     *
022     * @deprecated Please use {@link ObjectModification#UPDATE} and {@link ObjectModification#INSERT} 
023     * @author Thomas Mahler
024     * @version $Id: ObjectModificationDefaultImpl.java,v 1.1 2007-08-24 22:17:36 ewestfal Exp $
025     */
026    public class ObjectModificationDefaultImpl implements ObjectModification
027    {
028        private boolean needsInsert = false;
029        private boolean needsUpdate = false;
030    
031        /**
032         * ObjectModificationImpl constructor comment.
033         */
034        public ObjectModificationDefaultImpl()
035        {
036            super();
037        }
038    
039        /**
040         * ObjectModificationImpl constructor comment.
041         */
042        public ObjectModificationDefaultImpl(boolean pNeedsInsert, boolean pNeedsUpdate)
043        {
044            needsInsert = pNeedsInsert;
045            needsUpdate = pNeedsUpdate;
046        }
047    
048    
049            public static final ObjectModificationDefaultImpl INSERT = new ObjectModificationDefaultImpl(true, false);
050            public static final ObjectModificationDefaultImpl UPDATE = new ObjectModificationDefaultImpl(false, true);
051    
052    
053        /**
054         * returns true if the underlying Object needs an INSERT statement. Returns false else.
055         */
056        public boolean needsInsert()
057        {
058            return needsInsert;
059        }
060    
061        /**
062         * returns true if the underlying Object needs an UPDATE statement.
063         *
064         * Else Returns false.
065         */
066        public boolean needsUpdate()
067        {
068            return needsUpdate;
069        }
070    
071        /**
072         * Method declaration
073         *
074         * @param newValue
075         */
076        public void setNeedsInsert(boolean newValue)
077        {
078            needsInsert = newValue;
079        }
080    
081        /**
082         * Method declaration
083         *
084         * @param newValue
085         */
086        public void setNeedsUpdate(boolean newValue)
087        {
088            needsUpdate = newValue;
089        }
090    
091        /**
092         * Method declaration
093         */
094        public void markModified()
095        {
096            needsUpdate = true;
097        }
098    }