You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by tr...@apache.org on 2005/04/23 05:10:07 UTC

svn commit: r164321 - /directory/network/trunk/src/java/org/apache/mina/common/ByteBuffer.java

Author: trustin
Date: Fri Apr 22 20:10:06 2005
New Revision: 164321

URL: http://svn.apache.org/viewcvs?rev=164321&view=rev
Log:
* Fixed: DIRMINA-17
* Added: A note that users should know when they wrap their NIO buffers and byte arrays.

Modified:
    directory/network/trunk/src/java/org/apache/mina/common/ByteBuffer.java

Modified: directory/network/trunk/src/java/org/apache/mina/common/ByteBuffer.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/ByteBuffer.java?rev=164321&r1=164320&r2=164321&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/ByteBuffer.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/common/ByteBuffer.java Fri Apr 22 20:10:06 2005
@@ -219,12 +219,34 @@
     
     /**
      * Wraps the specified NIO {@link java.nio.ByteBuffer} into MINA buffer.
+     * Please note that MINA buffers are going to be pooled, and
+     * therefore there can be waste of memory if you specified
+     * a sliced buffer.
      */
     public static ByteBuffer wrap( java.nio.ByteBuffer nioBuffer )
     {
         DefaultByteBuffer buf = new DefaultByteBuffer();
         buf.init( nioBuffer );
         return buf;
+    }
+    
+    /**
+     * Wraps the specified byte array into MINA heap buffer.
+     */
+    public static ByteBuffer wrap( byte[] byteArray )
+    {
+        return wrap( java.nio.ByteBuffer.wrap( byteArray ) );
+    }
+    
+    /**
+     * Wraps the specified byte array into MINA heap buffer.
+     * Please note that MINA buffers are going to be pooled, and
+     * therefore there can be waste of memory if you wrap
+     * your byte array specifying <tt>offset</tt> and <tt>length</tt>.
+     */
+    public static ByteBuffer wrap( byte[] byteArray, int offset, int length )
+    {
+        return wrap( java.nio.ByteBuffer.wrap( byteArray, offset, length ) );
     }
     
     private static int getBufferStackIndex( Stack[] bufferStacks, int size )