Class VirtualListViewResponseControl
- java.lang.Object
-
- org.forgerock.opendj.ldap.controls.VirtualListViewResponseControl
-
- All Implemented Interfaces:
Control
public final class VirtualListViewResponseControl extends Object implements Control
The virtual list view response control as defined in draft-ietf-ldapext-ldapv3-vlv. This control is included with a search result in response to a virtual list view request included with a search request.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; } }
-
-
Field Summary
Fields Modifier and Type Field 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.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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()
Returnstrue
if this control has a value.boolean
isCritical()
Returnstrue
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()
-
-
-
Field Detail
-
OID
public static final String OID
The OID for the virtual list view request control.- See Also:
- Constant Field Values
-
DECODER
public static final ControlDecoder<VirtualListViewResponseControl> DECODER
A decoder which can be used for decoding the virtual list view response control.
-
-
Method Detail
-
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
- IftargetPosition
orcontentCount
were less than0
.NullPointerException
- Ifresult
wasnull
.
-
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
public 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.- 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
null
if there is no context ID.
-
getOid
public String getOid()
Description copied from interface:Control
Returns the numeric OID associated with this control.
-
getResult
public ResultCode 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
public ByteString getValue()
Description copied from interface:Control
Returns 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:Control
Returnstrue
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.
-
isCritical
public boolean isCritical()
Description copied from interface:Control
Returnstrue
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 oftrue
indicates that it is unacceptable to perform the operation without applying the semantics of the control.- Specified by:
isCritical
in interfaceControl
- Returns:
true
if this control must be processed by the Directory Server, orfalse
if it can be ignored.
-
-