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
44
45 public EmptyCursor()
46 {
47 if ( LOG_CURSOR.isDebugEnabled() )
48 {
49 LOG_CURSOR.debug( I18n.msg( I18n.MSG_13103_CREATING_EMPTY_CURSOR, this ) );
50 }
51 }
52
53
54
55
56
57 @Override
58 public boolean available()
59 {
60 return false;
61 }
62
63
64
65
66
67 @Override
68 public void before( E element ) throws LdapException, CursorException
69 {
70 checkNotClosed();
71 }
72
73
74
75
76
77 @Override
78 public void after( E element ) throws LdapException, CursorException
79 {
80 checkNotClosed();
81 }
82
83
84
85
86
87 @Override
88 public void beforeFirst() throws LdapException, CursorException
89 {
90 checkNotClosed();
91 }
92
93
94
95
96
97 @Override
98 public void afterLast() throws LdapException, CursorException
99 {
100 checkNotClosed();
101 }
102
103
104
105
106
107 @Override
108 public boolean first() throws LdapException, CursorException
109 {
110 checkNotClosed();
111 return false;
112 }
113
114
115
116
117
118 @Override
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 @Override
152 public E get() throws CursorException
153 {
154 checkNotClosed();
155 throw new InvalidCursorPositionException( I18n.err( I18n.ERR_13104_EMPTY_CURSOR ) );
156 }
157
158
159
160
161
162 @Override
163 public void close() throws IOException
164 {
165 if ( LOG_CURSOR.isDebugEnabled() )
166 {
167 LOG_CURSOR.debug( I18n.msg( I18n.MSG_13100_CLOSING_EMPTY_CURSOR, this ) );
168 }
169
170 super.close();
171 }
172
173
174
175
176
177 @Override
178 public void close( Exception cause ) throws IOException
179 {
180 if ( LOG_CURSOR.isDebugEnabled() )
181 {
182 LOG_CURSOR.debug( I18n.msg( I18n.MSG_13100_CLOSING_EMPTY_CURSOR, this ) );
183 }
184
185 super.close( cause );
186 }
187 }