public abstract class BufferWrapper extends Object
Modifier and Type | Class and Description |
---|---|
static class |
BufferWrapper.AbstractBufferWrapper<T extends Buffer> |
static class |
BufferWrapper.ByteBufferWrapper |
static class |
BufferWrapper.DoubleBufferWrapper |
protected static class |
BufferWrapper.EmptyBufferWrapper |
static class |
BufferWrapper.FloatBufferWrapper |
static class |
BufferWrapper.IntBufferWrapper |
static class |
BufferWrapper.ShortBufferWrapper |
Modifier and Type | Field and Description |
---|---|
protected static BufferWrapper |
EMPTY_BUFFER_WRAPPER |
Constructor and Description |
---|
BufferWrapper() |
Modifier and Type | Method and Description |
---|---|
abstract BufferWrapper |
copyOf(int newSize)
Returns a copy of this buffer with the specified new size.
|
static BufferWrapper |
emptyBufferWrapper()
Returns the empty BufferWrapper.
|
abstract Buffer |
getBackingBuffer()
Returns the buffer's backing data sture.
|
abstract byte |
getByte(int index)
Returns the value at the specified index, cast to a byte.
|
abstract void |
getByte(int index,
byte[] array,
int offset,
int length)
Returns the sequence of values starting at the specified index and with the specified length, cast to bytes.
|
abstract double |
getDouble(int index)
Returns the value at the specified index, cast to a double.
|
abstract void |
getDouble(int index,
double[] array,
int offset,
int length)
Returns the sequence of values starting at the specified index and with the specified length, cast to doubles.
|
abstract float |
getFloat(int index)
Returns the value at the specified index, cast to a float.
|
abstract void |
getFloat(int index,
float[] array,
int offset,
int length)
Returns the sequence of values starting at the specified index and with the specified length, cast to floats.
|
abstract int |
getGLDataType()
Returns the OpenGL data type corresponding to the buffer's underlying data type (e.g.
|
abstract int |
getInt(int index)
Returns the value at the specified index, cast to an int.
|
abstract void |
getInt(int index,
int[] array,
int offset,
int length)
Returns the sequence of values starting at the specified index and with the specified length, cast to ints.
|
abstract short |
getShort(int index)
Returns the value at the specified index, cast to a short.
|
abstract void |
getShort(int index,
short[] array,
int offset,
int length)
Returns the sequence of values starting at the specified index and with the specified length, cast to shorts.
|
abstract long |
getSizeInBytes()
Returns the size of this buffer, in bytes.
|
abstract BufferWrapper |
getSubBuffer(int index,
int length)
Returns a new BufferWrapper which is a subsequence of this buffer.
|
abstract int |
length()
Returns the length of the buffer, in units of the underlying data type (e.g.
|
abstract void |
putByte(int index,
byte value)
Sets the value at the specified index as a byte.
|
abstract void |
putByte(int index,
byte[] array,
int offset,
int length)
Sets the sequence of values starting at the specified index and with the specified length, as bytes.
|
abstract void |
putDouble(int index,
double value)
Sets the value at the specified index as a double.
|
abstract void |
putDouble(int index,
double[] array,
int offset,
int length)
Sets the sequence of values starting at the specified index and with the specified length, as doubles.
|
abstract void |
putFloat(int index,
float value)
Sets the value at the specified index as a float.
|
abstract void |
putFloat(int index,
float[] array,
int offset,
int length)
Sets the sequence of values starting at the specified index and with the specified length, as floats.
|
abstract void |
putInt(int index,
int value)
Sets the value at the specified index as an int.
|
abstract void |
putInt(int index,
int[] array,
int offset,
int length)
Sets the sequence of values starting at the specified index and with the specified length, as ints.
|
abstract void |
putShort(int index,
short value)
Sets the value at the specified index as a short.
|
abstract void |
putShort(int index,
short[] array,
int offset,
int length)
Sets the sequence of values starting at the specified index and with the specified length, as ints.
|
abstract void |
putSubBuffer(int index,
BufferWrapper buffer)
Sets a subsequence of this buffer with the contents of the specified buffer.
|
abstract void |
putSubBuffer(int index,
BufferWrapper buffer,
int offset,
int length)
Sets a subsequence of this buffer with the contents of the specified buffer.
|
static BufferWrapper |
wrap(ByteBuffer byteBuffer,
AVList params)
Wraps the specified
ByteBuffer with a BufferWrapper according to the specified parameters. |
static BufferWrapper |
wrap(ByteBuffer byteBuffer,
Object dataType)
Wraps the specified
ByteBuffer with a BufferWrapper according to the specified primitive dataType. |
static BufferWrapper |
wrap(ByteBuffer byteBuffer,
Object dataType,
Object byteOrder)
Wraps the specified
ByteBuffer with a BufferWrapper according to the specified primitive dataType and
byteOrder. |
protected static final BufferWrapper EMPTY_BUFFER_WRAPPER
public abstract BufferWrapper copyOf(int newSize)
newSize
- the new buffer's size.public static BufferWrapper emptyBufferWrapper()
public abstract Buffer getBackingBuffer()
Buffer
.public abstract byte getByte(int index)
index
- the index of the value to be returned.public abstract void getByte(int index, byte[] array, int offset, int length)
index
- the buffer starting index.array
- the array.offset
- the array starting index.length
- the number of values to get.public abstract double getDouble(int index)
index
- the index of the value to be returned.public abstract void getDouble(int index, double[] array, int offset, int length)
index
- the buffer starting index.array
- the array.offset
- the array starting index.length
- the number of values to get.public abstract float getFloat(int index)
index
- the index of the value to be returned.public abstract void getFloat(int index, float[] array, int offset, int length)
index
- the buffer starting index.array
- the array.offset
- the array starting index.length
- the number of values to get.public abstract int getGLDataType()
public abstract int getInt(int index)
index
- the index of the value to be returned.public abstract void getInt(int index, int[] array, int offset, int length)
index
- the buffer starting index.array
- the array.offset
- the array starting index.length
- the number of values to get.public abstract short getShort(int index)
index
- the index of the value to be returned.public abstract void getShort(int index, short[] array, int offset, int length)
index
- the buffer starting index.array
- the array.offset
- the array starting index.length
- the number of values to get.public abstract long getSizeInBytes()
public abstract BufferWrapper getSubBuffer(int index, int length)
index
- the new buffer's starting index.length
- the new buffer's length.public abstract int length()
public abstract void putByte(int index, byte value)
index
- the index of the value to be returned.value
- the byte value to be set.public abstract void putByte(int index, byte[] array, int offset, int length)
index
- the buffer starting index.array
- the array.offset
- the array starting index.length
- the number of values to put.public abstract void putDouble(int index, double value)
index
- the index of the value to be returned.value
- the double value to be set.public abstract void putDouble(int index, double[] array, int offset, int length)
index
- the buffer starting index.array
- the array.offset
- the array starting index.length
- the number of values to put.public abstract void putFloat(int index, float value)
index
- the index of the value to be returned.value
- the float value to be set.public abstract void putFloat(int index, float[] array, int offset, int length)
index
- the buffer starting index.array
- the array.offset
- the array starting index.length
- the number of values to put.public abstract void putInt(int index, int value)
index
- the index of the value to be returned.value
- the int value to be set.public abstract void putInt(int index, int[] array, int offset, int length)
index
- the buffer starting index.array
- the array.offset
- the array starting index.length
- the number of values to put.public abstract void putShort(int index, short value)
index
- the index of the value to be returned.value
- the short value to be set.public abstract void putShort(int index, short[] array, int offset, int length)
index
- the buffer starting index.array
- the array.offset
- the array starting index.length
- the number of values to put.public abstract void putSubBuffer(int index, BufferWrapper buffer)
index
- the starting index to set.buffer
- the buffer.public abstract void putSubBuffer(int index, BufferWrapper buffer, int offset, int length)
index
- the starting index to set.buffer
- the buffer.offset
- the starting index to get from the buffer.length
- the number of values to get from the buffer.public static BufferWrapper wrap(ByteBuffer byteBuffer, AVList params)
ByteBuffer
with a BufferWrapper according to the specified parameters. The AVKey.DATA_TYPE
parameter is required, and describes the primitive data type stored in the ByteBuffer: shorts,
ints, floats, or doubles. The AVKey.BYTE_ORDER
parameter is optional, and describes the ByteBuffer's byte
ordering.byteBuffer
- the buffer to wrap.params
- the parameters which describe how to interpret the buffer.IllegalArgumentException
- if either the byteBuffer or the parameters are null, or if AVKey.DATA_TYPE
parameter is missing.public static BufferWrapper wrap(ByteBuffer byteBuffer, Object dataType)
ByteBuffer
with a BufferWrapper according to the specified primitive dataType. The
dataType describes the primitive data type stored in the ByteBuffer: shorts, ints, floats, or doubles. This
assumes the ByteBuffer's current byte ordering.byteBuffer
- the buffer to wrap.dataType
- the primitive data type stored in the ByteBuffer.IllegalArgumentException
- if either the byteBuffer or the data type are null.public static BufferWrapper wrap(ByteBuffer byteBuffer, Object dataType, Object byteOrder)
ByteBuffer
with a BufferWrapper according to the specified primitive dataType and
byteOrder. The dataType describes the primitive data type stored in the ByteBuffer: shorts, ints, floats, or
doubles. The byteOrder describes the ByteBuffer's byte ordering. A null byteOrder indicates that the ByteBuffer's
current byte ordering should be used.byteBuffer
- the buffer to wrap.dataType
- the primitive data type stored in the ByteBuffer.byteOrder
- the primitive byte ordering of the ByteBuffer, or null to use the ByteBuffer's current
ordering.IllegalArgumentException
- if either the byteBuffer or the data type are null.