KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > browser > core > model > SearchParameter


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  *
19  */

20
21 package org.apache.directory.ldapstudio.browser.core.model;
22
23
24 import java.io.Serializable JavaDoc;
25
26
27 /**
28  * A Bean class to hold the search parameters.
29  * It is used to make searches persistent.
30  *
31  * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
32  * @version $Rev$, $Date$
33  */

34 public class SearchParameter implements Serializable JavaDoc
35 {
36
37     /** The serialVersionUID. */
38     private static final long serialVersionUID = 2447490121520960805L;
39
40     /** The symbolic name. */
41     private String JavaDoc name;
42
43     /** The search base. */
44     private DN searchBase;
45
46     /** The filter. */
47     private String JavaDoc filter;
48
49     /** The returning attributes. */
50     private String JavaDoc[] returningAttributes;
51
52     /** The search scope, one of ISearch.SCOPE_OBJECT, ISearch.SCOPE_ONELEVEL or ISearch.SCOPE_SUBTREE. */
53     private int scope;
54
55     /** The time limit in milliseconds, 0 means no limit. */
56     private int timeLimit;
57
58     /** The count limit, 0 means no limit. */
59     private int countLimit;
60
61     /** The alias dereferencing method, one of IConnection.DEREFERENCE_ALIASES_NEVER, IConnection.DEREFERENCE_ALIASES_ALWAYS, IConnection.DEREFERENCE_ALIASES_FINDING or IConnection.DEREFERENCE_ALIASES_SEARCH. */
62     private int aliasesDereferencingMethod;
63
64     /** The referrals handling method, one of IConnection.HANDLE_REFERRALS_IGNORE or IConnection.HANDLE_REFERRALS_FOLLOW. */
65     private int referralsHandlingMethod;
66
67     /** The controls */
68     private Control[] controls;
69
70     /** Flag indicating wether the hasChildren flag of IEntry should be initialized */
71     private boolean initHasChildrenFlag;
72
73     /** Flag indicating wether the isAlias and isReferral flag of IEntry should be initialized */
74     private boolean initAliasAndReferralFlag;
75
76
77     /**
78      * Creates a new instance of SearchParameter with default search parameters:
79      * <ul>
80      * <li>null search name
81      * <li>null search base
82      * <li>default filter (objectClass=*)
83      * <li>no returning attributes
84      * <li>search scope one level
85      * <li>no count limit
86      * <li>no time limit
87      * <li>never dereference aliases
88      * <li>ignore referrals
89      * <li>no initialization of hasChildren flag
90      * <li>no initialization of isAlias and isReferral flag
91      * <li>no controls
92      * </ul>
93      */

94     public SearchParameter()
95     {
96         name = null;
97         searchBase = null;
98         filter = ISearch.FILTER_TRUE;
99         returningAttributes = ISearch.NO_ATTRIBUTES;
100         scope = ISearch.SCOPE_ONELEVEL;
101         timeLimit = 0;
102         countLimit = 0;
103         aliasesDereferencingMethod = IConnection.DEREFERENCE_ALIASES_NEVER;
104         referralsHandlingMethod = IConnection.HANDLE_REFERRALS_IGNORE;
105         controls = null;
106         initHasChildrenFlag = false;
107         initAliasAndReferralFlag = false;
108     }
109
110
111     /**
112      * Gets the count limit, 0 means no limit.
113      *
114      * @return the count limit
115      */

116     public int getCountLimit()
117     {
118         return countLimit;
119     }
120
121
122     /**
123      * Sets the count limit, 0 means no limit.
124      *
125      * @param countLimit the count limit
126      */

127     public void setCountLimit( int countLimit )
128     {
129         this.countLimit = countLimit;
130     }
131
132
133     /**
134      * Gets the filter.
135      *
136      * @return the filter
137      */

138     public String JavaDoc getFilter()
139     {
140         return filter;
141     }
142
143
144     /**
145      * Sets the filter, a null or empty filter will be
146      * transformed to (objectClass=*).
147      *
148      * @param filter the filter
149      */

150     public void setFilter( String JavaDoc filter )
151     {
152         if ( filter == null || "".equals( filter ) ) //$NON-NLS-1$
153
{
154             filter = ISearch.FILTER_TRUE;
155         }
156         this.filter = filter;
157     }
158
159
160     /**
161      * Gets the symbolic name.
162      *
163      * @return the name
164      */

165     public String JavaDoc getName()
166     {
167         return name;
168     }
169
170
171     /**
172      * Sets the symbolic name.
173      *
174      * @param name the name
175      */

176     public void setName( String JavaDoc name )
177     {
178         this.name = name;
179     }
180
181
182     /**
183      * Gets the returning attributes.
184      *
185      * @return the returning attributes
186      */

187     public String JavaDoc[] getReturningAttributes()
188     {
189         return returningAttributes;
190     }
191
192
193     /**
194      * Sets the returning attributes, an empty array indicates none,
195      * null will be transformed to '*' (all user attributes).
196      *
197      * @param returningAttributes the returning attributes
198      */

199     public void setReturningAttributes( String JavaDoc[] returningAttributes )
200     {
201         if ( returningAttributes == null )
202         {
203             returningAttributes = new String JavaDoc[]
204                 { ISearch.ALL_USER_ATTRIBUTES };
205         }
206         this.returningAttributes = returningAttributes;
207     }
208
209
210     /**
211      * Gets the scope, one of ISearch.SCOPE_OBJECT,
212      * ISearch.SCOPE_ONELEVEL or ISearch.SCOPE_SUBTREE.
213      *
214      * @return the scope
215      */

216     public int getScope()
217     {
218         return scope;
219     }
220
221
222     /**
223      * Sets the scope, one of ISearch.SCOPE_OBJECT,
224      * ISearch.SCOPE_ONELEVEL or ISearch.SCOPE_SUBTREE.
225      *
226      * @param scope the scope
227      */

228     public void setScope( int scope )
229     {
230         this.scope = scope;
231     }
232
233
234     /**
235      * Gets the aliases dereferencing method, one of IConnection.DEREFERENCE_ALIASES_NEVER,
236      * IConnection.DEREFERENCE_ALIASES_ALWAYS, IConnection.DEREFERENCE_ALIASES_FINDING
237      * or IConnection.DEREFERENCE_ALIASES_SEARCH.
238      *
239      * @return the aliases dereferencing method
240      */

241     public int getAliasesDereferencingMethod()
242     {
243         return aliasesDereferencingMethod;
244     }
245
246
247     /**
248      * Sets the aliases dereferencing method, one of IConnection.DEREFERENCE_ALIASES_NEVER,
249      * IConnection.DEREFERENCE_ALIASES_ALWAYS, IConnection.DEREFERENCE_ALIASES_FINDING
250      * or IConnection.DEREFERENCE_ALIASES_SEARCH.
251      *
252      * @param aliasesDereferencingMethod the aliases dereferencing method
253      */

254     public void setAliasesDereferencingMethod( int aliasesDereferencingMethod )
255     {
256         this.aliasesDereferencingMethod = aliasesDereferencingMethod;
257     }
258
259
260     /**
261      * Gets the referrals handling method, one of IConnection.HANDLE_REFERRALS_IGNORE
262      * or IConnection.HANDLE_REFERRALS_FOLLOW.
263      *
264      * @return the referrals handling method
265      */

266     public int getReferralsHandlingMethod()
267     {
268         return referralsHandlingMethod;
269     }
270
271
272     /**
273      * Sets the referrals handling method, one of IConnection.HANDLE_REFERRALS_IGNORE or
274      * IConnection.HANDLE_REFERRALS_FOLLOW.
275      *
276      * @param referralsHandlingMethod the referrals handling method
277      */

278     public void setReferralsHandlingMethod( int referralsHandlingMethod )
279     {
280         this.referralsHandlingMethod = referralsHandlingMethod;
281     }
282
283
284     /**
285      * Gets the search base.
286      *
287      * @return the search base
288      */

289     public DN getSearchBase()
290     {
291         return searchBase;
292     }
293
294
295     /**
296      * Sets the search base, a null search base is not allowed.
297      *
298      * @param searchBase the search base
299      */

300     public void setSearchBase( DN searchBase )
301     {
302         assert searchBase != null;
303         this.searchBase = searchBase;
304     }
305
306
307     /**
308      * Gets the time limit in milliseconds, 0 means no limit.
309      *
310      * @return the time limit
311      */

312     public int getTimeLimit()
313     {
314         return timeLimit;
315     }
316
317
318     /**
319      * Sets the time limit in milliseconds, 0 means no limit.
320      *
321      * @param timeLimit the time limit
322      */

323     public void setTimeLimit( int timeLimit )
324     {
325         this.timeLimit = timeLimit;
326     }
327
328
329     /**
330      * {@inheritDoc}
331      */

332     public Object JavaDoc clone()
333     {
334         SearchParameter clone = new SearchParameter();
335         clone.setName( getName() );
336         clone.setSearchBase( getSearchBase() );
337         clone.setFilter( getFilter() );
338         clone.setReturningAttributes( getReturningAttributes() );
339         clone.setScope( getScope() );
340         clone.setTimeLimit( getTimeLimit() );
341         clone.setCountLimit( getCountLimit() );
342         clone.setAliasesDereferencingMethod( getAliasesDereferencingMethod() );
343         clone.setReferralsHandlingMethod( getReferralsHandlingMethod() );
344         clone.setInitHasChildrenFlag( isInitHasChildrenFlag() );
345         clone.setInitAliasAndReferralFlag( isInitAliasAndReferralFlag() );
346         clone.setControls( getControls() );
347         return clone;
348     }
349
350
351     /**
352      * Checks if the isAlias and isReferral flags of IEntry should be initialized.
353      *
354      * @return true, if the isAlias and isReferral flags of IEntry should be initialized
355      */

356     public boolean isInitAliasAndReferralFlag()
357     {
358         return initAliasAndReferralFlag;
359     }
360
361
362     /**
363      * Sets if the hasChildren flag of IEntry should be initialized.
364      *
365      * @param initAliasAndReferralFlag the init isAlias and isReferral flag
366      */

367     public void setInitAliasAndReferralFlag( boolean initAliasAndReferralFlag )
368     {
369         this.initAliasAndReferralFlag = initAliasAndReferralFlag;
370     }
371
372
373     /**
374      * Checks if the hasChildren flag of IEntry should be initialized.
375      *
376      * @return true, if the hasChildren flag of IEntry should be initialized
377      */

378     public boolean isInitHasChildrenFlag()
379     {
380         return initHasChildrenFlag;
381     }
382
383
384     /**
385      * Sets if the hasChildren flag of IEntry should be initialized.
386      *
387      * @param initHasChildrenFlag the init hasChildren flag
388      */

389     public void setInitHasChildrenFlag( boolean initHasChildrenFlag )
390     {
391         this.initHasChildrenFlag = initHasChildrenFlag;
392     }
393
394
395     /**
396      * Gets the controls.
397      *
398      * @return the controls
399      */

400     public Control[] getControls()
401     {
402         return controls;
403     }
404
405
406     /**
407      * Sets the controls.
408      *
409      * @param controls the controls
410      */

411     public void setControls( Control[] controls )
412     {
413         this.controls = controls;
414     }
415
416 }
417
Popular Tags