javax.naming.directory
Class SearchControls

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by javax.naming.directory.SearchControls
All Implemented Interfaces:
Serializable sample code for java.io.Serializable definition code for java.io.Serializable

public class SearchControls
extends Object sample code for java.lang.Object definition code for java.lang.Object
implements Serializable sample code for java.io.Serializable definition code for 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.

Since:
1.3
See Also:
Serialized Form

Field Summary
static int OBJECT_SCOPE sample code for javax.naming.directory.SearchControls.OBJECT_SCOPE definition code for javax.naming.directory.SearchControls.OBJECT_SCOPE
          Search the named object.
static int ONELEVEL_SCOPE sample code for javax.naming.directory.SearchControls.ONELEVEL_SCOPE definition code for javax.naming.directory.SearchControls.ONELEVEL_SCOPE
          Search one level of the named context.
static int SUBTREE_SCOPE sample code for javax.naming.directory.SearchControls.SUBTREE_SCOPE definition code for javax.naming.directory.SearchControls.SUBTREE_SCOPE
          Search the entire subtree rooted at the named object.
 
Constructor Summary
SearchControls sample code for javax.naming.directory.SearchControls.SearchControls() definition code for javax.naming.directory.SearchControls.SearchControls() ()
          Constructs a search constraints using defaults.
SearchControls sample code for javax.naming.directory.SearchControls.SearchControls(int, long, int, java.lang.String[], boolean, boolean) definition code for javax.naming.directory.SearchControls.SearchControls(int, long, int, java.lang.String[], boolean, boolean) (int scope, long countlim, int timelim, String sample code for java.lang.String definition code for java.lang.String [] attrs, boolean retobj, boolean deref)
          Constructs a search constraints using arguments.
 
Method Summary
 long getCountLimit sample code for javax.naming.directory.SearchControls.getCountLimit() definition code for javax.naming.directory.SearchControls.getCountLimit() ()
          Retrieves the maximum number of entries that will be returned as a result of the search.
 boolean getDerefLinkFlag sample code for javax.naming.directory.SearchControls.getDerefLinkFlag() definition code for javax.naming.directory.SearchControls.getDerefLinkFlag() ()
          Determines whether links will be dereferenced during the search.
 String sample code for java.lang.String definition code for java.lang.String [] getReturningAttributes sample code for javax.naming.directory.SearchControls.getReturningAttributes() definition code for javax.naming.directory.SearchControls.getReturningAttributes() ()
          Retrieves the attributes that will be returned as part of the search.
 boolean getReturningObjFlag sample code for javax.naming.directory.SearchControls.getReturningObjFlag() definition code for javax.naming.directory.SearchControls.getReturningObjFlag() ()
          Determines whether objects will be returned as part of the result.
 int getSearchScope sample code for javax.naming.directory.SearchControls.getSearchScope() definition code for javax.naming.directory.SearchControls.getSearchScope() ()
          Retrieves the search scope of these SearchControls.
 int getTimeLimit sample code for javax.naming.directory.SearchControls.getTimeLimit() definition code for javax.naming.directory.SearchControls.getTimeLimit() ()
          Retrieves the time limit of these SearchControls in milliseconds.
 void setCountLimit sample code for javax.naming.directory.SearchControls.setCountLimit(long) definition code for javax.naming.directory.SearchControls.setCountLimit(long) (long limit)
          Sets the maximum number of entries to be returned as a result of the search.
 void setDerefLinkFlag sample code for javax.naming.directory.SearchControls.setDerefLinkFlag(boolean) definition code for javax.naming.directory.SearchControls.setDerefLinkFlag(boolean) (boolean on)
          Enables/disables link dereferencing during the search.
 void setReturningAttributes sample code for javax.naming.directory.SearchControls.setReturningAttributes(java.lang.String[]) definition code for javax.naming.directory.SearchControls.setReturningAttributes(java.lang.String[]) (String sample code for java.lang.String definition code for java.lang.String [] attrs)
          Specifies the attributes that will be returned as part of the search.
 void setReturningObjFlag sample code for javax.naming.directory.SearchControls.setReturningObjFlag(boolean) definition code for javax.naming.directory.SearchControls.setReturningObjFlag(boolean) (boolean on)
          Enables/disables returning objects returned as part of the result.
 void setSearchScope sample code for javax.naming.directory.SearchControls.setSearchScope(int) definition code for javax.naming.directory.SearchControls.setSearchScope(int) (int scope)
          Sets the search scope to one of: OBJECT_SCOPE, ONELEVEL_SCOPE, SUBTREE_SCOPE.
 void setTimeLimit sample code for javax.naming.directory.SearchControls.setTimeLimit(int) definition code for javax.naming.directory.SearchControls.setTimeLimit(int) (int ms)
          Sets the time limit of these SearchControls in milliseconds.
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Field Detail

