APIdia Launch Partner
Top Description Fields Constructors Methods
javax.naming.directory

public Class SearchControls

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable

This class encapsulates factors that determine scope of search and what gets returned as a result of the search.

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.

Authors
Rosanna Lee, Scott Seligman
Since
1.3

Field Summary

Modifier and TypeField and Description
private String[]
attributesToReturn

Contains the list of attributes to be returned in SearchResult for each matching entry of search.

private long
countLimit

Contains the maximum number of SearchResults to return.

private boolean
derefLink

Indicates whether JNDI links are dereferenced during search.

public static final int
OBJECT_SCOPE

Search the named object.

public static final int
ONELEVEL_SCOPE

Search one level of the named context.

private boolean
returnObj

Indicates whether object is returned in SearchResult.

private int
searchScope

Contains the scope with which to apply the search.

private static final long
serialVersionUID

Use serialVersionUID from JNDI 1.1.1 for interoperability.

public static final int
SUBTREE_SCOPE

Search the entire subtree rooted at the named object.

private int
timeLimit

Contains the milliseconds to wait before returning from search.

Constructor Summary

AccessConstructor and Description
public
SearchControls()

Constructs a search constraints using defaults.

public
SearchControls(int
The search scope. One of: OBJECT_SCOPE, ONELEVEL_SCOPE, SUBTREE_SCOPE.
scope
,
long
The maximum number of entries to return. If 0, return all entries that satisfy filter.
countlim
,
int
The number of milliseconds to wait before returning. If 0, wait indefinitely.
timelim
,
String[]
The identifiers of the attributes to return along with the entry. If null, return all attributes. If empty return no attributes.
attrs
,
boolean
If true, return the object bound to the name of the entry; if false, do not return object.
retobj
,
boolean
If true, dereference links during search.
deref
)

Constructs a search constraints using arguments.

Method Summary

Modifier and TypeMethod and Description
public long

Returns:

The maximum number of entries that will be returned.
getCountLimit
()

Retrieves the maximum number of entries that will be returned as a result of the search.

public boolean

Returns:

true if links will be dereferenced; false otherwise.
getDerefLinkFlag
()

Determines whether links will be dereferenced during the search.

public String[]

Returns:

An array of attribute ids identifying the attributes that will be returned. Can be null.
getReturningAttributes
()

Retrieves the attributes that will be returned as part of the search.

public boolean

Returns:

true if objects will be returned; false otherwise.
getReturningObjFlag
()

Determines whether objects will be returned as part of the result.

public int

Returns:

The search scope of this SearchControls.
getSearchScope
()

Retrieves the search scope of these SearchControls.

public int

Returns:

The time limit of these SearchControls in milliseconds.
getTimeLimit
()

Retrieves the time limit of these SearchControls in milliseconds.

public void
setCountLimit(long
The maximum number of entries that will be returned.
limit
)

Sets the maximum number of entries to be returned as a result of the search.

public void
setDerefLinkFlag(boolean
if true links will be dereferenced; if false, not followed.
on
)

Enables/disables link dereferencing during the search.

public void
setReturningAttributes(String[]
An array of attribute ids identifying the attributes that will be returned. Can be null.
attrs
)

Specifies the attributes that will be returned as part of the search.

public void
setReturningObjFlag(boolean
if true, objects will be returned; if false, objects will not be returned.
on
)

Enables/disables returning objects returned as part of the result.

public void
setSearchScope(int
The search scope of this SearchControls.
scope
)

Sets the search scope to one of: OBJECT_SCOPE, ONELEVEL_SCOPE, SUBTREE_SCOPE.

public void
setTimeLimit(int
The time limit of these SearchControls in milliseconds.
ms
)

Sets the time limit of these SearchControls in milliseconds.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

attributesToReturnback to summary
private String[] attributesToReturn

Contains the list of attributes to be returned in SearchResult for each matching entry of search. null indicates that all attributes are to be returned.

countLimitback to summary
private long countLimit

Contains the maximum number of SearchResults to return.

OBJECT_SCOPEback to summary
public static final int OBJECT_SCOPE

Search the named object.

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().

The value of this constant is 0.

ONELEVEL_SCOPEback to summary
public static final int ONELEVEL_SCOPE

Search one level of the named context.

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.

The value of this constant is 1.

returnObjback to summary
private boolean returnObj

Indicates whether object is returned in SearchResult.

searchScopeback to summary
private int searchScope

Contains the scope with which to apply the search. One of ONELEVEL_SCOPE, OBJECT_SCOPE, or SUBTREE_SCOPE.

serialVersionUIDback to summary
private static final long serialVersionUID

Use serialVersionUID from JNDI 1.1.1 for interoperability.

