public class DefaultDataBufferFactory extends java.lang.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.
|
private int |
defaultInitialCapacity |
private boolean |
preferDirect |
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.
|
java.lang.String |
toString() |
DataBuffer |
wrap(byte[] bytes)
Wrap the given
byte array in a DataBuffer . |
DefaultDataBuffer |
wrap(java.nio.ByteBuffer byteBuffer)
Wrap the given
ByteBuffer in a DataBuffer . |
public static final int DEFAULT_INITIAL_CAPACITY
private final boolean preferDirect
private final int defaultInitialCapacity
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()
DataBufferFactory
allocateBuffer
in interface DataBufferFactory
public DefaultDataBuffer allocateBuffer(int initialCapacity)
DataBufferFactory
allocateBuffer
in interface DataBufferFactory
initialCapacity
- the initial capacity of the buffer to allocatepublic DefaultDataBuffer wrap(java.nio.ByteBuffer byteBuffer)
DataBufferFactory
ByteBuffer
in a DataBuffer
.wrap
in interface DataBufferFactory
byteBuffer
- the NIO byte buffer to wrappublic DataBuffer wrap(byte[] bytes)
DataBufferFactory
byte
array in a DataBuffer
.wrap
in interface DataBufferFactory
bytes
- the byte array to wrappublic java.lang.String toString()
toString
in class java.lang.Object