OBJECT_SCOPE sample code for javax.naming.directory.SearchControls.OBJECT_SCOPE

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.

See Also:
Constant Field Values

ONELEVEL_SCOPE sample code for javax.naming.directory.SearchControls.ONELEVEL_SCOPE

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.

See Also:
Constant Field Values

SUBTREE_SCOPE sample code for javax.naming.directory.SearchControls.SUBTREE_SCOPE

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.

See Also:
Constant Field Values
Constructor Detail

SearchControls sample code for javax.naming.directory.SearchControls() definition code for javax.naming.directory.SearchControls()

public SearchControls()
Constructs a search constraints using defaults.

The defaults are:


SearchControls sample code for javax.naming.directory.SearchControls(int, long, int, java.lang.String[], boolean, boolean) definition code for javax.naming.directory.SearchControls(int, long, int, java.lang.String[], boolean, boolean)

public SearchControls(int scope,
                      long countlim,
                      int timelim,
                      String sample code for java.lang.String definition code for java.lang.String [] attrs,
                      boolean retobj,
                      boolean deref)
Constructs a search constraints using arguments.

Parameters:
scope - The search scope. One of: OBJECT_SCOPE, ONELEVEL_SCOPE, SUBTREE_SCOPE.
timelim - The number of milliseconds to wait before returning. If 0, wait indefinitely.
deref - If true, dereference links during search.
countlim - The maximum number of entries to return. If 0, return all entries that satisfy filter.
retobj - If true, return the object bound to the name of the entry; if false, do not return object.
attrs - The identifiers of the attributes to return along with the entry. If null, return all attributes. If empty return no attributes.
Method Detail

getSearchScope sample code for javax.naming.directory.SearchControls.getSearchScope() definition code for javax.naming.directory.SearchControls.getSearchScope()

public int getSearchScope()
Retrieves the search scope of these SearchControls.

One of OBJECT_SCOPE, ONELEVEL_SCOPE, SUBTREE_SCOPE.

Returns:
The search scope of this SearchControls.
See Also:
setSearchScope(int) sample code for javax.naming.directory.SearchControls.setSearchScope(int) definition code for javax.naming.directory.SearchControls.setSearchScope(int)

getTimeLimit sample code for javax.naming.directory.SearchControls.getTimeLimit() definition code for javax.naming.directory.SearchControls.getTimeLimit()

public int getTimeLimit()
Retrieves the time limit of these SearchControls in milliseconds.

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

Returns:
The time limit of these SearchControls in milliseconds.
See Also:
setTimeLimit(int) sample code for javax.naming.directory.SearchControls.setTimeLimit(int) definition code for javax.naming.directory.SearchControls.setTimeLimit(int)

getDerefLinkFlag sample code for javax.naming.directory.SearchControls.getDerefLinkFlag() definition code for javax.naming.directory.SearchControls.getDerefLinkFlag()

public boolean getDerefLinkFlag()
Determines whether links will be dereferenced during the search.

Returns:
true if links will be dereferenced; false otherwise.
See Also:
setDerefLinkFlag(boolean) sample code for javax.naming.directory.SearchControls.setDerefLinkFlag(boolean) definition code for javax.naming.directory.SearchControls.setDerefLinkFlag(boolean)

getReturningObjFlag sample code for javax.naming.directory.SearchControls.getReturningObjFlag() definition code for javax.naming.directory.SearchControls.getReturningObjFlag()

