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-trueif only attribute descriptions (and not values) are to be returned, orfalse(the default) if both attribute descriptions and values are to be returned.attributes- theListcontaining 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 returnedListmay 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- theListcontaining 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 aRequestVisitorto 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 theattributesrecord component.controls()Returns the value of thecontrolsrecord component.Returns the value of thedereferenceAliasesPolicyrecord component.final booleanIndicates whether some other object is "equal to" this one.filter()Returns the value of thefilterrecord component.getType()Returns the type of this request to avoid expensiveinstanceofchecks.final inthashCode()Returns a hash code value for this object.name()Returns the value of thenamerecord component.scope()Returns the value of thescoperecord component.intReturns the value of thesizeLimitrecord component.intReturns the value of thetimeLimitrecord component.toString()Returns a string representation of this record class.booleanReturns the value of thetypesOnlyrecord component.withFilter(Filter filter) Create a newSearchRequestfrom existing one with new filter that defines the conditions that must be fulfilled in order for an entry to be returned.Create a newSearchRequestfrom existing one with new distinguished name.withNameAndScope(Dn name, SearchScope scope) Create a newSearchRequestfrom existing one with new distinguished name and the scope of the search.withSizeLimit(int sizeLimit) Create a newSearchRequestfrom existing one with new maximum number of entries to be returned by the search.withTypesOnly(boolean typesOnly) Create a newSearchRequestfrom existing one with new typesOnly flag.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods 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- iftimeLimitorsizeLimitwas negative.
-
-
Method Details
-
accept
Description copied from interface:RequestApplies aRequestVisitorto thisRequest.- Specified by:
acceptin 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, orNeverThrowsExceptionif 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- IfattributeDescriptionswasnull.
-
getType
Description copied from interface:RequestReturns the type of this request to avoid expensiveinstanceofchecks. -
withName
Create a newSearchRequestfrom 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 newSearchRequestfrom 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 newSearchRequestfrom 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 newSearchRequestfrom 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 newSearchRequestfrom existing one with new typesOnly flag.- Parameters:
typesOnly-trueif 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 thenamerecord component.- Returns:
- the value of the
namerecord component
-
scope
Returns the value of thescoperecord component.- Returns:
- the value of the
scoperecord component
-
dereferenceAliasesPolicy
Returns the value of thedereferenceAliasesPolicyrecord component.- Returns:
- the value of the
dereferenceAliasesPolicyrecord component
-
sizeLimit
public int sizeLimit()Returns the value of thesizeLimitrecord component.- Returns:
- the value of the
sizeLimitrecord component
-
timeLimit
public int timeLimit()Returns the value of thetimeLimitrecord component.- Returns:
- the value of the
timeLimitrecord component
-
typesOnly
public boolean typesOnly()Returns the value of thetypesOnlyrecord component.- Returns:
- the value of the
typesOnlyrecord component
-
filter
Returns the value of thefilterrecord component.- Returns:
- the value of the
filterrecord component
-
attributes
Returns the value of theattributesrecord component.- Returns:
- the value of the
attributesrecord component
-
controls
Returns the value of thecontrolsrecord component.- Specified by:
controlsin interfaceProtocolOp- Returns:
- the value of the
controlsrecord component
-