public class DefaultDataBufferFactory extends Object implements DataBufferFactory
DataBufferFactory interface. Allows for
specification of the default initial capacity at construction time, as well
as whether heap-based or direct buffers are to be preferred.| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_INITIAL_CAPACITY
The default capacity when none is specified.
|
| Constructor and Description |
|---|
DefaultDataBufferFactory()
Creates a new
DefaultDataBufferFactory with default settings. |
DefaultDataBufferFactory(boolean preferDirect)
Creates a new
DefaultDataBufferFactory, indicating whether direct
buffers should be created by allocateBuffer() and
allocateBuffer(int). |
DefaultDataBufferFactory(boolean preferDirect,
int defaultInitialCapacity)
Creates a new
DefaultDataBufferFactory, indicating whether direct
buffers should be created by allocateBuffer() and
allocateBuffer(int), and what the capacity is to be used for
allocateBuffer(). |
| Modifier and Type | Method and Description |
|---|---|
DefaultDataBuffer |
allocateBuffer()
Allocate a data buffer of a default initial capacity.
|
DefaultDataBuffer |
allocateBuffer(int initialCapacity)
Allocate a data buffer of the given initial capacity.
|
String |
toString() |
DefaultDataBuffer |
wrap(ByteBuffer byteBuffer)
Wrap the given
ByteBuffer in a DataBuffer. |
public static final int DEFAULT_INITIAL_CAPACITY
public DefaultDataBufferFactory()
DefaultDataBufferFactory with default settings.public DefaultDataBufferFactory(boolean preferDirect)
DefaultDataBufferFactory, indicating whether direct
buffers should be created by allocateBuffer() and
allocateBuffer(int).preferDirect - true if direct buffers are to be preferred;
false otherwisepublic DefaultDataBufferFactory(boolean preferDirect,
int defaultInitialCapacity)
DefaultDataBufferFactory, indicating whether direct
buffers should be created by allocateBuffer() and
allocateBuffer(int), and what the capacity is to be used for
allocateBuffer().preferDirect - true if direct buffers are to be preferred;
false otherwisepublic DefaultDataBuffer allocateBuffer()
DataBufferFactoryallocateBuffer in interface DataBufferFactorypublic DefaultDataBuffer allocateBuffer(int initialCapacity)
DataBufferFactoryallocateBuffer in interface DataBufferFactoryinitialCapacity - the initial capacity of the buffer to allocatepublic DefaultDataBuffer wrap(ByteBuffer byteBuffer)
DataBufferFactoryByteBuffer in a DataBuffer.wrap in interface DataBufferFactorybyteBuffer - the NIO byte buffer to wrap