01: package org.apache.ojb.broker.util.collections;
02:
03: /* Copyright 2002-2005 The Apache Software Foundation
04: *
05: * Licensed under the Apache License, Version 2.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: import org.apache.ojb.broker.ManageableCollection;
19: import org.apache.ojb.broker.PersistenceBroker;
20: import org.apache.ojb.broker.PersistenceBrokerException;
21:
22: import java.util.ArrayList;
23: import java.util.Iterator;
24:
25: /**
26: * is a utility class. provides an ArrayList that addionally implements
27: * the ManageableCollection interface. This class may be used
28: * as a type for collection attributes.
29: *
30: * @author <a href="mailto:thma@apache.org">Thomas Mahler<a>
31: * @version $Id: ManageableArrayList.java,v 1.7.2.1 2005/12/21 22:28:15 tomdz Exp $
32: */
33: public class ManageableArrayList extends ArrayList implements
34: ManageableCollection {
35: /**
36: * add a single Object to the Collection. This method is used during reading Collection elements
37: * from the database. Thus it is is save to cast anObject to the underlying element type of the
38: * collection.
39: */
40: public void ojbAdd(Object anObject) {
41: this .add(anObject);
42: }
43:
44: /**
45: * adds a Collection to this collection. Used in reading Extents from the Database.
46: * Thus it is save to cast otherCollection to this.getClass().
47: */
48: public void ojbAddAll(ManageableCollection otherCollection) {
49: this .addAll((ManageableArrayList) otherCollection);
50: }
51:
52: public void afterStore(PersistenceBroker broker)
53: throws PersistenceBrokerException {
54: //do nothing
55: }
56:
57: /**
58: * returns an Iterator over all elements in the collection. Used during store and delete Operations.
59: * If the implementor does not return an iterator over ALL elements, OJB cannot store and delete all elements properly.
60: *
61: */
62: public Iterator ojbIterator() {
63: return this.iterator();
64: }
65: }
|