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_02001_MONITOR ) );
49 }
50
51 this.monitor = monitor;
52 }
53
54
55
56
57
58
59
60
61 public final void checkNotClosed( String operation ) throws CursorClosedException
62 {
63 monitor.checkNotClosed();
64 }
65
66
67
68
69
70 @Override
71 public boolean isClosed()
72 {
73 return monitor.isClosed();
74 }
75
76
77
78
79
80 @Override
81 public void close( Exception cause ) throws IOException
82 {
83 monitor.close( cause );
84 }
85
86
87
88
89
90 @Override
91 public void close() throws IOException
92 {
93 monitor.close();
94 }
95
96
97
98
99
100 @Override
101 public Iterator<E> iterator()
102 {
103 return new CursorIterator<>( this );
104 }
105
106
107
108
109
110 @Override
111 public boolean isAfterLast()
112 {
113 throw new UnsupportedOperationException( I18n.err( I18n.ERR_02014_UNSUPPORTED_OPERATION, getClass().getName()
114 .concat( "." ).concat( "isAfterLast()" ) ) );
115 }
116
117
118
119
120
121 @Override
122 public boolean isBeforeFirst()
123 {
124 throw new UnsupportedOperationException( I18n.err( I18n.ERR_02014_UNSUPPORTED_OPERATION, getClass().getName()
125 .concat( "." ).concat( "isBeforeFirst()" ) ) );
126 }
127
128
129
130
131
132 @Override
133 public boolean isFirst()
134 {
135 throw new UnsupportedOperationException( I18n.err( I18n.ERR_02014_UNSUPPORTED_OPERATION, getClass().getName()
136 .concat( "." ).concat( "isFirst()" ) ) );
137 }
138
139
140
141
142
143 @Override
144 public boolean isLast()
145 {
146 throw new UnsupportedOperationException( I18n.err( I18n.ERR_02014_UNSUPPORTED_OPERATION, getClass().getName()
147 .concat( "." ).concat( "isLast()" ) ) );
148 }
149
150
151
152
153
154 @Override
155 public String toString( String tabs )
156 {
157 return tabs;
158 }
159 }