com.sun.grizzly.util
Class ByteBufferFactory

java.lang.Object
  extended by com.sun.grizzly.util.ByteBufferFactory

public class ByteBufferFactory
extends Object

Factory class used to create ByteBuffer. The ByteBuffer can by direct (ByteBufferType.DIRECT) or heap (ByteBufferType.HEAP) a view (ByteBufferType.DIRECT_VIEW) or ByteBufferType.HEAP_VIEW) or backed by an array (ByteBufferType.HEAP_ARRAY).

Author:
Jean-Francois Arcand

Nested Class Summary
static class ByteBufferFactory.ByteBufferType
          An enumeration of all type of ByteBuffer this object can create.
 
Field Summary
static int capacity
          The default capacity of the ByteBuffer from which views will be created.
static int defaultCapacity
          The default capacity of the default view of a ByteBuffer
 
Method Summary
static ByteBuffer allocate(ByteBufferFactory.ByteBufferType type, int size)
          Return a new ByteBuffer based on the requested ByteBufferType
static ByteBuffer allocateView(boolean direct)
          Return a direct ByteBuffer view using the default size.
static ByteBuffer allocateView(int size, boolean direct)
          Return a direct ByteBuffer view
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultCapacity

public static int defaultCapacity
The default capacity of the default view of a ByteBuffer


capacity

public static int capacity
The default capacity of the ByteBuffer from which views will be created.

Method Detail

allocateView

public static ByteBuffer allocateView(int size,
                                      boolean direct)
Return a direct ByteBuffer view

Parameters:
size - the Size of the ByteBuffer
direct - - direct or non-direct buffer?
Returns:
ByteBuffer

allocateView

public static ByteBuffer allocateView(boolean direct)
Return a direct ByteBuffer view using the default size.

Parameters:
direct - - direct or non-direct buffer
Returns:
ByteBuffer

allocate

public static ByteBuffer allocate(ByteBufferFactory.ByteBufferType type,
                                  int size)
Return a new ByteBuffer based on the requested ByteBufferType

Parameters:
type - the requested ByteBufferType
size - the ByteBuffer size.
Returns:
a new ByteBuffer based on the requested ByteBufferType


Copyright © 2008 SUN Microsystems. All Rights Reserved.