Package gov.nasa.worldwind.util
Class BufferFactory
- java.lang.Object
-
- gov.nasa.worldwind.util.BufferFactory
-
- Direct Known Subclasses:
BufferFactory.ByteBufferFactory
,BufferFactory.DoubleBufferFactory
,BufferFactory.FloatBufferFactory
,BufferFactory.IntBufferFactory
,BufferFactory.ShortBufferFactory
public abstract class BufferFactory extends java.lang.Object
BufferFactory provides a general factory interface for creating instances ofBufferWrapper
, 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
, andBufferFactory.DoubleBufferFactory
.- See Also:
BufferWrapper
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BufferFactory.ByteBufferFactory
Implementation of BufferFactory which constructs instances ofBufferWrapper.ByteBufferWrapper
static class
BufferFactory.DoubleBufferFactory
Implementation of BufferFactory which constructs instances ofBufferWrapper.DoubleBufferWrapper
static class
BufferFactory.FloatBufferFactory
Implementation of BufferFactory which constructs instances ofBufferWrapper.FloatBufferWrapper
static class
BufferFactory.IntBufferFactory
Implementation of BufferFactory which constructs instances ofBufferWrapper.IntBufferWrapper
static class
BufferFactory.ShortBufferFactory
Implementation of BufferFactory which constructs instances ofBufferWrapper.ShortBufferWrapper
-
Constructor Summary
Constructors Modifier Constructor 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.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
isAllocateDirect()
abstract BufferWrapper
newBuffer(int size)
Constructs a new BufferWrapper of the specified size.
-
-
-
Constructor Detail
-
BufferFactory
protected BufferFactory(boolean allocateDirect)
Constructs a new BufferFactory with the specified buffer allocation policy.- Parameters:
allocateDirect
- true to allocate and return BufferWrappers backed by direct buffers, false to allocate and return BufferWrappers backed by non-direct buffers.
-
BufferFactory
protected BufferFactory()
Constructs a new BufferFactory with the default buffer allocation policy. This factory allocates and returns BufferWrappers backed by direct buffers.
-
-
Method Detail
-
isAllocateDirect
public boolean isAllocateDirect()
- Returns:
- true if this factory allocates and returns BufferWrappers backed by direct buffers, and false if it allocates and return BufferWrappers backed by non-direct buffers.
-
newBuffer
public abstract BufferWrapper newBuffer(int size)
Constructs a new BufferWrapper of the specified size.- Parameters:
size
- the new buffer's size, in number of underlying data type units (bytes, shorts, ints, floats, or doubles).- Returns:
- the new buffer.
- Throws:
java.lang.IllegalArgumentException
- if size is negative.
-
-