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;
12:
13: import java.util.ListIterator;
14:
15: import com.versant.core.common.BindingSupportImpl;
16:
17: public class IteratorWrapper implements JDOListIterator {
18: private ListIterator iterator;
19: private boolean closed;
20:
21: public IteratorWrapper(ListIterator iterator) {
22: this .iterator = iterator;
23: }
24:
25: public boolean hasNext() {
26: if (closed)
27: return false;
28: return iterator.hasNext();
29: }
30:
31: public Object next() {
32: if (closed) {
33: throw BindingSupportImpl.getInstance().noSuchElement("");
34: }
35: return iterator.next();
36: }
37:
38: public void remove() {
39: throw BindingSupportImpl.getInstance().unsupportedOperation("");
40: }
41:
42: public void add(Object o) {
43: throw BindingSupportImpl.getInstance().unsupportedOperation("");
44: }
45:
46: public void set(Object o) {
47: throw BindingSupportImpl.getInstance().unsupportedOperation("");
48: }
49:
50: public int previousIndex() {
51: if (closed) {
52: throw BindingSupportImpl.getInstance().noSuchElement("");
53: }
54: return iterator.previousIndex();
55: }
56:
57: public int nextIndex() {
58: if (closed) {
59: throw BindingSupportImpl.getInstance().noSuchElement("");
60: }
61: return iterator.nextIndex();
62: }
63:
64: public Object previous() {
65: if (closed) {
66: throw BindingSupportImpl.getInstance().noSuchElement("");
67: }
68: return iterator.previous();
69: }
70:
71: public boolean hasPrevious() {
72: if (closed)
73: return false;
74: return iterator.hasPrevious();
75: }
76:
77: public void close() {
78: this .closed = true;
79: iterator = null;
80: }
81: }
|