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