public abstract class BufferFactory
extends java.lang.Object
BufferWrapper
, without having to know the underlying data type. Once created, a
BufferWrapper abstracts reading and writing buffer data from the underlying data type. When BufferWrapper is combined
with BufferFactory, a component may create and work with buffer data in a type agnostic manner.
BufferFactory is itself abstract and defines the factory interface. It defines several implementations as static
inner classes, which serve the most common data types: BufferFactory.ByteBufferFactory
,
BufferFactory.ShortBufferFactory
, BufferFactory.IntBufferFactory
,
BufferFactory.FloatBufferFactory
, and BufferFactory.DoubleBufferFactory
.BufferWrapper
Modifier and Type | Class and Description |
---|---|
static class |
BufferFactory.ByteBufferFactory
Implementation of BufferFactory which constructs instances of
BufferWrapper.ByteBufferWrapper |
static class |
BufferFactory.DoubleBufferFactory
Implementation of BufferFactory which constructs instances of
BufferWrapper.DoubleBufferWrapper |
static class |
BufferFactory.FloatBufferFactory
Implementation of BufferFactory which constructs instances of
BufferWrapper.FloatBufferWrapper |
static class |
BufferFactory.IntBufferFactory
Implementation of BufferFactory which constructs instances of
BufferWrapper.IntBufferWrapper |
static class |
BufferFactory.ShortBufferFactory
Implementation of BufferFactory which constructs instances of
BufferWrapper.ShortBufferWrapper |
Modifier | Constructor and Description |
---|---|
protected |
BufferFactory()
Constructs a new BufferFactory with the default buffer allocation policy.
|
protected |
BufferFactory(boolean allocateDirect)
Constructs a new BufferFactory with the specified buffer allocation policy.
|
Modifier and Type | Method and Description |
---|---|
boolean |
isAllocateDirect() |
abstract BufferWrapper |
newBuffer(int size)
Constructs a new BufferWrapper of the specified size.
|
protected BufferFactory()
protected BufferFactory(boolean allocateDirect)
allocateDirect
- true to allocate and return BufferWrappers backed by direct buffers, false to allocate and
return BufferWrappers backed by non-direct buffers.public boolean isAllocateDirect()
public abstract BufferWrapper newBuffer(int size)
size
- the new buffer's size, in number of underlying data type units (bytes, shorts, ints, floats, or
doubles).java.lang.IllegalArgumentException
- if size is negative.