001    package org.apache.ojb.broker.util.collections;
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 org.apache.ojb.broker.ManageableCollection;
019    import org.apache.ojb.broker.PersistenceBroker;
020    import org.apache.ojb.broker.PersistenceBrokerException;
021    
022    import java.util.Iterator;
023    import java.util.Vector;
024    
025    /**
026     * is a utility class. provides a Vector that addionally implements
027     * the ManageableCollection interface. This class may be used
028     * as a type for collection attributes.
029     *
030     * @author <a href="mailto:thma@apache.org">Thomas Mahler<a>
031     * @version $Id: ManageableVector.java,v 1.1 2007-08-24 22:17:39 ewestfal Exp $
032     */
033    public class ManageableVector extends Vector implements ManageableCollection
034    {
035        /**
036         * add a single Object to the Collection. This method is used during reading Collection elements
037         * from the database. Thus it is is save to cast anObject to the underlying element type of the
038         * collection.
039         */
040        public void ojbAdd(Object anObject)
041        {
042            this.add(anObject);
043        }
044    
045        /**
046         * adds a Collection to this collection. Used in reading Extents from the Database.
047         * Thus it is save to cast otherCollection to this.getClass().
048         */
049        public void ojbAddAll(ManageableCollection otherCollection)
050        {
051            this.addAll((ManageableVector) otherCollection);
052        }
053    
054        public void afterStore(PersistenceBroker broker) throws PersistenceBrokerException
055        {
056            //do nothing
057        }
058    
059        /**
060         * returns an Iterator over all elements in the collection. Used during store and delete Operations.
061         * If the implementor does not return an iterator over ALL elements, OJB cannot store and delete all elements properly.
062         *
063         */
064        public Iterator ojbIterator()
065        {
066            return this.iterator();
067        }
068    }