public final class SimplePagedResultsControl extends Object implements Control
This control is included in the searchRequest and searchResultDone messages and has the following structure:
realSearchControlValue ::= SEQUENCE { size INTEGER (0..maxInt), -- requested page size from client -- result set size estimate from server cookie OCTET STRING }
The following example demonstrates use of simple paged results to handle three entries at a time.
ByteString cookie = ByteString.empty(); SearchRequest request; SearchResultHandler resultHandler = new MySearchResultHandler(); Result result; int page = 1; do { System.out.println("# Simple paged results: Page " + page); request = Requests.newSearchRequest( "dc=example,dc=com", SearchScope.WHOLE_SUBTREE, "(sn=Jensen)", "cn") .addControl(SimplePagedResultsControl.newControl(true, 3, cookie)); result = connection.search(request, resultHandler); try { SimplePagedResultsControl control = result.getControl( SimplePagedResultsControl.DECODER, new DecodeOptions()); cookie = control.getCookie(); } catch (final DecodeException e) { // Failed to decode the response control. } ++page; } while (cookie.length() != 0);The search result handler in this case displays pages of results as LDIF on standard out.
private static class MySearchResultHandler implements SearchResultHandler { @Override public void handleExceptionResult(LdapException error) { // Ignore. } @Override public void handleResult(Result result) { // Ignore. } @Override public boolean handleEntry(SearchResultEntry entry) { final LDIFEntryWriter writer = new LDIFEntryWriter(System.out); try { writer.writeEntry(entry); writer.flush(); } catch (final IOException e) { // The writer could not write to System.out. } return true; } @Override public boolean handleReference(SearchResultReference reference) { System.out.println("Got a reference: " + reference.toString()); return false; } }
Modifier and Type | Field and Description |
---|---|
static ControlDecoder<SimplePagedResultsControl> |
DECODER
A decoder which can be used for decoding the simple paged results control.
|
static String |
OID
The OID for the paged results request/response control defined in RFC 2696.
|
Modifier and Type | Method and Description |
---|---|
ByteString |
getCookie()
Returns the opaque cookie which is used by the server to track its
position in the set of search results.
|
String |
getOid()
Returns the numeric OID associated with this control.
|
int |
getSize()
Returns the requested page size when used in a request control from the
client, or an estimate of the result set size when used in a response
control from the server (may be 0, indicating that the server does not
know).
|
ByteString |
getValue()
Returns the value, if any, associated with this control.
|
boolean |
hasValue()
Returns
true if this control has a value. |
boolean |
isCritical()
Returns
true if it is unacceptable to perform the operation
without applying the semantics of this control. |
static SimplePagedResultsControl |
newControl(boolean isCritical,
int size,
ByteString cookie)
Creates a new simple paged results control with the provided criticality,
size, and cookie.
|
String |
toString() |
public static final String OID
public static final ControlDecoder<SimplePagedResultsControl> DECODER
public static SimplePagedResultsControl newControl(boolean isCritical, int size, ByteString cookie)
isCritical
- true
if it is unacceptable to perform the operation
without applying the semantics of this control, or
false
if it can be ignored.size
- The requested page size when used in a request control from
the client, or an estimate of the result set size when used in
a response control from the server (may be 0, indicating that
the server does not know).cookie
- An opaque cookie which is used by the server to track its
position in the set of search results. The cookie must be
empty in the initial search request sent by the client. For
subsequent search requests the client must include the cookie
returned with the previous search result, until the server
returns an empty cookie indicating that the final page of
results has been returned.NullPointerException
- If cookie
was null
.public ByteString getCookie()
public String getOid()
Control
public int getSize()
public ByteString getValue()
Control
public boolean hasValue()
Control
true
if this control has a value. In some circumstances
it may be useful to determine if a control has a value, without actually
calculating the value and incurring any performance costs.public boolean isCritical()
Control
true
if it is unacceptable to perform the operation
without applying the semantics of this control.
The criticality field only has meaning in controls attached to request
messages (except UnbindRequest). For controls attached to response
messages and the UnbindRequest, the criticality field SHOULD be
false
, and MUST be ignored by the receiving protocol peer. A
value of true
indicates that it is unacceptable to perform the
operation without applying the semantics of the control.
isCritical
in interface Control
true
if this control must be processed by the Directory
Server, or false
if it can be ignored.Copyright 2010-2022 ForgeRock AS.