Record Class SearchRequest
java.lang.Object
java.lang.Record
org.forgerock.opendj.ldap.messages.SearchRequest
- Record Components:
name
- the distinguished name of the base entry relative to which the search is to be performed.scope
- the scope of the search.filter
- the filter that defines the conditions that must be fulfilled in order for an entry to be returned.dereferenceAliasesPolicy
- an indication whether alias entries are to be.timeLimit
- the time limit that should be used in order to restrict the maximum time (in seconds) allowed for the search.A value of 0 (the default) in this field indicates that no client-requested time limit restrictions are in effect for the search. Servers may also enforce a maximum time limit for the search.
sizeLimit
- the maximum number of entries that will be returned by the search.A value of 0 (the default) indicates that no client-requested size limit restrictions are in effect. Servers may also enforce a maximum number of entries to return.
typesOnly
-true
if only attribute descriptions (and not values) are to be returned, orfalse
(the default) if both attribute descriptions and values are to be returned.attributes
- theList
containing the attributes requested by the client to be included with each entry that matches the search criteria. Attributes that are subtypes of listed attributes are implicitly included. The returnedList
may be modified if permitted by this search request. Attributes are aList<String>
rather aSet<AttributeDescription>
because:- The values are not even attribute descriptions.
*
and+
are allowed as well as@ObjectClass
. - While a
Set<String>
would avoid duplicates with the same alphabetical spelling, you could still end up with duplicates like "cn", or "CN", "commonName", "CoMmOnNaMe", numeric OIDs, etc. - A list aligns with the protocol representation. If we used a set then we would manipulate what was being sent over the network.
- The values are not even attribute descriptions.
controls
- theList
containing the controls.
- All Implemented Interfaces:
ProtocolOp
,Request
public record SearchRequest(Dn name, SearchScope scope, DereferenceAliasesPolicy dereferenceAliasesPolicy, int sizeLimit, int timeLimit, boolean typesOnly, Filter filter, List<String> attributes, List<Control> controls)
extends Record
implements Request
The Search operation is used to request a server to return, subject to access controls and other restrictions,
a set of entries matching a complex search criterion. This can be used to read attributes from a single entry, from
entries immediately subordinate to a particular entry, or from a whole subtree of entries.
Use Requests.newSearchRequest(Dn, SearchScope, Filter, String...)
or Requests.newSearchRequest(String, SearchScope, String, String...)
to create a new search request.
SearchRequest request = Requests.newSearchRequest("dc=example,dc=com", SearchScope.WHOLE_SUBTREE, "(sn=Jensen)", "cn");Alternatively, use the
Connection.search(String, SearchScope, String, String...)
to specify the arguments directly.
Connection connection = ...; ConnectionEntryReader reader = connection.search("dc=example,dc=com", SearchScope.BASE_ONLY, "(sn=Jensen)", "cn");
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.forgerock.opendj.ldap.messages.Request
Request.RequestType
-
Constructor Summary
ConstructorsConstructorDescriptionSearchRequest
(Dn name, SearchScope scope, DereferenceAliasesPolicy dereferenceAliasesPolicy, int sizeLimit, int timeLimit, boolean typesOnly, Filter filter, List<String> attributes, List<Control> controls) Creates a newSearchRequest
. -
Method Summary
Modifier and TypeMethodDescription<R,
P, E extends Exception>
Raccept
(RequestVisitor<R, P, E> v, P p) Applies aRequestVisitor
to thisRequest
.addAttribute
(String... attributeDescriptions) Adds the provided attribute name(s) to the list of attributes to be included with each entry that matches the search criteria.Returns the value of theattributes
record component.controls()
Returns the value of thecontrols
record component.Returns the value of thedereferenceAliasesPolicy
record component.final boolean
Indicates whether some other object is "equal to" this one.filter()
Returns the value of thefilter
record component.getType()
Returns the type of this request to avoid expensiveinstanceof
checks.final int
hashCode()
Returns a hash code value for this object.name()
Returns the value of thename
record component.scope()
Returns the value of thescope
record component.int
Returns the value of thesizeLimit
record component.int
Returns the value of thetimeLimit
record component.toString()
Returns a string representation of this record class.boolean
Returns the value of thetypesOnly
record component.withFilter
(Filter filter) Create a newSearchRequest
from existing one with new filter that defines the conditions that must be fulfilled in order for an entry to be returned.Create a newSearchRequest
from existing one with new distinguished name.withNameAndScope
(Dn name, SearchScope scope) Create a newSearchRequest
from existing one with new distinguished name and the scope of the search.withSizeLimit
(int sizeLimit) Create a newSearchRequest
from existing one with new maximum number of entries to be returned by the search.withTypesOnly
(boolean typesOnly) Create a newSearchRequest
from existing one with new typesOnly flag.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.forgerock.opendj.ldap.messages.ProtocolOp
addControl, addControls, containsControl, getControl, getControl, removeControls
-
Constructor Details
-
SearchRequest
public SearchRequest(Dn name, SearchScope scope, DereferenceAliasesPolicy dereferenceAliasesPolicy, int sizeLimit, int timeLimit, boolean typesOnly, Filter filter, List<String> attributes, List<Control> controls) Creates a newSearchRequest
.- Throws:
LocalizedIllegalArgumentException
- iftimeLimit
orsizeLimit
was negative.
-
-
Method Details
-
accept
Description copied from interface:Request
Applies aRequestVisitor
to thisRequest
.- Specified by:
accept
in interfaceRequest
- Type Parameters:
R
- The return type of the visitor's methods.P
- The type of the additional parameters to the visitor's methods.E
- The type of the exception thrown by the visitor method if it fails, orNeverThrowsException
if the visitor cannot fail.- Parameters:
v
- The request visitor.p
- Optional additional visitor parameter.- Returns:
- A result as specified by the visitor.
- Throws:
E
- If the visitor failed.
-
addAttribute
Adds the provided attribute name(s) to the list of attributes to be included with each entry that matches the search criteria. Attributes that are sub-types of listed attributes are implicitly included.- Parameters:
attributeDescriptions
- The name(s) of the attribute to be included with each entry.- Returns:
- This search request.
- Throws:
UnsupportedOperationException
- If this search request does not permit attribute names to be added.NullPointerException
- IfattributeDescriptions
wasnull
.
-
getType
Description copied from interface:Request
Returns the type of this request to avoid expensiveinstanceof
checks. -
withName
Create a newSearchRequest
from existing one with new distinguished name.- Parameters:
name
- the distinguished name of the base entry relative to which the search is to be performed.- Returns:
- New search request.
-
withNameAndScope
Create a newSearchRequest
from existing one with new distinguished name and the scope of the search.- Parameters:
name
- the distinguished name of the base entry relative to which the search is to be performed.scope
- the scope of the search.- Returns:
- New search request.
-
withFilter
Create a newSearchRequest
from existing one with new filter that defines the conditions that must be fulfilled in order for an entry to be returned.- Parameters:
filter
- the filter that defines the conditions that must be fulfilled in order for an entry to be returned.- Returns:
- New search request.
-
withSizeLimit
Create a newSearchRequest
from existing one with new maximum number of entries to be returned by the search.- Parameters:
sizeLimit
- the maximum number of entries that will be returned by the search. 0 means an unlimited number of entries will be returned.- Returns:
- New search request.
-
withTypesOnly
Create a newSearchRequest
from existing one with new typesOnly flag.- Parameters:
typesOnly
-true
if only attribute descriptions (and not values) are to be returned, orfalse
(the default) if both attribute descriptions and values are to be returned.- Returns:
- New search request.
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object)
; primitive components are compared with '=='. -
name
Returns the value of thename
record component.- Returns:
- the value of the
name
record component
-
scope
Returns the value of thescope
record component.- Returns:
- the value of the
scope
record component
-
dereferenceAliasesPolicy
Returns the value of thedereferenceAliasesPolicy
record component.- Returns:
- the value of the
dereferenceAliasesPolicy
record component
-
sizeLimit
public int sizeLimit()Returns the value of thesizeLimit
record component.- Returns:
- the value of the
sizeLimit
record component
-
timeLimit
public int timeLimit()Returns the value of thetimeLimit
record component.- Returns:
- the value of the
timeLimit
record component
-
typesOnly
public boolean typesOnly()Returns the value of thetypesOnly
record component.- Returns:
- the value of the
typesOnly
record component
-
filter
Returns the value of thefilter
record component.- Returns:
- the value of the
filter
record component
-
attributes
Returns the value of theattributes
record component.- Returns:
- the value of the
attributes
record component
-
controls
Returns the value of thecontrols
record component.- Specified by:
controls
in interfaceProtocolOp
- Returns:
- the value of the
controls
record component
-