01: package org.apache.ojb.odmg.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 java.util.Iterator;
19:
20: import org.apache.ojb.odmg.TransactionImpl;
21:
22: /**
23: * Iterator implementation for {@link org.odmg.DSet} implementation.
24: *
25: * @version $Id: DSetIterator.java,v 1.8.2.2 2005/12/21 22:29:50 tomdz Exp $
26: */
27: class DSetIterator implements Iterator {
28: private Iterator iter;
29: private DSetImpl dSet;
30: private DSetEntry currentEntry = null;
31:
32: /**
33: * DListIterator constructor comment.
34: */
35: public DSetIterator(DSetImpl set) {
36: this .dSet = set;
37: this .iter = set.getElements().iterator();
38: }
39:
40: /**
41: * @see java.util.Iterator#hasNext()
42: */
43: public boolean hasNext() {
44: return iter.hasNext();
45: }
46:
47: /**
48: * @see java.util.Iterator#next()
49: */
50: public Object next() {
51: currentEntry = ((DSetEntry) iter.next());
52: return currentEntry.getRealSubject();
53: }
54:
55: /**
56: * @see java.util.Iterator#remove()
57: */
58: public void remove() {
59: iter.remove();
60: TransactionImpl tx = dSet.getTransaction();
61: if (tx != null) {
62: tx.markDelete(currentEntry);
63: }
64: currentEntry = null;
65: }
66: }
|