com.unboundid.ldap.sdk.controls
Class VirtualListViewRequestControl

java.lang.Object
  extended by com.unboundid.ldap.sdk.Control
      extended by 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 the SimplePagedResultsControl, 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:

When the start of the result set is to be specified using a search string, then the virtual list view request control should include the following elements: Note that the virtual list view request control may only be included in a search request if that search request also includes the 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 a VirtualListViewResponseControl 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
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
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(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(Control control)
          Creates a new virtual list view request control which is decoded from the provided generic control.
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(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
 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, toString, writeTo
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

VIRTUAL_LIST_VIEW_REQUEST_OID

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,
                                     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 be null. For subsequent searches in the VLV sequence, it should be the (possibly null context ID included in the response control from the previous search.

VirtualListViewRequestControl

public 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. 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 be null.
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 be null. For subsequent searches in the VLV sequence, it should be the (possibly null context ID included in the response control from the previous search.

VirtualListViewRequestControl

public 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. 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 be null.
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 be null. For subsequent searches in the VLV sequence, it should be the (possibly null context ID included in the response control from the previous search.

VirtualListViewRequestControl

public 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. 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 be null.
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 be null. For subsequent searches in the VLV sequence, it should be the (possibly null context ID included in the response control from the previous search.

VirtualListViewRequestControl

public 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.

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 be null. For subsequent searches in the VLV sequence, it should be the (possibly null context ID included in the response control from the previous search.
isCritical - Indicates whether this control should be marked critical.

VirtualListViewRequestControl

public 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. 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 be null.
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 be null. For subsequent searches in the VLV sequence, it should be the (possibly null context ID included in the response control from the previous search.
isCritical - Indicates whether this control should be marked critical.

VirtualListViewRequestControl

public 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. 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 be null.
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 be null. For subsequent searches in the VLV sequence, it should be the (possibly null context ID included in the response control from the previous search.
isCritical - Indicates whether this control should be marked critical.

VirtualListViewRequestControl

public 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. 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 be null.
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 be null. For subsequent searches in the VLV sequence, it should be the (possibly null context ID included in the response control from the previous search.
isCritical - Indicates whether this control should be marked critical.

VirtualListViewRequestControl

public VirtualListViewRequestControl(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

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

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

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

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

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 class Control
Returns:
The user-friendly name for this control, or the OID if no user-friendly name is available.

toString

public void toString(java.lang.StringBuilder buffer)
Appends a string representation of this LDAP control to the provided buffer.

Overrides:
toString in class Control
Parameters:
buffer - The buffer to which to append the string representation of this buffer.