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.ObjectBufferFactory 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 classBufferFactory.ByteBufferFactoryImplementation of BufferFactory which constructs instances ofBufferWrapper.ByteBufferWrapperstatic classBufferFactory.DoubleBufferFactoryImplementation of BufferFactory which constructs instances ofBufferWrapper.DoubleBufferWrapperstatic classBufferFactory.FloatBufferFactoryImplementation of BufferFactory which constructs instances ofBufferWrapper.FloatBufferWrapperstatic classBufferFactory.IntBufferFactoryImplementation of BufferFactory which constructs instances ofBufferWrapper.IntBufferWrapperstatic classBufferFactory.ShortBufferFactoryImplementation of BufferFactory which constructs instances ofBufferWrapper.ShortBufferWrapper
-
Constructor Summary
Constructors Modifier Constructor Description protectedBufferFactory()Constructs a new BufferFactory with the default buffer allocation policy.protectedBufferFactory(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 booleanisAllocateDirect()abstract BufferWrappernewBuffer(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.
-
-