directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r164321 - /directory/network/trunk/src/java/org/apache/mina/common/ByteBuffer.java
Date Sat, 23 Apr 2005 03:10:07 GMT
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 )



Mime
View raw message