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