API Overview API Index Package Overview Direct link to this page
JDK 1.6
  javax.naming.directory. SearchControls View Javadoc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319

/*
 * @(#)SearchControls.java	1.11 05/11/17
 *
 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */


package javax.naming.directory;

/**
  * This class encapsulates
  * factors that determine scope of search and what gets returned
  * as a result of the search.
  *<p>
  * A SearchControls instance is not synchronized against concurrent 
  * multithreaded access. Multiple threads trying to access and modify
  * a single SearchControls instance should lock the object.
  *
  * @author Rosanna Lee
  * @author Scott Seligman
  * @version 1.11 05/11/17
  * @since 1.3
  */

public class SearchControls implements java.io.Serializable {
    /**
     * Search the named object.
     *<p>
     * The NamingEnumeration that results from search()
     * using OBJECT_SCOPE will contain one or zero element.
     * The enumeration contains one element if the named object satisfies
     * the search filter specified in search().
     * The element will have as its name the empty string because the names
     * of elements in the NamingEnumeration are relative to the 
     * target context--in this case, the target context is the named object.
     * It contains zero element if the named object does not satisfy
     * the search filter specified in search().
     * <p>
     * The value of this constant is <tt>0</tt>.
     */
    public final static int OBJECT_SCOPE = 0;

    /**
     * Search one level of the named context.
     *<p>
     * The NamingEnumeration that results from search()
     * using ONELEVEL_SCOPE contains elements with
     * objects in the named context that satisfy
     * the search filter specified in search().
     * The names of elements in the NamingEnumeration are atomic names
     * relative to the named context.
     * <p>
     * The value of this constant is <tt>1</tt>.
     */
    public final static int ONELEVEL_SCOPE = 1;
    /**
     * Search the entire subtree rooted at the named object.
     *<p>
     * If the named object is not a DirContext, search only the object.
     * If the named object is a DirContext, search the subtree
     * rooted at the named object, including the named object itself.
     *<p>
     * The search will not cross naming system boundaries.
     *<p>
     * The NamingEnumeration that results from search()
     * using SUBTREE_SCOPE contains elements of objects
     * from the subtree (including the named context)
     * that satisfy the search filter specified in search().
     * The names of elements in the NamingEnumeration are either
     * relative to the named context or is a URL string.
     * If the named context satisfies the search filter, it is
     * included in the enumeration with the empty string as 
     * its name.
     * <p>
     * The value of this constant is <tt>2</tt>.
     */
    public final static int SUBTREE_SCOPE = 2;

    /**
     * Contains the scope with which to apply the search. One of
     * <tt>ONELEVEL_SCOPE</tt>, <tt>OBJECT_SCOPE</tt>, or 
     * <tt>SUBTREE_SCOPE</tt>.
     * @serial
     */
    private int searchScope;

    /**
     * Contains the milliseconds to wait before returning
     * from search.
     * @serial
     */
    private int timeLimit;

    /**
     * Indicates whether JNDI links are dereferenced during
     * search.
     * @serial
     */
    private boolean derefLink;

    /**
     *  Indicates whether object is returned in <tt>SearchResult</tt>.
     * @serial
     */
    private boolean returnObj;

    /**
     * Contains the maximum number of SearchResults to return.
     * @serial
     */
    private long countLimit;

    /**
     *  Contains the list of attributes to be returned in
     * <tt>SearchResult</tt> for each matching entry of search. <tt>null</tt>
     * indicates that all attributes are to be returned.
     * @serial
     */
    private String[] attributesToReturn;

    /**
     * Constructs a search constraints using defaults.
     *<p>
     * The defaults are:
     * <ul>
     * <li>search one level
     * <li>no maximum return limit for search results
     * <li>no time limit for search
     * <li>return all attributes associated with objects that satisfy
     *   the search filter.
     * <li>do not return named object  (return only name and class)
     * <li>do not dereference links during search
     *</ul>
     */
    public SearchControls() {
	searchScope = ONELEVEL_SCOPE;
	timeLimit = 0; // no limit
	countLimit = 0; // no limit
	derefLink = false;
	returnObj = false;
	attributesToReturn = null; // return all
    }

