From 15ad9b53748b474cf78d89fc9350d0c0ca10cb3b Mon Sep 17 00:00:00 2001
From: Nicolas Capponi <nicolas.capponi@forgerock.com>
Date: Thu, 09 Jan 2014 15:22:31 +0000
Subject: [PATCH] Add ByteStringBuilder#copyTo(WritableByteChannel) method  to align class with ByteStringBuilder class from server 2.x

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

diff --git a/opendj-core/src/main/java/org/forgerock/opendj/ldap/ByteStringBuilder.java b/opendj-core/src/main/java/org/forgerock/opendj/ldap/ByteStringBuilder.java
index c99f6a2..f49fad7 100755
--- a/opendj-core/src/main/java/org/forgerock/opendj/ldap/ByteStringBuilder.java
+++ b/opendj-core/src/main/java/org/forgerock/opendj/ldap/ByteStringBuilder.java
@@ -32,6 +32,7 @@
 import java.io.UnsupportedEncodingException;
 import java.nio.ByteBuffer;
 import java.nio.CharBuffer;
+import java.nio.channels.WritableByteChannel;
 import java.nio.charset.Charset;
 
 /**
@@ -824,6 +825,21 @@
     }
 
     /**
+     * Copies the entire contents of this byte string to the provided
+     * {@code WritableByteChannel}.
+     *
+     * @param channel
+     *            The {@code WritableByteChannel} to copy to.
+     * @return The number of bytes written, possibly zero
+     * @throws IOException
+     *             If some other I/O error occurs
+     * @see WritableByteChannel#write(java.nio.ByteBuffer)
+     */
+    public int copyTo(WritableByteChannel channel) throws IOException {
+        return channel.write(ByteBuffer.wrap(buffer, 0, length));
+    }
+
+    /**
      * Ensures that the specified number of additional bytes will fit in this
      * byte string builder and resizes it if necessary.
      *

--
Gitblit v1.10.0