NASA World Wind

gov.nasa.worldwind.util
Class BufferFactory

java.lang.Object
  extended by gov.nasa.worldwind.util.BufferFactory
Direct Known Subclasses:
BufferFactory.ByteBufferFactory, BufferFactory.DoubleBufferFactory, BufferFactory.FloatBufferFactory, BufferFactory.IntBufferFactory, BufferFactory.ShortBufferFactory

public abstract class BufferFactory
extends Object

BufferFactory provides a general factory interface for creating instances of 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.

See Also:
BufferWrapper

Nested Class Summary
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
 
Constructor Summary
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
 boolean isAllocateDirect()
           
abstract  BufferWrapper newBuffer(int size)
          Constructs a new BufferWrapper of the specified size.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BufferFactory

protected BufferFactory()
Constructs a new BufferFactory with the default buffer allocation policy. This factory allocates and returns BufferWrappers backed by direct buffers.


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.
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:
IllegalArgumentException - if size is negative.

NASA World Wind