01: /*
02: * Copyright (c) 1998 - 2005 Versant Corporation
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * Versant Corporation - initial API and implementation
10: */
11: package com.versant.core.jdo.sco;
12:
13: import com.versant.core.jdo.VersantStateManager;
14:
15: import javax.jdo.spi.PersistenceCapable;
16: import java.util.Iterator;
17:
18: import com.versant.core.jdo.VersantStateManager;
19:
20: /**
21: * @keep-all
22: */
23: public class SCOIterator implements Iterator {
24:
25: private Iterator delegateIter;
26: private PersistenceCapable owner;
27: private VersantStateManager stateManager;
28: private int fieldNo;
29:
30: public SCOIterator(Iterator delegateIter,
31: VersantStateManager stateManager, PersistenceCapable owner,
32: int fieldNo) {
33: this .delegateIter = delegateIter;
34: this .stateManager = stateManager;
35: this .owner = owner;
36: this .fieldNo = fieldNo;
37: }
38:
39: public boolean hasNext() {
40: return delegateIter.hasNext();
41: }
42:
43: public Object next() {
44: return delegateIter.next();
45: }
46:
47: public void remove() {
48: delegateIter.remove();
49: makeDirty();
50: }
51:
52: private void makeDirty() {
53: if (stateManager != null && owner != null) {
54: stateManager.makeDirty(owner, fieldNo);
55: }
56: }
57: }
|