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.model.filter;
22
23
24 import java.util.List;
25
26
27
28
29
30
31
32 public class AndNode extends BranchNode
33 {
34
35
36
37
38
39 public AndNode( List<ExprNode> childList )
40 {
41 super( AssertionType.AND, childList );
42 }
43
44
45
46
47
48
49
50 public AndNode( ExprNode... childList )
51 {
52 super( AssertionType.AND, childList );
53 }
54
55
56
57
58
59 public AndNode()
60 {
61 super( AssertionType.AND );
62 }
63
64
65
66
67
68
69
70 public AssertionType getOperator()
71 {
72 return AssertionType.AND;
73 }
74
75
76
77
78
79
80
81 public boolean isDisjunction()
82 {
83 return false;
84 }
85
86
87
88
89
90
91
92 public boolean isConjunction()
93 {
94 return true;
95 }
96
97
98
99
100
101
102
103 public boolean isNegation()
104 {
105 return false;
106 }
107
108
109
110
111
112
113
114
115
116 public StringBuilder printRefinementToBuffer( StringBuilder buf )
117 {
118 buf.append( "and: {" );
119 boolean isFirst = true;
120
121 for ( ExprNode node : children )
122 {
123 if ( isFirst )
124 {
125 isFirst = false;
126 buf.append( ' ' );
127 }
128 else
129 {
130 buf.append( ", " );
131 }
132
133 node.printRefinementToBuffer( buf );
134 }
135
136 buf.append( " }" );
137
138 return buf;
139 }
140
141
142
143
144
145
146
147
148
149 public String toString()
150 {
151 StringBuffer buf = new StringBuffer();
152 buf.append( "(&" );
153
154 buf.append( super.toString() );
155
156 for ( ExprNode child : getChildren() )
157 {
158 buf.append( child );
159 }
160
161 buf.append( ')' );
162
163 return buf.toString();
164 }
165
166
167
168
169
170
171 public int hashCode()
172 {
173 int hash = 37;
174 hash = hash * 17 + AssertionType.AND.hashCode();
175 hash = hash * 17 + ( annotations == null ? 0 : annotations.hashCode() );
176 return hash;
177 }
178
179
180
181
182
183 public boolean equals( Object other )
184 {
185 if ( this == other )
186 {
187 return true;
188 }
189
190 if ( !( other instanceof AndNode ) )
191 {
192 return false;
193 }
194
195 AndNode otherExprNode = ( AndNode ) other;
196
197 List<ExprNode> otherChildren = otherExprNode.getChildren();
198
199 if ( otherChildren == children )
200 {
201 return true;
202 }
203
204 if ( children.size() != otherChildren.size() )
205 {
206 return false;
207 }
208
209 for ( int i = 0; i < children.size(); i++ )
210 {
211 ExprNode child = children.get( i );
212 ExprNode otherChild = otherChildren.get( i );
213
214 if ( !child.equals( otherChild ) )
215 {
216 return false;
217 }
218 }
219
220 return true;
221 }
222 }