net.sf.neem.impl
Class Buffers

java.lang.Object
  extended by net.sf.neem.impl.Buffers

public abstract class Buffers
extends java.lang.Object

Buffer manipulation utilities.


Method Summary
static java.nio.ByteBuffer[] clone(java.nio.ByteBuffer[] buffer)
          Clone a buffer array.
static java.nio.ByteBuffer compact(java.nio.ByteBuffer[] buffer)
          Compact a buffer array to a single buffer.
static int copy(java.nio.ByteBuffer res, java.nio.ByteBuffer[] buffer)
          Copy a buffer array to a single buffer.
static int count(java.nio.ByteBuffer[] buffer)
          Count remaining bytes in a buffer array.
static java.nio.ByteBuffer[] slice(java.nio.ByteBuffer[] buffer, int size)
          Remove data from the head of a buffer array.
static java.nio.ByteBuffer sliceCompact(java.nio.ByteBuffer[] buffer, int size)
          Remove a contiguous header from the head of a buffer array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

slice

public static java.nio.ByteBuffer[] slice(java.nio.ByteBuffer[] buffer,
                                          int size)
Remove data from the head of a buffer array. No copying of data is done. This is useful if data if being resent. This operation might leave some buffers in the array with remaining()==0.


sliceCompact

public static java.nio.ByteBuffer sliceCompact(java.nio.ByteBuffer[] buffer,
                                               int size)
Remove a contiguous header from the head of a buffer array. Copying of data is done only if required to return a contiguous buffer. This might be less efficient that popData() but the result can be used safely to read data. This operation might leave some buffers in the array with remaining()==0.


compact

public static java.nio.ByteBuffer compact(java.nio.ByteBuffer[] buffer)
Compact a buffer array to a single buffer. Upon returning, all supplied buffers will have remaining()==0. Contents are returned in a single freshly allocated buffer.


count

public static int count(java.nio.ByteBuffer[] buffer)
Count remaining bytes in a buffer array.


copy

public static int copy(java.nio.ByteBuffer res,
                       java.nio.ByteBuffer[] buffer)
Copy a buffer array to a single buffer.


clone

public static java.nio.ByteBuffer[] clone(java.nio.ByteBuffer[] buffer)
Clone a buffer array. Upon returning, the supplied buffers remain intact and a read only copy is returned.



Copyright © 2005 University of Minho, Portugal. All Rights Reserved.