From 30f5175327333dcfaaeafb02560697bcdce6166d Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Mon, 30 Apr 2007 16:24:15 +0000
Subject: [PATCH] Implement support for the virtual list view (VLV) control as defined in draft-ietf-ldapext-ldapv3-vlv.  This can be used to retrieve a specified page of a search result set.  Any result set that can be used with server-side sorting can also be used with VLV.  The ldapsearch tool has also been updated to support this control.

---
 opends/src/server/org/opends/server/backends/jeb/SortValues.java |   35 +++++++++++++++++++++++++++++++++--
 1 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/opends/src/server/org/opends/server/backends/jeb/SortValues.java b/opends/src/server/org/opends/server/backends/jeb/SortValues.java
index 2ee7f8d..1d26ff8 100644
--- a/opends/src/server/org/opends/server/backends/jeb/SortValues.java
+++ b/opends/src/server/org/opends/server/backends/jeb/SortValues.java
@@ -165,6 +165,28 @@
 
 
   /**
+   * Compares the first element in this set of sort values with the provided
+   * assertion value to determine whether the assertion value is greater than or
+   * equal to the initial sort value.  This is used during VLV processing to
+   * find the offset by assertion value.
+   *
+   * @param  assertionValue  The assertion value to compare against the first
+   *                         sort value.
+   *
+   * @return  A negative value if the provided assertion value should come
+   *          before the first sort value, zero if the provided assertion value
+   *          is equal to the first sort value, or a positive value if the
+   *          provided assertion value should come after the first sort value.
+   */
+  public int compareTo(AttributeValue assertionValue)
+  {
+    SortKey sortKey = sortOrder.getSortKeys()[0];
+    return sortKey.compareValues(values[0], assertionValue);
+  }
+
+
+
+  /**
    * Retrieves a string representation of this sort values object.
    *
    * @return  A string representation of this sort values object.
@@ -193,7 +215,7 @@
     {
       if (i > 0)
       {
-        buffer.append(", ");
+        buffer.append(",");
       }
 
       if (sortKeys[i].ascending())
@@ -207,9 +229,18 @@
 
       buffer.append(sortKeys[i].getAttributeType().getNameOrOID());
       buffer.append("=");
-      buffer.append(values[i].getStringValue());
+      if (values[i] == null)
+      {
+        buffer.append("null");
+      }
+      else
+      {
+        buffer.append(values[i].getStringValue());
+      }
     }
 
+    buffer.append(", id=");
+    buffer.append(entryID.toString());
     buffer.append(")");
   }
 }

--
Gitblit v1.10.0