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