directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r161427 - directory/network/trunk/src/java/org/apache/mina/common/ByteBuffer.java
Date Fri, 15 Apr 2005 09:55:39 GMT
Author: trustin
Date: Fri Apr 15 02:55:38 2005
New Revision: 161427

URL: http://svn.apache.org/viewcvs?view=rev&rev=161427
Log:
Added ByteBuffer.wrap()

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?view=diff&r1=161426&r2=161427
==============================================================================
--- 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 15 02:55:38
2005
@@ -114,6 +114,14 @@
         return buf;
     }
     
+    /**
+     * Wraps the specified NIO {@link java.nio.ByteBuffer} into MINA buffer.
+     */
+    public static ByteBuffer wrap( java.nio.ByteBuffer nioBuffer )
+    {
+        return new ByteBuffer( nioBuffer );
+    }
+    
     private static int getBufferStackIndex( Stack[] bufferStacks, int size )
     {
         int targetSize = 16;
@@ -135,6 +143,15 @@
     private final java.nio.ByteBuffer buf;
 
     private int refCount = 1;
+    
+    private ByteBuffer( java.nio.ByteBuffer buf )
+    {
+        if( buf == null )
+        {
+            throw new NullPointerException( "buf" );
+        }
+        this.buf = buf;
+    }
 
     private ByteBuffer( int capacity, boolean direct )
     {



Mime
View raw message