KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > versant > core > jdo > IteratorWrapper


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;
13
14 import java.util.ListIterator JavaDoc;
15
16 import com.versant.core.common.BindingSupportImpl;
17
18 public class IteratorWrapper implements JDOListIterator {
19     private ListIterator JavaDoc iterator;
20     private boolean closed;
21
22     public IteratorWrapper(ListIterator JavaDoc iterator) {
23         this.iterator = iterator;
24     }
25
26     public boolean hasNext() {
27         if (closed) return false;
28         return iterator.hasNext();
29     }
30
31     public Object JavaDoc 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 JavaDoc o) {
43         throw BindingSupportImpl.getInstance().unsupportedOperation("");
44     }
45
46     public void set(Object JavaDoc 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 JavaDoc previous() {
65         if (closed) {
66             throw BindingSupportImpl.getInstance().noSuchElement("");
67         }
68         return iterator.previous();
69     }
70
71     public boolean hasPrevious() {
72         if (closed) return false;
73         return iterator.hasPrevious();
74     }
75
76     public void close() {
77         this.closed = true;
78         iterator = null;
79     }
80 }
81
Popular Tags