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