KickJava   Java API By Example, From Geeks To Geeks.

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


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.ListIterator JavaDoc;
18
19 import com.versant.core.jdo.VersantStateManager;
20
21 /**
22  * This is an ListIter that calls makeDirty on the sco list when a mutate method is called.
23  *
24  * @keep-all
25  */

26 public class SCOListIterator implements ListIterator JavaDoc {
27
28     private ListIterator JavaDoc delegateIter;
29     private PersistenceCapable owner;
30     private VersantStateManager stateManager;
31     private int fieldNo;
32
33     public SCOListIterator(ListIterator JavaDoc delegateIter, VersantStateManager stateManager, PersistenceCapable owner, int fieldNo) {
34         this.delegateIter = delegateIter;
35         this.stateManager = stateManager;
36         this.owner = owner;
37         this.fieldNo = fieldNo;
38     }
39
40     public boolean hasNext() {
41         return delegateIter.hasNext();
42     }
43
44     public Object JavaDoc next() {
45         return delegateIter.next();
46     }
47
48     public boolean hasPrevious() {
49         return delegateIter.hasPrevious();
50     }
51
52     public Object JavaDoc previous() {
53         return delegateIter.previous();
54     }
55
56     public int nextIndex() {
57         return delegateIter.nextIndex();
58     }
59
60     public int previousIndex() {
61         return delegateIter.previousIndex();
62     }
63
64     public void remove() {
65         delegateIter.remove();
66         makeDirty();
67     }
68
69     public void set(Object JavaDoc o) {
70         delegateIter.set(o);
71         makeDirty();
72     }
73
74     public void add(Object JavaDoc o) {
75         delegateIter.add(o);
76         makeDirty();
77     }
78
79     private void makeDirty() {
80         if (stateManager != null && owner != null) {
81             stateManager.makeDirty(owner, fieldNo);
82         }
83     }
84 }
85
86
87
Popular Tags