1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.directory.server.core.cursor;
20
21
22 import java.util.Iterator;
23
24
25
26
27
28
29
30
31 public class IteratorCursor<E> extends AbstractCursor<E>
32 {
33 private final Iterator<E> values;
34 private E current;
35
36
37 public IteratorCursor( Iterator<E> values )
38 {
39 this.values = values;
40 }
41
42
43 public boolean available()
44 {
45 return current != null;
46 }
47
48
49 public void before( E element )
50 {
51 throw new UnsupportedOperationException( "Cannot advance before an element on the underlying Iterator." );
52 }
53
54
55 public void after( E element )
56 {
57 throw new UnsupportedOperationException( "Cannot advance after an element on the underlying Iterator." );
58 }
59
60
61 public void beforeFirst()
62 {
63 throw new UnsupportedOperationException( "Cannot advance before first on the underlying Iterator." );
64 }
65
66
67 public void afterLast()
68 {
69 throw new UnsupportedOperationException( "Cannot adanvce after last on the underlying Iterator." );
70 }
71
72
73 public boolean first()
74 {
75 throw new UnsupportedOperationException( "Cannot advance to first position on the underlying Iterator." );
76 }
77
78
79 public boolean last()
80 {
81 throw new UnsupportedOperationException( "Cannot advance to last position on the underlying Iterator." );
82 }
83
84
85 public boolean previous()
86 {
87 throw new UnsupportedOperationException( "Cannot back up on the underlying Iterator." );
88 }
89
90
91 public boolean next() throws Exception
92 {
93 checkNotClosed( "next()" );
94 if ( values.hasNext() )
95 {
96 current = values.next();
97 return true;
98 }
99
100 return false;
101 }
102
103
104 public E get() throws Exception
105 {
106 checkNotClosed( "get()" );
107 return current;
108 }
109
110
111 public boolean isElementReused()
112 {
113 return false;
114 }
115 }