mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Matthew Swift
19.17.2014 c2746d58a6973b698de71f513037523f2a3c16c7
OPENDJ-1602 (CR-5566) New pluggable storage based backend

Add ByteString.valueOf(byte[], int, int).
1 files modified
26 ■■■■■ changed files
opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/ByteString.java 26 ●●●●● patch | view | raw | blame | history
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.
     *