KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > versant > core > jdo > sco > SCOIterator


1
2 /*
3  * Copyright (c) 1998 - 2005 Versant Corporation
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  * Versant Corporation - initial API and implementation
11  */

12 package com.versant.core.jdo.sco;
13
14 import com.versant.core.jdo.VersantStateManager;
15
16 import javax.jdo.spi.PersistenceCapable;
17 import java.util.Iterator JavaDoc;
18
19 import com.versant.core.jdo.VersantStateManager;
20
21 /**
22  * @keep-all
23  */

24 public class SCOIterator implements Iterator JavaDoc {
25
26     private Iterator JavaDoc delegateIter;
27     private PersistenceCapable owner;
28     private VersantStateManager stateManager;
29     private int fieldNo;
30
31     public SCOIterator(Iterator JavaDoc delegateIter, VersantStateManager stateManager, PersistenceCapable owner, int fieldNo) {
32         this.delegateIter = delegateIter;
33         this.stateManager = stateManager;
34         this.owner = owner;
35         this.fieldNo = fieldNo;
36     }
37
38     public boolean hasNext() {
39         return delegateIter.hasNext();
40     }
41
42     public Object JavaDoc next() {
43         return delegateIter.next();
44     }
45
46     public void remove() {
47         delegateIter.remove();
48         makeDirty();
49     }
50
51     private void makeDirty() {
52         if (stateManager != null && owner != null) {
53             stateManager.makeDirty(owner, fieldNo);
54         }
55     }
56 }
57
Popular Tags