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