Class VirtualListViewResponseControl
- All Implemented Interfaces:
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) {
var 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;
}
}
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ControlDecoder<VirtualListViewResponseControl>A decoder which can be used for decoding theVirtualListViewResponseControl.static final StringThe OID for the virtual list view response control. -
Method Summary
Modifier and TypeMethodDescriptiongetAlias()Returns the control "friendly name" alias for the control.intReturns the estimated total number of entries in the result set.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.getOid()Returns the numeric OID associated with this control.Returns result code indicating the outcome of the virtual list view request.intReturns the position of the target entry in the result set.getValue()Returns the value, if any, associated with this control.booleanhasValue()Returnstrueif this control has a value.booleanReturnstrueif it is unacceptable to perform the operation without applying the semantics of this control.newControl(int targetPosition, int contentCount, ResultCode result, ByteString contextId) Creates a new virtual list view response control.toString()
-
Field Details
-
OID
The OID for the virtual list view response control.- See Also:
-
DECODER
A decoder which can be used for decoding theVirtualListViewResponseControl.
-
-
Method Details
-
newControl
public static VirtualListViewResponseControl newControl(int targetPosition, int contentCount, ResultCode result, ByteString contextId) Creates a new virtual list view response control.- Parameters:
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.- Returns:
- The new control.
- Throws:
IllegalArgumentException- IftargetPositionorcontentCountwere less than0.NullPointerException- Ifresultwasnull.
-
getContentCount
public int getContentCount()Returns the estimated total number of entries in the result set.- Returns:
- The estimated total number of entries in the result set.
-
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.- 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, or
nullif there is no context ID.
-
getOid
Description copied from interface:ControlReturns the numeric OID associated with this control. -
getResult
Returns result code indicating the outcome of the virtual list view request.- Returns:
- The result code indicating the outcome of the virtual list view request.
-
getTargetPosition
public int getTargetPosition()Returns the position of the target entry in the result set.- Returns:
- The position of the target entry in the result set.
-
getValue
Description copied from interface:ControlReturns the value, if any, associated with this control. Its format is defined by the specification of this control. -
hasValue
public boolean hasValue()Description copied from interface:ControlReturnstrueif 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. -
isCritical
public boolean isCritical()Description copied from interface:ControlReturnstrueif 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 oftrueindicates that it is unacceptable to perform the operation without applying the semantics of the control.- Specified by:
isCriticalin interfaceControl- Returns:
trueif this control must be processed by the Directory Server, orfalseif it can be ignored.
-
toString
-
getAlias
Description copied from interface:ControlReturns the control "friendly name" alias for the control.
-