1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.directory.server.xdbm;
20
21
22 import java.io.IOException;
23
24 import org.apache.directory.api.ldap.model.constants.Loggers;
25 import org.apache.directory.api.ldap.model.cursor.CursorException;
26 import org.apache.directory.api.ldap.model.cursor.InvalidCursorPositionException;
27 import org.apache.directory.api.ldap.model.exception.LdapException;
28 import org.apache.directory.server.core.api.partition.PartitionTxn;
29 import org.apache.directory.server.i18n.I18n;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
32
33
34
35
36
37
38
39 public class EmptyIndexCursor<K> extends AbstractIndexCursor<K>
40 {
41
42 private static final Logger LOG_CURSOR = LoggerFactory.getLogger( Loggers.CURSOR_LOG.getName() );
43
44
45 private static final boolean IS_DEBUG = LOG_CURSOR.isDebugEnabled();
46
47
48 public EmptyIndexCursor( PartitionTxn partitionTxn )
49 {
50 if ( IS_DEBUG )
51 {
52 LOG_CURSOR.debug( "Creating EmptyIndexCursor {}", this );
53 }
54
55 this.partitionTxn = partitionTxn;
56 }
57
58
59
60
61
62 @Override
63 public void before( IndexEntry<K, String> element ) throws LdapException, CursorException
64 {
65 checkNotClosed();
66 }
67
68
69
70
71
72 protected String getUnsupportedMessage()
73 {
74 return UNSUPPORTED_MSG;
75 }
76
77
78
79
80
81 @Override
82 public void after( IndexEntry<K, String> element ) throws LdapException, CursorException
83 {
84 checkNotClosed();
85 }
86
87
88
89
90
91 public void beforeFirst() throws LdapException, CursorException
92 {
93 checkNotClosed();
94 }
95
96
97
98
99
100 public void afterLast() throws LdapException, CursorException
101 {
102 checkNotClosed();
103 }
104
105
106
107
108
109 public boolean first() throws LdapException, CursorException
110 {
111 checkNotClosed();
112 return false;
113 }
114
115
116
117
118
119 public boolean last() throws LdapException, CursorException
120 {
121 checkNotClosed();
122 return false;
123 }
124
125
126
127
128
129 @Override
130 public boolean previous() throws LdapException, CursorException
131 {
132 checkNotClosed();
133 return false;
134 }
135
136
137
138
139
140 @Override
141 public boolean next() throws LdapException, CursorException
142 {
143 checkNotClosed();
144 return false;
145 }
146
147
148
149
150
151 public IndexEntry<K, String> get() throws CursorException
152 {
153 checkNotClosed();
154 throw new InvalidCursorPositionException( I18n.err( I18n.ERR_703 ) );
155 }
156
157
158
159
160
161 public void afterValue( String id, K indexValue ) throws Exception
162 {
163 checkNotClosed();
164 }
165
166
167
168
169
170 public void beforeValue( String id, K indexValue ) throws Exception
171 {
172 checkNotClosed();
173 }
174
175
176
177
178
179 @Override
180 public void close() throws IOException
181 {
182 if ( IS_DEBUG )
183 {
184 LOG_CURSOR.debug( "Closing EmptyIndexCursor {}", this );
185 }
186
187 super.close();
188 }
189
190
191
192
193
194 @Override
195 public void close( Exception cause ) throws IOException
196 {
197 if ( IS_DEBUG )
198 {
199 LOG_CURSOR.debug( "Closing EmptyIndexCursor {}", this );
200 }
201
202 super.close( cause );
203 }
204 }