1 package org.apache.ojb.odmg.collections; 2 3 /* Copyright 2002-2005 The Apache Software Foundation 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * 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.1 2007-08-24 22:17:37 ewestfal Exp $ 26 */ 27 class DSetIterator implements Iterator 28 { 29 private Iterator iter; 30 private DSetImpl dSet; 31 private DSetEntry currentEntry = null; 32 33 /** 34 * DListIterator constructor comment. 35 */ 36 public DSetIterator(DSetImpl set) 37 { 38 this.dSet = set; 39 this.iter = set.getElements().iterator(); 40 } 41 42 /** 43 * @see java.util.Iterator#hasNext() 44 */ 45 public boolean hasNext() 46 { 47 return iter.hasNext(); 48 } 49 50 /** 51 * @see java.util.Iterator#next() 52 */ 53 public Object next() 54 { 55 currentEntry = ((DSetEntry) iter.next()); 56 return currentEntry.getRealSubject(); 57 } 58 59 /** 60 * @see java.util.Iterator#remove() 61 */ 62 public void remove() 63 { 64 iter.remove(); 65 TransactionImpl tx = dSet.getTransaction(); 66 if (tx != null) 67 { 68 tx.markDelete(currentEntry); 69 } 70 currentEntry = null; 71 } 72 }