net.sf.cindy.buffer
Class BufferFactory

java.lang.Object
  extended by net.sf.cindy.buffer.BufferFactory

public class BufferFactory
extends java.lang.Object

Buffer factory.

Version:
$id$
Author:
Roger Chen

Constructor Summary
BufferFactory()
           
 
Method Summary
static Buffer allocate(int capacity)
          Allocate a new buffer.
static Buffer allocate(int capacity, boolean direct)
          Allocate a new buffer.
static Buffer wrap(Buffer[] buffers)
          Wrap a buffer array into a single buffer.
static Buffer wrap(byte[] array)
          Wrap a byte array into a buffer.
static Buffer wrap(byte[] array, int offset, int length)
          Wrap a byte array into a buffer.
static Buffer wrap(java.nio.ByteBuffer buffer)
          Wrap a byte buffer into a buffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BufferFactory

public BufferFactory()
Method Detail

wrap

public static Buffer wrap(byte[] array)
Wrap a byte array into a buffer.

Parameters:
array - byte array
Returns:
the new buffer

wrap

public static Buffer wrap(byte[] array,
                          int offset,
                          int length)
Wrap a byte array into a buffer.

Parameters:
array - byte array
offset - the offset of the subarray to be used
length - the length of the subarray to be used
Returns:
the new buffer

wrap

public static Buffer wrap(java.nio.ByteBuffer buffer)
Wrap a byte buffer into a buffer.

Parameters:
buffer - byte buffer
Returns:
the new buffer

wrap

public static Buffer wrap(Buffer[] buffers)
Wrap a buffer array into a single buffer.

Parameters:
buffers - buffer array
Returns:
the new buffer

allocate

public static Buffer allocate(int capacity)
Allocate a new buffer. The contents of the buffer are uninitialized, they will generally be garbage.

Parameters:
capacity - allocate capacity
Returns:
the new buffer

allocate

public static Buffer allocate(int capacity,
                              boolean direct)
Allocate a new buffer. The contents of the buffer are uninitialized, they will generally be garbage.

Parameters:
capacity - allocate capacity
direct - allocate direct buffer
Returns:
the new buffer