com.jniwrapper
Class ParameterBufferImpl

java.lang.Object
  extended by com.jniwrapper.ParameterBufferImpl
All Implemented Interfaces:
DataBuffer, MemoryBuffer

public class ParameterBufferImpl
extends java.lang.Object
implements MemoryBuffer


Method Summary
static MemoryBuffer allocate(int amount)
           
static MemoryBuffer createExternMemorySource(long handle, int amount)
           
 java.nio.ByteBuffer getBuffer()
           
 long getHandle()
          Returns native memory handle (usually block address).
 int getLength()
          Returns the length of allocated memory block.
 byte readByte(int offset)
          Reads a byte at a given offset.
 void readByteArray(int offset, byte[] dstArray, int dstOffset, int length)
          Copies data from this source to an array.
 byte[] readByteArray(int offset, int length)
          Reads the length bytes from this source.
 long readCallbackReference(int offset)
          Reads a callback reference (pointer) at a given offset.
 int readInt(int offset)
          Reads an int (2-byte signed) value at a given offset.
 long readLong(int offset)
          Reads a long (8-byte signed) value at a given offset.
 long readPointer(int offset)
          Reads a pointer value at a given offset.
 short readShort(int offset)
          Reads a short (2-byte signed) value at a given offset.
 void resize(int newSize)
          Resizes this source so that it can hold the newSize bytes.
 void setupReallocation(long reallocatedHandle, int newSize)
          Sets new handle and size after this block has been reallocated outside of this block's code.
 void writeByte(int offset, byte val)
          Writes a single byte at a given offset.
 void writeByteArray(int offset, byte[] val)
          Copies all data from a given array to this source.
 void writeByteArray(int offset, byte[] val, int srcOffset, int length)
          Copies data from an array to this source.
 void writeCallbackReference(int offset, long val)
          Writes a callback reference (pointer) at a given offset.
 void writeInt(int offset, int val)
          Writes an int (4-byte signed) value at a given offset.
 void writeLong(int offset, long val)
          Writes a long (8-byte signed) value at a given offset.
 void writePointer(int offset, long val)
          Writes a pointer value at a given offset.
 void writeShort(int offset, short val)
          Writes a short (2-byte signed) value at a given offset.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.jniwrapper.DataBuffer
readByte, readByteArray, readByteArray, readCallbackReference, readInt, readLong, readPointer, readShort, writeByte, writeByteArray, writeByteArray, writeCallbackReference, writeInt, writeLong, writePointer, writeShort
 

Method Detail

getHandle

public long getHandle()
Description copied from interface: MemoryBuffer
Returns native memory handle (usually block address).

Specified by:
getHandle in interface MemoryBuffer

getLength

public int getLength()
Description copied from interface: MemoryBuffer
Returns the length of allocated memory block. Memory access methods may check that all accessed data is within allocated bounds, but this is not guaranteed.

Specified by:
getLength in interface MemoryBuffer

resize

public void resize(int newSize)
Description copied from interface: DataBuffer
Resizes this source so that it can hold the newSize bytes.

Specified by:
resize in interface DataBuffer

setupReallocation

public void setupReallocation(long reallocatedHandle,
                              int newSize)
Description copied from interface: MemoryBuffer
Sets new handle and size after this block has been reallocated outside of this block's code.

Specified by:
setupReallocation in interface MemoryBuffer

allocate

public static MemoryBuffer allocate(int amount)

createExternMemorySource

public static MemoryBuffer createExternMemorySource(long handle,
                                                    int amount)

getBuffer

public java.nio.ByteBuffer getBuffer()

writeByte

public void writeByte(int offset,
                      byte val)
Description copied from interface: DataBuffer
Writes a single byte at a given offset.

Specified by:
writeByte in interface DataBuffer

readByte

public byte readByte(int offset)
Description copied from interface: DataBuffer
Reads a byte at a given offset.

Specified by:
readByte in interface DataBuffer

writeShort

public void writeShort(int offset,
                       short val)
Description copied from interface: DataBuffer
Writes a short (2-byte signed) value at a given offset.

Specified by:
writeShort in interface DataBuffer

readShort

public short readShort(int offset)
Description copied from interface: DataBuffer
Reads a short (2-byte signed) value at a given offset.

Specified by:
readShort in interface DataBuffer

writeInt

public void writeInt(int offset,
                     int val)
Description copied from interface: DataBuffer
Writes an int (4-byte signed) value at a given offset.

Specified by:
writeInt in interface DataBuffer

readInt

public int readInt(int offset)
Description copied from interface: DataBuffer
Reads an int (2-byte signed) value at a given offset.

Specified by:
readInt in interface DataBuffer

writeLong

public void writeLong(int offset,
                      long val)
Description copied from interface: DataBuffer
Writes a long (8-byte signed) value at a given offset.

Specified by:
writeLong in interface DataBuffer

readLong

public long readLong(int offset)
Description copied from interface: DataBuffer
Reads a long (8-byte signed) value at a given offset.

Specified by:
readLong in interface DataBuffer

writePointer

public void writePointer(int offset,
                         long val)
Description copied from interface: DataBuffer
Writes a pointer value at a given offset.

Specified by:
writePointer in interface DataBuffer

readPointer

public long readPointer(int offset)
Description copied from interface: DataBuffer
Reads a pointer value at a given offset.

Specified by:
readPointer in interface DataBuffer

writeCallbackReference

public void writeCallbackReference(int offset,
                                   long val)
Description copied from interface: DataBuffer
Writes a callback reference (pointer) at a given offset.

Specified by:
writeCallbackReference in interface DataBuffer

readCallbackReference

public long readCallbackReference(int offset)
Description copied from interface: DataBuffer
Reads a callback reference (pointer) at a given offset.

Specified by:
readCallbackReference in interface DataBuffer

writeByteArray

public void writeByteArray(int offset,
                           byte[] val,
                           int srcOffset,
                           int length)
Description copied from interface: DataBuffer
Copies data from an array to this source.

Specified by:
writeByteArray in interface DataBuffer
Parameters:
offset - target offset in this DataSource
val - where to get data
srcOffset - starting offset in the val array
length - the number of bytes to copy

readByteArray

public void readByteArray(int offset,
                          byte[] dstArray,
                          int dstOffset,
                          int length)
Description copied from interface: DataBuffer
Copies data from this source to an array.

Specified by:
readByteArray in interface DataBuffer
Parameters:
offset - source offset in this DataSource
dstArray - where to put data
dstOffset - starting offset in the dstArray array
length - the number of bytes to copy

writeByteArray

public void writeByteArray(int offset,
                           byte[] val)
Description copied from interface: DataBuffer
Copies all data from a given array to this source.

Specified by:
writeByteArray in interface DataBuffer

readByteArray

public byte[] readByteArray(int offset,
                            int length)
Description copied from interface: DataBuffer
Reads the length bytes from this source.

Specified by:
readByteArray in interface DataBuffer