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
48
49
50
51
52
53 public class VirtualListViewResponseImpl extends AbstractControl implements VirtualListViewResponse
54 {
55
56 private int targetPosition;
57 private int contentCount;
58 private VirtualListViewResultCode virtualListViewResult;
59 private byte[] contextId;
60
61
62 public VirtualListViewResponseImpl()
63 {
64 super( OID );
65 }
66
67
68 @Override
69 public int getTargetPosition()
70 {
71 return targetPosition;
72 }
73
74
75 @Override
76 public void setTargetPosition( int targetPosition )
77 {
78 this.targetPosition = targetPosition;
79 }
80
81
82 @Override
83 public int getContentCount()
84 {
85 return contentCount;
86 }
87
88
89 @Override
90 public void setContentCount( int contentCount )
91 {
92 this.contentCount = contentCount;
93 }
94
95
96 @Override
97 public VirtualListViewResultCode getVirtualListViewResult()
98 {
99 return virtualListViewResult;
100 }
101
102
103 @Override
104 public void setVirtualListViewResult( VirtualListViewResultCode virtualListViewResultCode )
105 {
106 this.virtualListViewResult = virtualListViewResultCode;
107 }
108
109
110 @Override
111 public byte[] getContextId()
112 {
113 return contextId;
114 }
115
116
117 @Override
118 public void setContextId( byte[] contextId )
119 {
120 this.contextId = contextId;
121 }
122
123
124
125
126
127 @Override
128 public int hashCode()
129 {
130 int h = super.hashCode();
131
132 h = h * 37 + targetPosition;
133 h = h * 37 + contentCount;
134 h = h * 37 + ( ( virtualListViewResult == null ) ? 0 : virtualListViewResult.hashCode() );
135
136 if ( contextId != null )
137 {
138 for ( byte b : contextId )
139 {
140 h = h * 17 + b;
141 }
142 }
143
144 return h;
145 }
146
147
148
149
150
151 @Override
152 public boolean equals( Object o )
153 {
154 if ( !super.equals( o ) )
155 {
156 return false;
157 }
158
159 VirtualListViewResponseImpl otherControl = ( VirtualListViewResponseImpl ) o;
160
161 return ( targetPosition == otherControl.getTargetPosition() ) &&
162 ( contentCount == otherControl.getContentCount() ) &&
163 ( virtualListViewResult == otherControl.getVirtualListViewResult() ) &&
164 Arrays.equals( contextId, otherControl.getContextId() );
165 }
166
167
168
169
170
171 public String toString()
172 {
173 StringBuffer sb = new StringBuffer();
174
175 sb.append( " Virtual List View Response Control\n" );
176 sb.append( " oid : " ).append( getOid() ).append( '\n' );
177 sb.append( " critical : " ).append( isCritical() ).append( '\n' );
178 sb.append( " targetPosition : '" ).append( targetPosition ).append( "'\n" );
179 sb.append( " contentCount : '" ).append( contentCount ).append( "'\n" );
180 sb.append( " virtualListViewResult : '" ).append( virtualListViewResult ).append( "'\n" );
181
182 if ( contextId != null )
183 {
184 sb.append( " contextID : '" ).append( Strings.dumpBytes( contextId ) ).append( "'\n" );
185 }
186
187 return sb.toString();
188 }
189 }