1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.apache.directory.api.ldap.extras.controls.vlv;
22
23
24 import java.util.Arrays;
25
26 import org.apache.directory.api.ldap.model.message.controls.AbstractControl;
27 import org.apache.directory.api.util.Strings;
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47 public class VirtualListViewRequestImpl extends AbstractControl implements VirtualListViewRequest
48 {
49 private int beforeCount;
50 private int afterCount;
51 private int offset;
52 private int contentCount;
53 private byte[] contextId;
54
55
56 private byte[] assertionValue;
57
58
59 private boolean targetType = OFFSET;
60
61 private static final boolean OFFSET = true;
62 private static final boolean ASSERTION_VALUE = false;
63
64
65
66
67
68 public VirtualListViewRequestImpl()
69 {
70 super( OID );
71 }
72
73
74
75
76
77 @Override
78 public int getBeforeCount()
79 {
80 return beforeCount;
81 }
82
83
84
85
86
87 @Override
88 public void setBeforeCount( int beforeCount )
89 {
90 this.beforeCount = beforeCount;
91 }
92
93
94
95
96
97 @Override
98 public int getAfterCount()
99 {
100 return afterCount;
101 }
102
103
104
105
106
107 @Override
108 public void setAfterCount( int afterCount )
109 {
110 this.afterCount = afterCount;
111 }
112
113
114
115
116
117 @Override
118 public int getOffset()
119 {
120 return offset;
121 }
122
123
124
125
126
127 @Override
128 public void setOffset( int offset )
129 {
130 this.offset = offset;
131 targetType = OFFSET;
132 }
133
134
135
136
137
138 @Override
139 public int getContentCount()
140 {
141 return contentCount;
142 }
143
144
145
146
147
148 @Override
149 public void setContentCount( int contentCount )
150 {
151 this.contentCount = contentCount;
152 }
153
154
155
156
157
158 @Override
159 public byte[] getAssertionValue()
160 {
161 return assertionValue;
162 }
163
164
165
166
167
168 @Override
169 public void setAssertionValue( byte[] assertionValue )
170 {
171 this.assertionValue = assertionValue;
172 targetType = ASSERTION_VALUE;
173 }
174
175
176
177
178
179 @Override
180 public byte[] getContextId()
181 {
182 return contextId;
183 }
184
185
186
187
188
189 @Override
190 public void setContextId( byte[] contextId )
191 {
192 this.contextId = contextId;
193 }
194
195
196
197
198
199 @Override
200 public boolean hasOffset()
201 {
202 return targetType == OFFSET;
203 }
204
205
206
207
208
209 @Override
210 public boolean hasAssertionValue()
211 {
212 return targetType == ASSERTION_VALUE;
213 }
214
215
216
217
218
219 @Override
220 public int hashCode()
221 {
222 int h = super.hashCode();
223
224 h = h * 37 + beforeCount;
225 h = h * 37 + afterCount;
226 h = h * 37 + offset;
227 h = h * 37 + contentCount;
228
229 if ( contextId != null )
230 {
231 for ( byte b : contextId )
232 {
233 h = h * 17 + b;
234 }
235 }
236
237 return h;
238 }
239
240
241
242
243
244 @Override
245 public boolean equals( Object o )
246 {
247 if ( !super.equals( o ) )
248 {
249 return false;
250 }
251
252 VirtualListViewRequestImpl otherControl = ( VirtualListViewRequestImpl ) o;
253
254 return ( beforeCount == otherControl.getBeforeCount() )
255 && ( afterCount == otherControl.getAfterCount() )
256 && ( offset == otherControl.getOffset() )
257 && ( contentCount == otherControl.getContentCount() )
258 && Arrays.equals( contextId, otherControl.getContextId() );
259 }
260
261
262
263
264
265 @Override
266 public String toString()
267 {
268 StringBuilder sb = new StringBuilder();
269
270 sb.append( " Virtual List View Request Control\n" );
271 sb.append( " oid : " ).append( getOid() ).append( '\n' );
272 sb.append( " critical : " ).append( isCritical() ).append( '\n' );
273 sb.append( " beforeCount : '" ).append( beforeCount ).append( "'\n" );
274 sb.append( " afterCount : '" ).append( afterCount ).append( "'\n" );
275 sb.append( " target : \n" );
276
277 if ( targetType == OFFSET )
278 {
279 sb.append( " offset : '" ).append( offset ).append( "'\n" );
280 sb.append( " contentCount : '" ).append( contentCount ).append( "'\n" );
281 }
282 else
283 {
284 sb.append( " assertionValue : '" ).append( Strings.utf8ToString( assertionValue ) )
285 .append( "'\n" );
286
287 }
288
289 if ( contextId != null )
290 {
291 sb.append( " contextID : '" ).append( Strings.dumpBytes( contextId ) ).append( "'\n" );
292 }
293
294 return sb.toString();
295 }
296 }