public final class VirtualListViewResponseControl extends Object implements Control
If the result code included with this control indicates that the virtual list view request succeeded then the content count and target position give sufficient information for the client to update a list box slider position to match the newly retrieved entries and identify the target entry.
The content count and context ID should be used in a subsequent virtual list view requests.
The following example demonstrates use of the virtual list view controls.
ByteString contextID = ByteString.empty(); // Add a window of 2 entries on either side of the first sn=Jensen entry. SearchRequest request = Requests.newSearchRequest("ou=People,dc=example,dc=com", SearchScope.WHOLE_SUBTREE, "(sn=*)", "sn", "givenName") .addControl(ServerSideSortRequestControl.newControl(true, new SortKey("sn"))) .addControl(VirtualListViewRequestControl.newAssertionControl( true, ByteString.valueOf("Jensen"), 2, 2, contextID)); SearchResultHandler resultHandler = new MySearchResultHandler(); Result result = connection.search(request, resultHandler); ServerSideSortResponseControl sssControl = result.getControl(ServerSideSortResponseControl.DECODER, new DecodeOptions()); if (sssControl != null && sssControl.getResult() == ResultCode.SUCCESS) { // Entries are sorted. } else { // Entries not necessarily sorted } VirtualListViewResponseControl vlvControl = result.getControl(VirtualListViewResponseControl.DECODER, new DecodeOptions()); // Position in list: vlvControl.getTargetPosition()/vlvControl.getContentCount()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<VirtualListViewResponseControl> |
DECODER
A decoder which can be used for decoding the virtual list view response control.
|
static String |
OID
The OID for the virtual list view request control.
|
Modifier and Type | Method and Description |
---|---|
int |
getContentCount()
Returns the estimated total number of entries in the result set.
|
ByteString |
getContextId()
Returns a server-defined octet string which, if present, should be sent
back to the server by the client in a subsequent virtual list request.
|
String |
getOid()
Returns the numeric OID associated with this control.
|
ResultCode |
getResult()
Returns result code indicating the outcome of the virtual list view
request.
|
int |
getTargetPosition()
Returns the position of the target entry in the result set.
|
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 VirtualListViewResponseControl |
newControl(int targetPosition,
int contentCount,
ResultCode result,
ByteString contextId)
Creates a new virtual list view response control.
|
String |
toString() |
public static final String OID
public static final ControlDecoder<VirtualListViewResponseControl> DECODER
public static VirtualListViewResponseControl newControl(int targetPosition, int contentCount, ResultCode result, ByteString contextId)
targetPosition
- The position of the target entry in the result set.contentCount
- An estimate of the total number of entries in the result set.result
- The result code indicating the outcome of the virtual list
view request.contextId
- A server-defined octet string. If present, the contextId
should be sent back to the server by the client in a
subsequent virtual list request.IllegalArgumentException
- If targetPosition
or contentCount
were less
than 0
.NullPointerException
- If result
was null
.public int getContentCount()
public ByteString getContextId()
null
if there is no context ID.public String getOid()
Control
public ResultCode getResult()
public int getTargetPosition()
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.