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.ad;
22
23 import java.util.Arrays;
24
25 import org.apache.directory.api.ldap.model.message.controls.AbstractControl;
26 import org.apache.directory.api.util.Strings;
27
28
29
30
31
32
33 public class AdDirSyncImpl extends AbstractControl implements AdDirSync
34 {
35
36 int parentFirst = 1;
37
38
39 AdDirSyncFlag flag = AdDirSyncFlag.DEFAULT;
40
41
42 int maxReturnLength = 0;
43
44
45 private byte[] cookie;
46
47
48
49
50 public AdDirSyncImpl()
51 {
52 super( OID, Boolean.TRUE );
53 }
54
55
56
57
58
59 public int getParentFirst()
60 {
61 return parentFirst;
62 }
63
64
65
66
67
68 public void setParentFirst( int parentFirst )
69 {
70 this.parentFirst = parentFirst;
71 }
72
73
74
75
76
77 public AdDirSyncFlag getFlag()
78 {
79 return flag;
80 }
81
82
83
84
85
86 public void setFlag( AdDirSyncFlag flag )
87 {
88 this.flag = flag;
89 }
90
91
92
93
94
95 public int getMaxReturnLength()
96 {
97 return maxReturnLength;
98 }
99
100
101
102
103
104 public void setMaxReturnLength( int maxReturnLength )
105 {
106 this.maxReturnLength = maxReturnLength;
107 }
108
109
110
111
112
113 public byte[] getCookie()
114 {
115 return cookie;
116 }
117
118
119
120
121
122 public void setCookie( byte[] cookie )
123 {
124 if ( cookie != null )
125 {
126 this.cookie = new byte[cookie.length];
127 System.arraycopy( cookie, 0, this.cookie, 0,cookie.length );
128 }
129 else
130 {
131 this.cookie = Strings.EMPTY_BYTES;
132 }
133 }
134
135
136
137
138
139 @Override
140 public int hashCode()
141 {
142 int h = 37;
143
144 h = h * 17 + super.hashCode();
145 h = h * 17 + parentFirst;
146 h = h * 17 + maxReturnLength;
147
148 if ( cookie != null )
149 {
150 for ( byte b : cookie )
151 {
152 h = h * 17 + b;
153 }
154 }
155
156 return h;
157 }
158
159
160
161
162
163 @Override
164 public boolean equals( Object o )
165 {
166 if ( this == o )
167 {
168 return true;
169 }
170
171 if ( !( o instanceof AdDirSync ) )
172 {
173 return false;
174 }
175
176 AdDirSync otherControl = ( AdDirSync ) o;
177
178 return ( maxReturnLength == otherControl.getMaxReturnLength() ) &&
179 ( parentFirst == otherControl.getParentFirst() ) &&
180 ( Arrays.equals( cookie, otherControl.getCookie() ) &&
181 ( isCritical() == otherControl.isCritical() ) );
182 }
183
184
185
186
187
188 @Override
189 public String toString()
190 {
191 StringBuilder sb = new StringBuilder();
192
193 sb.append( " DirSync control :\n" );
194 sb.append( " oid : " ).append( getOid() ).append( '\n' );
195 sb.append( " critical : " ).append( isCritical() ).append( '\n' );
196 sb.append( " parentFirst : '" ).append( getParentFirst() ).append( "'\n" );
197 sb.append( " maxReturnLength : '" ).append( getMaxReturnLength() ).append( "'\n" );
198 sb.append( " cookie : '" ).append( Strings.dumpBytes( getCookie() ) ).append( "'\n" );
199
200 return sb.toString();
201 }
202 }