From c2746d58a6973b698de71f513037523f2a3c16c7 Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Fri, 19 Dec 2014 13:17:50 +0000
Subject: [PATCH] OPENDJ-1602 (CR-5566) New pluggable storage based backend

---
 opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/ByteString.java |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/ByteString.java b/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/ByteString.java
index 0c5ac3a..160b392 100755
--- a/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/ByteString.java
+++ b/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/ByteString.java
@@ -215,6 +215,32 @@
     }
 
     /**
+     * Returns a byte string containing a subsequence of the contents of the
+     * provided byte array.
+     * <p>
+     * This method differs from {@link #wrap(byte[], int, int)} in that it
+     * defensively copies the provided byte array.
+     *
+     * @param bytes
+     *            The byte array to use.
+     * @param offset
+     *            The offset of the byte array to be used; must be non-negative
+     *            and no larger than {@code bytes.length} .
+     * @param length
+     *            The length of the byte array to be used; must be non-negative
+     *            and no larger than {@code bytes.length - offset}.
+     * @return A byte string containing a copy of the subsequence of the
+     *         provided byte array.
+     */
+    public static ByteString valueOf(final byte[] bytes, final int offset, final int length) {
+        checkArrayBounds(bytes, offset, length);
+        if (offset == length) {
+            return EMPTY;
+        }
+        return wrap(Arrays.copyOfRange(bytes, offset, offset + length));
+    }
+
+    /**
      * Returns a byte string containing the UTF-8 encoded bytes of the provided
      * char array.
      *

--
Gitblit v1.10.0