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 import java.util.Iterator;
24
25 import org.apache.directory.api.i18n.I18n;
26
27
28
29
30
31
32
33
34 public abstract class AbstractCursor<E> implements Cursor<E>
35 {
36
37 private ClosureMonitor monitor = new DefaultClosureMonitor();
38
39
40
41
42
43 @Override
44 public void setClosureMonitor( ClosureMonitor monitor )
45 {
46 if ( monitor == null )
47 {
48 throw new IllegalArgumentException( I18n.err( I18n.ERR_13101_MONITOR ) );
49 }
50
51 this.monitor = monitor;
52 }
53
54
55
56
57
58
59
60 public final void checkNotClosed() throws CursorClosedException
61 {
62 monitor.checkNotClosed();
63 }
64
65
66
67
68
69 @Override
70 public boolean isClosed()
71 {
72 return monitor.isClosed();
73 }
74
75
76
77
78
79 @Override
80 public void close( Exception cause ) throws IOException
81 {
82 monitor.close( cause );
83 }
84
85
86
87
88
89 @Override
90 public void close() throws IOException
91 {
92 monitor.close();
93 }
94
95
96
97
98
99 @Override
100 public Iterator<E> iterator()
101 {
102 return new CursorIterator<>( this );
103 }
104
105
106
107
108
109 @Override
110 public boolean isAfterLast()
111 {
112 throw new UnsupportedOperationException( I18n.err( I18n.ERR_13102_UNSUPPORTED_OPERATION, getClass().getName()
113 .concat( "." ).concat( "isAfterLast()" ) ) );
114 }
115
116
117
118
119
120 @Override
121 public boolean isBeforeFirst()
122 {
123 throw new UnsupportedOperationException( I18n.err( I18n.ERR_13102_UNSUPPORTED_OPERATION, getClass().getName()
124 .concat( "." ).concat( "isBeforeFirst()" ) ) );
125 }
126
127
128
129
130
131 @Override
132 public boolean isFirst()
133 {
134 throw new UnsupportedOperationException( I18n.err( I18n.ERR_13102_UNSUPPORTED_OPERATION, getClass().getName()
135 .concat( "." ).concat( "isFirst()" ) ) );
136 }
137
138
139
140
141
142 @Override
143 public boolean isLast()
144 {
145 throw new UnsupportedOperationException( I18n.err( I18n.ERR_13102_UNSUPPORTED_OPERATION, getClass().getName()
146 .concat( "." ).concat( "isLast()" ) ) );
147 }
148
149
150
151
152
153 @Override
154 public String toString( String tabs )
155 {
156 return tabs;
157 }
158 }