SUBTREE_SCOPEback to summary
public static final int SUBTREE_SCOPE

Search the entire subtree rooted at the named object.

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.

The search will not cross naming system boundaries.

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.

The value of this constant is 2.

timeLimitback to summary
private int timeLimit

Contains the milliseconds to wait before returning from search.

Constructor Detail

SearchControlsback to summary
public SearchControls()

Constructs a search constraints using defaults.

The defaults are:

  • search one level
  • no maximum return limit for search results
  • no time limit for search
  • return all attributes associated with objects that satisfy the search filter.
  • do not return named object (return only name and class)
  • do not dereference links during search
SearchControlsback to summary
public SearchControls(int scope, long countlim, int timelim, String[] attrs, boolean retobj, boolean deref)

Constructs a search constraints using arguments.

Parameters
scope:int

The search scope. One of: OBJECT_SCOPE, ONELEVEL_SCOPE, SUBTREE_SCOPE.

countlim:long

The maximum number of entries to return. If 0, return all entries that satisfy filter.

timelim:int

The number of milliseconds to wait before returning. If 0, wait indefinitely.

attrs:String[]

The identifiers of the attributes to return along with the entry. If null, return all attributes. If empty return no attributes.

retobj:boolean

If true, return the object bound to the name of the entry; if false, do not return object.

deref:boolean

If true, dereference links during search.

Method Detail

getCountLimitback to summary
public long getCountLimit()

Retrieves the maximum number of entries that will be returned as a result of the search.

0 indicates that all entries will be returned.

Returns:long

The maximum number of entries that will be returned.

See Also
setCountLimit
getDerefLinkFlagback to summary
public boolean getDerefLinkFlag()

Determines whether links will be dereferenced during the search.

Returns:boolean

true if links will be dereferenced; false otherwise.

See Also
setDerefLinkFlag
getReturningAttributesback to summary
public String[] getReturningAttributes()

Retrieves the attributes that will be returned as part of the search.

A value of null indicates that all attributes will be returned. An empty array indicates that no attributes are to be returned.

Returns:String[]

An array of attribute ids identifying the attributes that will be returned. Can be null.

See Also
setReturningAttributes
getReturningObjFlagback to summary
public boolean getReturningObjFlag()

Determines whether objects will be returned as part of the result.

Returns:boolean

true if objects will be returned; false otherwise.

See Also
setReturningObjFlag
getSearchScopeback to summary
public int getSearchScope()

Retrieves the search scope of these SearchControls.

One of OBJECT_SCOPE, ONELEVEL_SCOPE, SUBTREE_SCOPE.

Returns:int

The search scope of this SearchControls.

See Also
setSearchScope
getTimeLimitback to summary
public int getTimeLimit()

Retrieves the time limit of these SearchControls in milliseconds.

If the value is 0, this means to wait indefinitely.

Returns:int

The time limit of these SearchControls in milliseconds.

See Also
setTimeLimit
setCountLimitback to summary
public void setCountLimit(long limit)

Sets the maximum number of entries to be returned as a result of the search.

0 indicates no limit: all entries will be returned.

Parameters
limit:long

The maximum number of entries that will be returned.

See Also
getCountLimit
setDerefLinkFlagback to summary
public void setDerefLinkFlag(boolean on)

Enables/disables link dereferencing during the search.

Parameters
on:boolean

if true links will be dereferenced; if false, not followed.

See Also
getDerefLinkFlag
setReturningAttributesback to summary
public void setReturningAttributes(String[] attrs)

Specifies the attributes that will be returned as part of the search.

null indicates that all attributes will be returned. An empty array indicates no attributes are returned.

Parameters
attrs:String[]

An array of attribute ids identifying the attributes that will be returned. Can be null.

See Also
getReturningAttributes
setReturningObjFlagback to summary
public void setReturningObjFlag(boolean on)

Enables/disables returning objects returned as part of the result.

If disabled, only the name and class of the object is returned. If enabled, the object will be returned.

Parameters
on:boolean

if true, objects will be returned; if false, objects will not be returned.

See Also
getReturningObjFlag
setSearchScopeback to summary
public void setSearchScope(int scope)

Sets the search scope to one of: OBJECT_SCOPE, ONELEVEL_SCOPE, SUBTREE_SCOPE.

Parameters
scope:int

The search scope of this SearchControls.

See Also
getSearchScope
setTimeLimitback to summary
public void setTimeLimit(int ms)

Sets the time limit of these SearchControls in milliseconds.

If the value is 0, this means to wait indefinitely.

Parameters
ms:int

The time limit of these SearchControls in milliseconds.

See Also
getTimeLimit