    /**
     * Constructs a search constraints using arguments.
     * @param scope	The search scope.  One of:
     *			OBJECT_SCOPE, ONELEVEL_SCOPE, SUBTREE_SCOPE.
     * @param timelim	The number of milliseconds to wait before returning.
     *			If 0, wait indefinitely.
     * @param deref	If true, dereference links during search.
     * @param countlim	The maximum number of entries to return.  If 0, return
     *			all entries that satisfy filter.
     * @param retobj	If true, return the object bound to the name of the
     *			entry; if false, do not return object.
     * @param attrs	The identifiers of the attributes to return along with
     *			the entry.  If null, return all attributes. If empty
     *			return no attributes.
     */
    public SearchControls(int scope, 
			     long countlim, 
			     int timelim, 
			     String[] attrs,
			     boolean retobj, 
			     boolean deref) {
	searchScope = scope;
	timeLimit = timelim; // no limit
	derefLink = deref;
	returnObj = retobj;
	countLimit = countlim; // no limit
	attributesToReturn = attrs; // return all
    }

    /**
     * Retrieves the search scope of these SearchControls.
     *<p>
     * One of OBJECT_SCOPE, ONELEVEL_SCOPE, SUBTREE_SCOPE.
     *
     * @return The search scope of this SearchControls.
     * @see #setSearchScope
     */
    public int getSearchScope() {
	return searchScope;
    }

    /**
     * Retrieves the time limit of these SearchControls in milliseconds.
     *<p>
     * If the value is 0, this means to wait indefinitely.
     * @return The time limit of these SearchControls in milliseconds.
     * @see #setTimeLimit
     */
    public int getTimeLimit() {
	return timeLimit;
    }

    /**
     * Determines whether links will be dereferenced during the search.
     *
     * @return true if links will be dereferenced; false otherwise.
     * @see #setDerefLinkFlag
     */
    public boolean getDerefLinkFlag() {
	return derefLink;
    }

    /**
     * Determines whether objects will be returned as part of the result.
     * 
     * @return true if objects will be returned; false otherwise.
     * @see #setReturningObjFlag
     */
    public boolean getReturningObjFlag() {
	return returnObj;
    }

    /**
     * Retrieves the maximum number of entries that will be returned
     * as a result of the search.  
     *<p>
     * 0 indicates that all entries will be returned.
     * @return The maximum number of entries that will be returned.
     * @see #setCountLimit
     */
    public long getCountLimit() {
	return countLimit;
    }

    /**
     * Retrieves the attributes that will be returned as part of the search.
     *<p>
     * A value of null indicates that all attributes will be returned.
     * An empty array indicates that no attributes are to be returned.
     *
     * @return An array of attribute ids identifying the attributes that
     * will be returned. Can be null.
     * @see #setReturningAttributes
     */
    public String[] getReturningAttributes() {
	return attributesToReturn;
    }

    /**
     * Sets the search scope to one of:
     * OBJECT_SCOPE, ONELEVEL_SCOPE, SUBTREE_SCOPE.
     * @param scope	The search scope of this SearchControls.
     * @see #getSearchScope
     */
    public void setSearchScope(int scope) {
	searchScope = scope;
    }

    /**
     * Sets the time limit of these SearchControls in milliseconds.
     *<p>
     * If the value is 0, this means to wait indefinitely.
     * @param ms	The time limit of these SearchControls in milliseconds.
     * @see #getTimeLimit
     */
    public void setTimeLimit(int ms) {
	timeLimit = ms;
    }

    /**
     * Enables/disables link dereferencing during the search.
     *
     * @param on 	if true links will be dereferenced; if false, not followed.
     * @see #getDerefLinkFlag
     */
    public void setDerefLinkFlag(boolean on) {
	derefLink = on;
    }

    /**
     * Enables/disables returning objects returned as part of the result.
     *<p>
     * If disabled, only the name and class of the object is returned.
     * If enabled, the object will be returned.
     * 
     * @param on	if true, objects will be returned; if false, 
     * 			objects will not be returned.
     * @see #getReturningObjFlag
     */
    public void setReturningObjFlag(boolean on) {
	returnObj = on;
    }

    /**
     * Sets the maximum number of entries to be returned
     * as a result of the search.  
     *<p>
     * 0 indicates no limit:  all entries will be returned.
     * 
     * @param limit The maximum number of entries that will be returned.
     * @see #getCountLimit
     */
    public void setCountLimit(long limit) {
	countLimit = limit;
    }

    /**
     * Specifies the attributes that will be returned as part of the search.
     *<p>
     * null indicates that all attributes will be returned.
     * An empty array indicates no attributes are returned.
     *
     * @param attrs An array of attribute ids identifying the attributes that
     * 		    will be returned. Can be null.
     * @see #getReturningAttributes
     */
    public void setReturningAttributes(String[] attrs) {
	attributesToReturn = attrs;
    }

    /**
     * Use serialVersionUID from JNDI 1.1.1 for interoperability.
     */
    private static final long serialVersionUID = -2480540967773454797L;
}

Generated By: JavaOnTracks Doclet 0.1.4     ©Thibaut Colar