public boolean getReturningObjFlag()
Determines whether objects will be returned as part of the result.

Returns:
true if objects will be returned; false otherwise.
See Also:
setReturningObjFlag(boolean) sample code for javax.naming.directory.SearchControls.setReturningObjFlag(boolean) definition code for javax.naming.directory.SearchControls.setReturningObjFlag(boolean)

getCountLimit sample code for javax.naming.directory.SearchControls.getCountLimit() definition code for javax.naming.directory.SearchControls.getCountLimit()

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:
The maximum number of entries that will be returned.
See Also:
setCountLimit(long) sample code for javax.naming.directory.SearchControls.setCountLimit(long) definition code for javax.naming.directory.SearchControls.setCountLimit(long)

getReturningAttributes sample code for javax.naming.directory.SearchControls.getReturningAttributes() definition code for javax.naming.directory.SearchControls.getReturningAttributes()

public String sample code for java.lang.String definition code for java.lang.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:
An array of attribute ids identifying the attributes that will be returned. Can be null.
See Also:
setReturningAttributes(java.lang.String[]) sample code for javax.naming.directory.SearchControls.setReturningAttributes(java.lang.String[]) definition code for javax.naming.directory.SearchControls.setReturningAttributes(java.lang.String[])

setSearchScope sample code for javax.naming.directory.SearchControls.setSearchScope(int) definition code for javax.naming.directory.SearchControls.setSearchScope(int)

public void setSearchScope(int scope)
Sets the search scope to one of: OBJECT_SCOPE, ONELEVEL_SCOPE, SUBTREE_SCOPE.

Parameters:
scope - The search scope of this SearchControls.
See Also:
getSearchScope() sample code for javax.naming.directory.SearchControls.getSearchScope() definition code for javax.naming.directory.SearchControls.getSearchScope()

setTimeLimit sample code for javax.naming.directory.SearchControls.setTimeLimit(int) definition code for javax.naming.directory.SearchControls.setTimeLimit(int)

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 - The time limit of these SearchControls in milliseconds.
See Also:
getTimeLimit() sample code for javax.naming.directory.SearchControls.getTimeLimit() definition code for javax.naming.directory.SearchControls.getTimeLimit()

setDerefLinkFlag sample code for javax.naming.directory.SearchControls.setDerefLinkFlag(boolean) definition code for javax.naming.directory.SearchControls.setDerefLinkFlag(boolean)

public void setDerefLinkFlag(boolean on)
Enables/disables link dereferencing during the search.

Parameters:
on - if true links will be dereferenced; if false, not followed.
See Also:
getDerefLinkFlag() sample code for javax.naming.directory.SearchControls.getDerefLinkFlag() definition code for javax.naming.directory.SearchControls.getDerefLinkFlag()

setReturningObjFlag sample code for javax.naming.directory.SearchControls.setReturningObjFlag(boolean) definition code for javax.naming.directory.SearchControls.setReturningObjFlag(boolean)

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 - if true, objects will be returned; if false, objects will not be returned.
See Also:
getReturningObjFlag() sample code for javax.naming.directory.SearchControls.getReturningObjFlag() definition code for javax.naming.directory.SearchControls.getReturningObjFlag()

setCountLimit sample code for javax.naming.directory.SearchControls.setCountLimit(long) definition code for javax.naming.directory.SearchControls.setCountLimit(long)

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 - The maximum number of entries that will be returned.
See Also:
getCountLimit() sample code for javax.naming.directory.SearchControls.getCountLimit() definition code for javax.naming.directory.SearchControls.getCountLimit()

setReturningAttributes sample code for javax.naming.directory.SearchControls.setReturningAttributes(java.lang.String[]) definition code for javax.naming.directory.SearchControls.setReturningAttributes(java.lang.String[])

public void setReturningAttributes(String sample code for java.lang.String definition code for java.lang.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 - An array of attribute ids identifying the attributes that will be returned. Can be null.
See Also:
getReturningAttributes() sample code for javax.naming.directory.SearchControls.getReturningAttributes() definition code for javax.naming.directory.SearchControls.getReturningAttributes()