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.message.AliasDerefMode;
24 import org.apache.directory.api.ldap.model.message.SearchScope;
25 import org.apache.directory.api.ldap.model.name.Dn;
26
27
28
29
30
31
32
33
34 public class ScopeNode extends AbstractExprNode
35 {
36
37 private final SearchScope scope;
38
39
40 private final Dn baseDn;
41
42
43 private final String baseId;
44
45
46 private final AliasDerefMode aliasDerefAliases;
47
48
49
50
51
52
53
54
55
56
57 public ScopeNode( AliasDerefMode aliasDerefAliases, Dn baseDn, String baseId, SearchScope scope )
58 {
59 super( AssertionType.SCOPE );
60 this.scope = scope;
61 this.baseDn = baseDn;
62 this.aliasDerefAliases = aliasDerefAliases;
63 this.baseId = baseId;
64 }
65
66
67
68
69
70
71
72
73 @Override
74 public boolean isLeaf()
75 {
76 return true;
77 }
78
79
80
81
82
83
84
85 public SearchScope getScope()
86 {
87 return scope;
88 }
89
90
91
92
93
94
95
96 public Dn getBaseDn()
97 {
98 return baseDn;
99 }
100
101
102
103
104
105
106
107 public String getBaseId()
108 {
109 return baseId;
110 }
111
112
113
114
115
116
117
118 public AliasDerefMode getDerefAliases()
119 {
120 return aliasDerefAliases;
121 }
122
123
124
125
126
127
128
129
130
131 @Override
132 public Object accept( FilterVisitor visitor )
133 {
134 if ( visitor.canVisit( this ) )
135 {
136 return visitor.visit( this );
137 }
138 else
139 {
140 return null;
141 }
142 }
143
144
145
146
147
148
149
150 @Override
151 public boolean isSchemaAware()
152 {
153 return true;
154 }
155
156
157
158
159
160 @Override
161 public boolean equals( Object obj )
162 {
163 if ( obj == this )
164 {
165 return true;
166 }
167
168 if ( !( obj instanceof ScopeNode ) )
169 {
170 return false;
171 }
172 ScopeNode that = ( ScopeNode ) obj;
173 if ( aliasDerefAliases == null )
174 {
175 if ( that.aliasDerefAliases != null )
176 {
177 return false;
178 }
179 }
180 else
181 {
182 if ( !aliasDerefAliases.equals( that.aliasDerefAliases ) )
183 {
184 return false;
185 }
186 }
187 if ( baseDn == null )
188 {
189 if ( that.baseDn != null )
190 {
191 return false;
192 }
193 }
194 else
195 {
196 if ( !baseDn.equals( that.baseDn ) )
197 {
198 return false;
199 }
200 }
201 if ( scope.getScope() != that.scope.getScope() )
202 {
203 return false;
204 }
205 return super.equals( obj );
206 }
207
208
209
210
211
212
213 @Override
214 public int hashCode()
215 {
216 int h = 37;
217
218 h = h * 17 + super.hashCode();
219 h = h * 17 + ( aliasDerefAliases != null ? aliasDerefAliases.hashCode() : 0 );
220 h = h * 17 + ( baseDn != null ? baseDn.hashCode() : 0 );
221 h = h * 17 + scope.getScope();
222
223 return h;
224 }
225
226
227
228
229
230
231 @Override
232 public String toString()
233 {
234 StringBuilder buf = new StringBuilder();
235
236 buf.append( "(#{" );
237
238 switch ( scope )
239 {
240 case OBJECT:
241 buf.append( "OBJECT_SCOPE" );
242
243 break;
244
245 case ONELEVEL:
246 buf.append( "ONE_LEVEL_SCOPE" );
247
248 break;
249
250 case SUBTREE:
251 buf.append( "SUBTREE_SCOPE (Estimated)" );
252
253 break;
254
255 default:
256 buf.append( "UNKNOWN" );
257 break;
258 }
259
260 buf.append( ", '" );
261 buf.append( baseDn );
262 buf.append( "', " );
263 buf.append( aliasDerefAliases );
264 buf.append( "}" );
265 buf.append( super.toString() );
266 buf.append( ')' );
267
268 return buf.toString();
269 }
270 }