1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.directory.api.ldap.model.filter;
21
22
23 import org.apache.directory.api.ldap.model.entry.Value;
24 import org.apache.directory.api.ldap.model.schema.AttributeType;
25
26
27
28
29
30
31
32 public class ExtensibleNode extends LeafNode
33 {
34
35 private Value<?> value;
36
37
38 private String matchingRuleId;
39
40
41 private boolean dnAttributes = false;
42
43
44
45
46
47
48
49 public ExtensibleNode( AttributeType attributeType )
50 {
51 super( attributeType, AssertionType.EXTENSIBLE );
52
53 dnAttributes = false;
54 }
55
56
57
58
59
60
61
62 public ExtensibleNode( String attribute )
63 {
64 super( attribute, AssertionType.EXTENSIBLE );
65
66 dnAttributes = false;
67 }
68
69
70
71
72
73
74
75
76
77
78 public ExtensibleNode( AttributeType attributeType, Value<?> value, String matchingRuleId, boolean dnAttributes )
79 {
80 super( attributeType, AssertionType.EXTENSIBLE );
81
82 this.value = value;
83 this.matchingRuleId = matchingRuleId;
84 this.dnAttributes = dnAttributes;
85 }
86
87
88
89
90
91
92
93
94
95
96 public ExtensibleNode( String attribute, Value<?> value, String matchingRuleId, boolean dnAttributes )
97 {
98 super( attribute, AssertionType.EXTENSIBLE );
99
100 this.value = value;
101 this.matchingRuleId = matchingRuleId;
102 this.dnAttributes = dnAttributes;
103 }
104
105
106
107
108
109
110
111 @Override
112 public ExprNode clone()
113 {
114 ExprNode clone = super.clone();
115
116
117 if ( value != null )
118 {
119 ( ( ExtensibleNode ) clone ).value = value.clone();
120 }
121
122 return clone;
123 }
124
125
126
127
128
129
130
131 public boolean hasDnAttributes()
132 {
133 return dnAttributes;
134 }
135
136
137
138
139
140
141
142 public void setDnAttributes( boolean dnAttributes )
143 {
144 this.dnAttributes = dnAttributes;
145 }
146
147
148
149
150
151
152
153 public String getMatchingRuleId()
154 {
155 return matchingRuleId;
156 }
157
158
159
160
161
162
163
164 public void setMatchingRuleId( String matchingRuleId )
165 {
166 this.matchingRuleId = matchingRuleId;
167 }
168
169
170
171
172
173
174
175 public final Value<?> getValue()
176 {
177 return value;
178 }
179
180
181
182
183
184 public Value<?> getEscapedValue()
185 {
186 if ( value.isHumanReadable() )
187 {
188 return escapeFilterValue( value );
189 }
190
191 return value;
192 }
193
194
195
196
197
198
199
200 public final void setValue( Value<?> value )
201 {
202 this.value = value;
203 }
204
205
206
207
208
209 @Override
210 public boolean equals( Object obj )
211 {
212 if ( obj == this )
213 {
214 return true;
215 }
216
217 if ( ( obj == null ) || !( obj instanceof ExtensibleNode ) )
218 {
219 return false;
220 }
221 ExtensibleNode that = ( ExtensibleNode ) obj;
222
223 if ( dnAttributes != that.dnAttributes )
224 {
225 return false;
226 }
227 if ( !matchingRuleId.equals( that.matchingRuleId ) )
228 {
229 return false;
230 }
231 if ( !value.equals( that.value ) )
232 {
233 return false;
234 }
235
236 return super.equals( obj );
237 }
238
239
240
241
242
243
244 @Override
245 public int hashCode()
246 {
247 int h = 37;
248
249 h = h * 17 + super.hashCode();
250 h = h * 17 + ( dnAttributes ? 1 : 0 );
251 h = h * 17 + matchingRuleId.hashCode();
252 h = h * 17 + value.hashCode();
253
254 return h;
255 }
256
257
258
259
260
261
262 @Override
263 public String toString()
264 {
265 StringBuilder buf = new StringBuilder();
266
267 buf.append( '(' );
268
269 if ( attributeType != null )
270 {
271 buf.append( attributeType.getName() );
272 }
273 else
274 {
275 buf.append( attribute );
276 }
277
278 buf.append( "-" );
279 buf.append( dnAttributes );
280 buf.append( "-EXTENSIBLE-" );
281 buf.append( matchingRuleId );
282 buf.append( "-" );
283 buf.append( value );
284
285 buf.append( super.toString() );
286
287 buf.append( ')' );
288
289 return buf.toString();
290 }
291 }