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.xdbm.search.impl;
21
22
23 import org.apache.directory.server.core.entry.ServerEntry;
24 import org.apache.directory.server.xdbm.AbstractIndexCursor;
25 import org.apache.directory.server.xdbm.ForwardIndexEntry;
26 import org.apache.directory.server.xdbm.IndexCursor;
27 import org.apache.directory.server.xdbm.IndexEntry;
28 import org.apache.directory.server.xdbm.Store;
29
30
31
32
33
34
35
36
37 public class AllEntriesCursor extends AbstractIndexCursor<Long,ServerEntry>
38 {
39 private IndexEntry<Long, ServerEntry> indexEntry = new ForwardIndexEntry<Long, ServerEntry>();
40 private final IndexCursor<String,ServerEntry> wrapped;
41
42
43 public AllEntriesCursor( Store<ServerEntry> db ) throws Exception
44 {
45
46 wrapped = db.getNdnIndex().reverseCursor();
47 }
48
49
50
51
52
53 public void afterValue( Long key, Long value ) throws Exception
54 {
55 checkNotClosed( "afterValue()" );
56 wrapped.afterValue( key, null );
57 }
58
59
60
61
62
63 public void beforeValue( Long id, Long value ) throws Exception
64 {
65 checkNotClosed( "beforeValue()" );
66 wrapped.beforeValue( id, null );
67 }
68
69
70
71
72
73 public void after( IndexEntry<Long,ServerEntry> indexEntry ) throws Exception
74 {
75 checkNotClosed( "after()" );
76 wrapped.afterValue( indexEntry.getId(), null );
77 }
78
79
80
81
82
83 public void afterLast() throws Exception
84 {
85 checkNotClosed( "afterLast()" );
86 wrapped.afterLast();
87 }
88
89
90
91
92
93 public boolean available()
94 {
95 return wrapped.available();
96 }
97
98
99
100
101
102 public void before( IndexEntry<Long,ServerEntry> indexEntry ) throws Exception
103 {
104 checkNotClosed( "before()" );
105 wrapped.beforeValue( indexEntry.getId(), null );
106 }
107
108
109
110
111
112 public void beforeFirst() throws Exception
113 {
114 checkNotClosed( "beforeFirst()" );
115 wrapped.beforeFirst();
116 }
117
118
119
120
121
122 public boolean first() throws Exception
123 {
124 checkNotClosed( "first()" );
125 return wrapped.first();
126 }
127
128
129
130
131
132 public IndexEntry<Long,ServerEntry> get() throws Exception
133 {
134 checkNotClosed( "get()" );
135 IndexEntry<String,ServerEntry> wrappedEntry = wrapped.get();
136 indexEntry.setId( wrappedEntry.getId() );
137 indexEntry.setValue( wrappedEntry.getId() );
138 indexEntry.setObject( wrappedEntry.getObject() );
139 return indexEntry;
140 }
141
142
143
144
145
146 public boolean isElementReused()
147 {
148 return true;
149 }
150
151
152
153
154
155 public boolean last() throws Exception
156 {
157 checkNotClosed( "last()" );
158 return wrapped.last();
159 }
160
161
162
163
164
165 public boolean next() throws Exception
166 {
167 checkNotClosed( "next()" );
168 return wrapped.next();
169 }
170
171
172
173
174
175 public boolean previous() throws Exception
176 {
177 checkNotClosed( "previous()" );
178 return wrapped.previous();
179 }
180 }