Package com.unboundid.ldap.sdk.controls
Class VirtualListViewRequestControl
- java.lang.Object
-
- com.unboundid.ldap.sdk.Control
-
- com.unboundid.ldap.sdk.controls.VirtualListViewRequestControl
-
- All Implemented Interfaces:
java.io.Serializable
@NotMutable @ThreadSafety(level=COMPLETELY_THREADSAFE) public final class VirtualListViewRequestControl extends Control
This class provides an implementation of the LDAP virtual list view (VLV) request control as defined in draft-ietf-ldapext-ldapv3-vlv. This control may be used to retrieve arbitrary "pages" of entries from the complete set of search results. It is similar to theSimplePagedResultsControl
, with the exception that the simple paged results control requires scrolling through the results in sequential order, while the VLV control allows starting and resuming at any arbitrary point in the result set. The starting point may be specified using either a positional offset, or based on the first entry with a value that is greater than or equal to a specified value.
When the start of the result set is to be specified using an offset, then the virtual list view request control should include the following elements:targetOffset
-- The position in the result set of the entry to target for the next page of results to return. Note that the offset is one-based (so the first entry has offset 1, the second entry has offset 2, etc.).beforeCount
-- The number of entries before the entry specified as the target offset that should be retrieved.afterCount
-- The number of entries after the entry specified as the target offset that should be retrieved.contentCount
-- The estimated total number of entries that are in the total result set. This should be zero for the first request in a VLV search sequence, but should be the value returned by the server in the corresponding response control for subsequent searches as part of the VLV sequence.contextID
-- This is an optional cookie that may be used to help the server resume processing on a VLV search. It should be absent from the initial request, but for subsequent requests should be the value returned in the previous VLV response control.
assertionValue
-- The value that specifies the start of the page of results to retrieve. The target entry will be the first entry in which the value for the primary sort attribute is greater than or equal to this assertion value.beforeCount
-- The number of entries before the entry specified by the assertion value that should be retrieved.afterCount
-- The number of entries after the entry specified by the assertion value that should be retrieved.contentCount
-- The estimated total number of entries that are in the total result set. This should be zero for the first request in a VLV search sequence, but should be the value returned by the server in the corresponding response control for subsequent searches as part of the VLV sequence.contextID
-- This is an optional cookie that may be used to help the server resume processing on a VLV search. It should be absent from the initial request, but for subsequent requests should be the value returned in the previous VLV response control.
ServerSideSortRequestControl
. This is necessary to ensure that a consistent order is used for the resulting entries.
If the search is successful, then the search result done response may include aVirtualListViewResponseControl
to provide information about the state of the virtual list view processing.
Example
The following example demonstrates the use of the virtual list view request control to iterate through all users, retrieving up to 10 entries at a time:// Perform a search to retrieve all users in the server, but only retrieving // ten at a time. Ensure that the users are sorted in ascending order by // last name, then first name. int numSearches = 0; int totalEntriesReturned = 0; SearchRequest searchRequest = new SearchRequest("dc=example,dc=com", SearchScope.SUB, Filter.createEqualityFilter("objectClass", "person")); int vlvOffset = 1; int vlvContentCount = 0; ASN1OctetString vlvContextID = null; while (true) { // Note that the VLV control always requires the server-side sort // control. searchRequest.setControls( new ServerSideSortRequestControl(new SortKey("sn"), new SortKey("givenName")), new VirtualListViewRequestControl(vlvOffset, 0, 9, vlvContentCount, vlvContextID)); SearchResult searchResult = connection.search(searchRequest); numSearches++; totalEntriesReturned += searchResult.getEntryCount(); for (SearchResultEntry e : searchResult.getSearchEntries()) { // Do something with each entry... } LDAPTestUtils.assertHasControl(searchResult, VirtualListViewResponseControl.VIRTUAL_LIST_VIEW_RESPONSE_OID); VirtualListViewResponseControl vlvResponseControl = VirtualListViewResponseControl.get(searchResult); vlvContentCount = vlvResponseControl.getContentCount(); vlvOffset += 10; vlvContextID = vlvResponseControl.getContextID(); if (vlvOffset > vlvContentCount) { break; } }
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
VIRTUAL_LIST_VIEW_REQUEST_OID
The OID (2.16.840.1.113730.3.4.9) for the virtual list view request control.
-
Constructor Summary
Constructors Constructor Description VirtualListViewRequestControl(byte[] assertionValue, int beforeCount, int afterCount, ASN1OctetString contextID)
Creates a new virtual list view request control that will identify the beginning of the result set by an assertion value.VirtualListViewRequestControl(byte[] assertionValue, int beforeCount, int afterCount, ASN1OctetString contextID, boolean isCritical)
Creates a new virtual list view request control that will identify the beginning of the result set by an assertion value.VirtualListViewRequestControl(int targetOffset, int beforeCount, int afterCount, int contentCount, ASN1OctetString contextID)
Creates a new virtual list view request control that will identify the beginning of the result set by a target offset.VirtualListViewRequestControl(int targetOffset, int beforeCount, int afterCount, int contentCount, ASN1OctetString contextID, boolean isCritical)
Creates a new virtual list view request control that will identify the beginning of the result set by a target offset.VirtualListViewRequestControl(ASN1OctetString assertionValue, int beforeCount, int afterCount, ASN1OctetString contextID)
Creates a new virtual list view request control that will identify the beginning of the result set by an assertion value.VirtualListViewRequestControl(ASN1OctetString assertionValue, int beforeCount, int afterCount, ASN1OctetString contextID, boolean isCritical)
Creates a new virtual list view request control that will identify the beginning of the result set by an assertion value.VirtualListViewRequestControl(Control control)
Creates a new virtual list view request control which is decoded from the provided generic control.VirtualListViewRequestControl(java.lang.String assertionValue, int beforeCount, int afterCount, ASN1OctetString contextID)
Creates a new virtual list view request control that will identify the beginning of the result set by an assertion value.VirtualListViewRequestControl(java.lang.String assertionValue, int beforeCount, int afterCount, ASN1OctetString contextID, boolean isCritical)
Creates a new virtual list view request control that will identify the beginning of the result set by an assertion value.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getAfterCount()
Retrieves the number of entries that should be retrieved after the target entry.ASN1OctetString
getAssertionValue()
Retrieves the assertion value for this virtual list view request control, if applicable.byte[]
getAssertionValueBytes()
Retrieves the byte array representation of the assertion value for this virtual list view request control, if applicable.java.lang.String
getAssertionValueString()
Retrieves the string representation of the assertion value for this virtual list view request control, if applicable.int
getBeforeCount()
Retrieves the number of entries that should be retrieved before the target entry.int
getContentCount()
Retrieves the estimated number of entries in the result set, if applicable.ASN1OctetString
getContextID()
Retrieves the context ID for this virtual list view request control, if available.java.lang.String
getControlName()
Retrieves the user-friendly name for this control, if available.int
getTargetOffset()
Retrieves the target offset position for this virtual list view request control, if applicable.void
toString(java.lang.StringBuilder buffer)
Appends a string representation of this LDAP control to the provided buffer.-
Methods inherited from class com.unboundid.ldap.sdk.Control
decode, decode, decodeControls, deregisterDecodeableControl, encode, encodeControls, equals, getOID, getValue, hashCode, hasValue, isCritical, readFrom, registerDecodeableControl, registerDecodeableControl, toString, writeTo
-
-
-
-
Field Detail
-
VIRTUAL_LIST_VIEW_REQUEST_OID
@NotNull public static final java.lang.String VIRTUAL_LIST_VIEW_REQUEST_OID
The OID (2.16.840.1.113730.3.4.9) for the virtual list view request control.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
VirtualListViewRequestControl
public VirtualListViewRequestControl(int targetOffset, int beforeCount, int afterCount, int contentCount, @Nullable ASN1OctetString contextID)
Creates a new virtual list view request control that will identify the beginning of the result set by a target offset. It will be marked critical.- Parameters:
targetOffset
- The position of the entry that should be used as the start of the result set.beforeCount
- The maximum number of entries that should be returned before the entry with the specified target offset.afterCount
- The maximum number of entries that should be returned after the entry with the specified target offset.contentCount
- The estimated number of entries in the result set. For the first request in a series of searches with the VLV control, it should be zero. For subsequent searches in the VLV sequence, it should be the content count included in the response control from the previous search.contextID
- The context ID that may be used to help the server continue in the same result set for subsequent searches. For the first request in a series of searches with the VLV control, it should benull
. For subsequent searches in the VLV sequence, it should be the (possiblynull
) context ID included in the response control from the previous search.
-
VirtualListViewRequestControl
public VirtualListViewRequestControl(@NotNull java.lang.String assertionValue, int beforeCount, int afterCount, @Nullable ASN1OctetString contextID)
Creates a new virtual list view request control that will identify the beginning of the result set by an assertion value. It will be marked critical.- Parameters:
assertionValue
- The assertion value that will be used to identify the start of the result set. The target entry will be the first entry with a value for the primary sort attribute that is greater than or equal to this assertion value. It must not benull
.beforeCount
- The maximum number of entries that should be returned before the first entry with a value greater than or equal to the provided assertion value.afterCount
- The maximum number of entries that should be returned after the first entry with a value greater than or equal to the provided assertion value.contextID
- The context ID that may be used to help the server continue in the same result set for subsequent searches. For the first request in a series of searches with the VLV control, it should benull
. For subsequent searches in the VLV sequence, it should be the (possiblynull
) context ID included in the response control from the previous search.
-
VirtualListViewRequestControl
public VirtualListViewRequestControl(@NotNull byte[] assertionValue, int beforeCount, int afterCount, @Nullable ASN1OctetString contextID)
Creates a new virtual list view request control that will identify the beginning of the result set by an assertion value. It will be marked critical.- Parameters:
assertionValue
- The assertion value that will be used to identify the start of the result set. The target entry will be the first entry with a value for the primary sort attribute that is greater than or equal to this assertion value. It must not benull
.beforeCount
- The maximum number of entries that should be returned before the first entry with a value greater than or equal to the provided assertion value.afterCount
- The maximum number of entries that should be returned after the first entry with a value greater than or equal to the provided assertion value.contextID
- The context ID that may be used to help the server continue in the same result set for subsequent searches. For the first request in a series of searches with the VLV control, it should benull
. For subsequent searches in the VLV sequence, it should be the (possiblynull
) context ID included in the response control from the previous search.
-
VirtualListViewRequestControl
public VirtualListViewRequestControl(@NotNull ASN1OctetString assertionValue, int beforeCount, int afterCount, @Nullable ASN1OctetString contextID)
Creates a new virtual list view request control that will identify the beginning of the result set by an assertion value. It will be marked critical.- Parameters:
assertionValue
- The assertion value that will be used to identify the start of the result set. The target entry will be the first entry with a value for the primary sort attribute that is greater than or equal to this assertion value. It must not benull
.beforeCount
- The maximum number of entries that should be returned before the first entry with a value greater than or equal to the provided assertion value.afterCount
- The maximum number of entries that should be returned after the first entry with a value greater than or equal to the provided assertion value.contextID
- The context ID that may be used to help the server continue in the same result set for subsequent searches. For the first request in a series of searches with the VLV control, it should benull
. For subsequent searches in the VLV sequence, it should be the (possiblynull
) context ID included in the response control from the previous search.
-
VirtualListViewRequestControl
public VirtualListViewRequestControl(int targetOffset, int beforeCount, int afterCount, int contentCount, @Nullable ASN1OctetString contextID, boolean isCritical)
Creates a new virtual list view request control that will identify the beginning of the result set by a target offset.- Parameters:
targetOffset
- The position of the entry that should be used as the start of the result set.beforeCount
- The maximum number of entries that should be returned before the entry with the specified target offset.afterCount
- The maximum number of entries that should be returned after the entry with the specified target offset.contentCount
- The estimated number of entries in the result set. For the first request in a series of searches with the VLV control, it should be zero. For subsequent searches in the VLV sequence, it should be the content count included in the response control from the previous search.contextID
- The context ID that may be used to help the server continue in the same result set for subsequent searches. For the first request in a series of searches with the VLV control, it should benull
. For subsequent searches in the VLV sequence, it should be the (possiblynull
) context ID included in the response control from the previous search.isCritical
- Indicates whether this control should be marked critical.
-
VirtualListViewRequestControl
public VirtualListViewRequestControl(@NotNull java.lang.String assertionValue, int beforeCount, int afterCount, @Nullable ASN1OctetString contextID, boolean isCritical)
Creates a new virtual list view request control that will identify the beginning of the result set by an assertion value. It will be marked critical.- Parameters:
assertionValue
- The assertion value that will be used to identify the start of the result set. The target entry will be the first entry with a value for the primary sort attribute that is greater than or equal to this assertion value. It must not benull
.beforeCount
- The maximum number of entries that should be returned before the first entry with a value greater than or equal to the provided assertion value.afterCount
- The maximum number of entries that should be returned after the first entry with a value greater than or equal to the provided assertion value.contextID
- The context ID that may be used to help the server continue in the same result set for subsequent searches. For the first request in a series of searches with the VLV control, it should benull
. For subsequent searches in the VLV sequence, it should be the (possiblynull
) context ID included in the response control from the previous search.isCritical
- Indicates whether this control should be marked critical.
-
VirtualListViewRequestControl
public VirtualListViewRequestControl(@NotNull byte[] assertionValue, int beforeCount, int afterCount, @Nullable ASN1OctetString contextID, boolean isCritical)
Creates a new virtual list view request control that will identify the beginning of the result set by an assertion value. It will be marked critical.- Parameters:
assertionValue
- The assertion value that will be used to identify the start of the result set. The target entry will be the first entry with a value for the primary sort attribute that is greater than or equal to this assertion value. It must not benull
.beforeCount
- The maximum number of entries that should be returned before the first entry with a value greater than or equal to the provided assertion value.afterCount
- The maximum number of entries that should be returned after the first entry with a value greater than or equal to the provided assertion value.contextID
- The context ID that may be used to help the server continue in the same result set for subsequent searches. For the first request in a series of searches with the VLV control, it should benull
. For subsequent searches in the VLV sequence, it should be the (possiblynull
) context ID included in the response control from the previous search.isCritical
- Indicates whether this control should be marked critical.
-
VirtualListViewRequestControl
public VirtualListViewRequestControl(@NotNull ASN1OctetString assertionValue, int beforeCount, int afterCount, @Nullable ASN1OctetString contextID, boolean isCritical)
Creates a new virtual list view request control that will identify the beginning of the result set by an assertion value. It will be marked critical.- Parameters:
assertionValue
- The assertion value that will be used to identify the start of the result set. The target entry will be the first entry with a value for the primary sort attribute that is greater than or equal to this assertion value. It must not benull
.beforeCount
- The maximum number of entries that should be returned before the first entry with a value greater than or equal to the provided assertion value.afterCount
- The maximum number of entries that should be returned after the first entry with a value greater than or equal to the provided assertion value.contextID
- The context ID that may be used to help the server continue in the same result set for subsequent searches. For the first request in a series of searches with the VLV control, it should benull
. For subsequent searches in the VLV sequence, it should be the (possiblynull
) context ID included in the response control from the previous search.isCritical
- Indicates whether this control should be marked critical.
-
VirtualListViewRequestControl
public VirtualListViewRequestControl(@NotNull Control control) throws LDAPException
Creates a new virtual list view request control which is decoded from the provided generic control.- Parameters:
control
- The generic control to be decoded as a virtual list view request control.- Throws:
LDAPException
- If the provided control cannot be decoded as a virtual list view request control.
-
-
Method Detail
-
getTargetOffset
public int getTargetOffset()
Retrieves the target offset position for this virtual list view request control, if applicable.- Returns:
- The target offset position for this virtual list view request control, or -1 if the target is specified by an assertion value.
-
getAssertionValueString
@Nullable public java.lang.String getAssertionValueString()
Retrieves the string representation of the assertion value for this virtual list view request control, if applicable.- Returns:
- The string representation of the assertion value for this virtual
list view request control, or
null
if the target is specified by offset.
-
getAssertionValueBytes
@Nullable public byte[] getAssertionValueBytes()
Retrieves the byte array representation of the assertion value for this virtual list view request control, if applicable.- Returns:
- The byte array representation of the assertion value for this
virtual list view request control, or
null
if the target is specified by offset.
-
getAssertionValue
@Nullable public ASN1OctetString getAssertionValue()
Retrieves the assertion value for this virtual list view request control, if applicable.- Returns:
- The assertion value for this virtual list view request control, or
null
if the target is specified by offset.
-
getBeforeCount
public int getBeforeCount()
Retrieves the number of entries that should be retrieved before the target entry.- Returns:
- The number of entries that should be retrieved before the target entry.
-
getAfterCount
public int getAfterCount()
Retrieves the number of entries that should be retrieved after the target entry.- Returns:
- The number of entries that should be retrieved after the target entry.
-
getContentCount
public int getContentCount()
Retrieves the estimated number of entries in the result set, if applicable.- Returns:
- The estimated number of entries in the result set, zero if it is not known (for the first search in a sequence where the target is specified by offset), or -1 if the target is specified by an assertion value.
-
getContextID
@Nullable public ASN1OctetString getContextID()
Retrieves the context ID for this virtual list view request control, if available.- Returns:
- The context ID for this virtual list view request control, or
null
if there is none.
-
getControlName
@NotNull public java.lang.String getControlName()
Retrieves the user-friendly name for this control, if available. If no user-friendly name has been defined, then the OID will be returned.- Overrides:
getControlName
in classControl
- Returns:
- The user-friendly name for this control, or the OID if no user-friendly name is available.
-
-