From c430f8b3da724d0a117eadd172b92179b9a0b5a9 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Fri, 21 Mar 2014 11:59:48 +0000
Subject: [PATCH] OPENDJ-1368 (CR-3232) Remove AttributeValue

---
 opendj3-server-dev/src/server/org/opends/server/backends/jeb/JebFormat.java |   31 ++++++++++++++++++++++---------
 1 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/opendj3-server-dev/src/server/org/opends/server/backends/jeb/JebFormat.java b/opendj3-server-dev/src/server/org/opends/server/backends/jeb/JebFormat.java
index 458df29..9813c65 100644
--- a/opendj3-server-dev/src/server/org/opends/server/backends/jeb/JebFormat.java
+++ b/opendj3-server-dev/src/server/org/opends/server/backends/jeb/JebFormat.java
@@ -66,8 +66,28 @@
    */
   public static long entryIDFromDatabase(byte[] bytes)
   {
+    return toLong(bytes, 0, 8);
+  }
+
+  /**
+   * Decode a long from a byte array, starting at start index and ending at end
+   * index.
+   *
+   * @param bytes
+   *          The bytes value of the long.
+   * @param start
+   *          the array index where to start computing the long
+   * @param end
+   *          the array index exclusive where to end computing the long
+   * @return the long representation of the read bytes.
+   * @throws ArrayIndexOutOfBoundsException
+   *           if the bytes array length is less than end.
+   */
+  public static long toLong(byte[] bytes, int start, int end)
+      throws ArrayIndexOutOfBoundsException
+  {
     long v = 0;
-    for (int i = 0; i < 8; i++)
+    for (int i = start; i < end; i++)
     {
       v <<= 8;
       v |= (bytes[i] & 0xFF);
@@ -90,14 +110,7 @@
 
     if(bytes.length == 8)
     {
-      long v = 0;
-      v |= (bytes[0] & 0x7F);
-      for (int i = 1; i < 8; i++)
-      {
-        v <<= 8;
-        v |= (bytes[i] & 0xFF);
-      }
-      return v;
+      return entryIDFromDatabase(bytes);
     }
     return Long.MAX_VALUE;
   }

--
Gitblit v1.10.0