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