directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r122706 - in incubator/directory/network/trunk/mina/src/java/org/apache/mina/io: . socket
Date Sat, 18 Dec 2004 04:33:52 GMT
Author: trustin
Date: Fri Dec 17 20:33:50 2004
New Revision: 122706

URL: http://svn.apache.org/viewcvs?view=rev&rev=122706
Log:
 * Added ReadBuffer.getAsPossible(), too.
Modified:
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/ReadBuffer.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/WriteBuffer.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/TcpReadBuffer.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/TcpWriteBuffer.java

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/ReadBuffer.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/ReadBuffer.java?view=diff&rev=122706&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/ReadBuffer.java&r1=122705&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/ReadBuffer.java&r2=122706
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/ReadBuffer.java	(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/ReadBuffer.java	Fri
Dec 17 20:33:50 2004
@@ -53,6 +53,14 @@
 
     ReadBuffer get( byte[] dst, int offset, int length );
 
+    ReadBuffer get( ByteBuffer buf );
+
+    ReadBuffer get( WriteBuffer buf );
+
+    int getAsPossible( ByteBuffer buf );
+
+    int getAsPossible( WriteBuffer buf );
+
     byte get();
 
     char getChar();

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/WriteBuffer.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/WriteBuffer.java?view=diff&rev=122706&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/WriteBuffer.java&r1=122705&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/WriteBuffer.java&r2=122706
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/WriteBuffer.java	(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/WriteBuffer.java	Fri
Dec 17 20:33:50 2004
@@ -52,10 +52,10 @@
     WriteBuffer put( ByteBuffer buf );
 
     WriteBuffer put( ReadBuffer buf );
-    
-    int putAsPossible(ByteBuffer buf);
-    
-    int putAsPossible(ReadBuffer buf);
+
+    int putAsPossible( ByteBuffer buf );
+
+    int putAsPossible( ReadBuffer buf );
 
     WriteBuffer put( byte b );
 
@@ -94,4 +94,4 @@
     WriteBuffer flush();
 
     WriteBuffer putMarker( Object marker );
-}
\ No newline at end of file
+}

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/TcpReadBuffer.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/TcpReadBuffer.java?view=diff&rev=122706&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/TcpReadBuffer.java&r1=122705&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/TcpReadBuffer.java&r2=122706
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/TcpReadBuffer.java
(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/TcpReadBuffer.java
Fri Dec 17 20:33:50 2004
@@ -22,6 +22,7 @@
 import java.nio.ByteOrder;
 
 import org.apache.mina.io.ReadBuffer;
+import org.apache.mina.io.WriteBuffer;
 
 /**
  * TODO Document me.
@@ -63,6 +64,36 @@
     {
         buf.get( dst, offset, length );
         return this;
+    }
+
+    public ReadBuffer get( ByteBuffer buf )
+    {
+        buf.put( this.buf );
+        return this;
+    }
+
+    public ReadBuffer get( WriteBuffer buf )
+    {
+        buf.put( this.buf );
+        return this;
+    }
+
+    public int getAsPossible( ByteBuffer buf )
+    {
+        int length = Math.min( buf.remaining(), this.buf.remaining() );
+        if( length > 0 )
+        {
+            int oldLimit = buf.limit();
+            buf.limit( buf.position() + length );
+            buf.put( this.buf );
+            buf.limit( oldLimit );
+        }
+        return length;
+    }
+
+    public int getAsPossible( WriteBuffer buf )
+    {
+        return buf.putAsPossible( this );
     }
 
     public byte get()

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/TcpWriteBuffer.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/TcpWriteBuffer.java?view=diff&rev=122706&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/TcpWriteBuffer.java&r1=122705&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/TcpWriteBuffer.java&r2=122706
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/TcpWriteBuffer.java
(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/TcpWriteBuffer.java
Fri Dec 17 20:33:50 2004
@@ -38,7 +38,7 @@
     private final ByteBuffer buf;
 
     private final Queue markers = new Queue( 16 );
-    
+
     private int baseIndex;
 
     TcpWriteBuffer( TcpSession session, ByteBuffer buf )
@@ -81,21 +81,24 @@
         this.buf.put( buf );
         return this;
     }
-    
-    public int putAsPossible( ReadBuffer buf ) {
+
+    public int putAsPossible( ReadBuffer buf )
+    {
         checkBufferCompatibility( buf );
         return this.putAsPossible( ( ( TcpReadBuffer ) buf ).buf() );
     }
-    
-    public int putAsPossible( ByteBuffer buf ) {
-        int length = this.buf.remaining() < buf.remaining()? this.buf.remaining() : buf.remaining();
-        if (length > 0) {
+
+    public int putAsPossible( ByteBuffer buf )
+    {
+        int length = Math.min( buf.remaining(), this.buf.remaining() );
+        if( length > 0 )
+        {
             int oldLimit = buf.limit();
-            buf.limit(buf.position() + length);
-            this.buf.put(buf);
-            buf.limit(oldLimit);
+            buf.limit( buf.position() + length );
+            this.buf.put( buf );
+            buf.limit( oldLimit );
         }
-        
+
         return length;
     }
 

Mime
View raw message