1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.directory.server.core.partition.impl.btree;
21
22
23 import java.util.Iterator;
24
25 import org.apache.directory.server.core.cursor.ClosureMonitor;
26 import org.apache.directory.server.core.cursor.Cursor;
27 import org.apache.directory.server.core.cursor.CursorIterator;
28 import org.apache.directory.server.core.entry.ServerEntry;
29 import org.apache.directory.server.core.partition.Partition;
30 import org.apache.directory.server.xdbm.IndexCursor;
31 import org.apache.directory.server.xdbm.IndexEntry;
32
33
34
35
36
37
38
39
40 public class ServerEntryCursorAdaptor implements Cursor<ServerEntry>
41 {
42 private final Partition db;
43 private final IndexCursor<Long, ServerEntry> indexCursor;
44
45
46 public ServerEntryCursorAdaptor( Partition db, IndexCursor<Long, ServerEntry> indexCursor )
47 {
48 this.db = db;
49 this.indexCursor = indexCursor;
50 }
51
52
53
54
55
56 public void after( ServerEntry element ) throws Exception
57 {
58 throw new UnsupportedOperationException();
59 }
60
61
62
63
64
65 public void afterLast() throws Exception
66 {
67 this.indexCursor.afterLast();
68 }
69
70
71
72
73
74 public boolean available()
75 {
76 return indexCursor.available();
77 }
78
79
80
81
82
83 public void before( ServerEntry element ) throws Exception
84 {
85 throw new UnsupportedOperationException();
86 }
87
88
89
90
91
92 public void beforeFirst() throws Exception
93 {
94 indexCursor.beforeFirst();
95 }
96
97
98 public final void setClosureMonitor( ClosureMonitor monitor )
99 {
100 indexCursor.setClosureMonitor( monitor );
101 }
102
103
104
105
106
107 public void close() throws Exception
108 {
109 indexCursor.close();
110 }
111
112
113
114
115
116 public void close( Exception e ) throws Exception
117 {
118 indexCursor.close( e );
119 }
120
121
122
123
124
125 public boolean first() throws Exception
126 {
127 return indexCursor.first();
128 }
129
130
131
132
133
134 public ServerEntry get() throws Exception
135 {
136 IndexEntry<Long,ServerEntry> indexEntry = indexCursor.get();
137
138 if ( indexEntry.getObject() == null )
139 {
140 indexEntry.setObject( db.lookup( indexEntry.getId() ) );
141 }
142
143 return indexEntry.getObject();
144 }
145
146
147
148
149
150 public boolean isClosed() throws Exception
151 {
152 return indexCursor.isClosed();
153 }
154
155
156
157
158
159 public boolean isElementReused()
160 {
161 return indexCursor.isElementReused();
162 }
163
164
165
166
167
168 public boolean last() throws Exception
169 {
170 return indexCursor.last();
171 }
172
173
174
175
176
177 public boolean next() throws Exception
178 {
179 return indexCursor.next();
180 }
181
182
183
184
185
186 public boolean previous() throws Exception
187 {
188 return indexCursor.previous();
189 }
190
191
192
193
194
195 public Iterator<ServerEntry> iterator()
196 {
197 return new CursorIterator<ServerEntry>( this );
198 }
199 }