com.kenai.jaffl

Class MemoryIO

public abstract class MemoryIO extends Object implements Pointer

Interface to reading/writing various types of memory
Method Summary
abstract longaddress()
Gets the native address of this memory object (optional operation).
static MemoryIOallocate(int size)
Allocates a new block of java heap memory and wraps it in a MemoryIO accessor.
static MemoryIOallocateDirect(int size)
Allocates a new block of native memory and wraps it in a MemoryIO accessor.
static MemoryIOallocateDirect(int size, boolean clear)
Allocates a new block of native memory and wraps it in a MemoryIO accessor.
abstract voidget(long offset, byte[] dst, int idx, int len)
Bulk byte get method.
abstract voidget(long offset, short[] dst, int idx, int len)
Bulk short get method.
abstract voidget(long offset, int[] dst, int idx, int len)
Bulk int get method.
abstract voidget(long offset, long[] dst, int idx, int len)
Bulk long get method.
abstract voidget(long offset, float[] dst, int idx, int len)
Bulk float get method.
abstract voidget(long offset, double[] dst, int idx, int len)
Bulk double get method.
abstract longgetAddress(long offset)
abstract bytegetByte(long offset)
Reads a 8 bit integer at the given offset.
abstract doublegetDouble(long offset)
Reads a 64 bit floating point value at the given offset.
abstract floatgetFloat(long offset)
Reads a 32 bit floating point value at the given offset.
abstract intgetInt(long offset)
Reads a 32 bit integer at the given offset.
abstract longgetLong(long offset)
Reads a 64 bit integer at the given offset.
abstract MemoryIOgetMemoryIO(long offset)
abstract MemoryIOgetMemoryIO(long offset, long size)
abstract longgetNativeLong(long offset)
abstract PointergetPointer(long offset)
abstract shortgetShort(long offset)
Reads a 16 bit integer at the given offset.
abstract StringgetString(long offset, int maxLength, Charset cs)
abstract StringgetString(long offset)
abstract intindexOf(long offset, byte value)
abstract intindexOf(long offset, byte value, int maxlen)
abstract booleanisDirect()
Tells whether or not this memory object is direct.
abstract voidput(long offset, byte[] src, int idx, int len)
Bulk byte put method.
abstract voidput(long offset, short[] src, int idx, int len)
Bulk short put method.
abstract voidput(long offset, int[] src, int idx, int len)
Bulk int put method.
abstract voidput(long offset, long[] src, int idx, int len)
Bulk long put method.
abstract voidput(long offset, float[] src, int idx, int len)
Bulk float put method.
abstract voidput(long offset, double[] src, int idx, int len)
Bulk double put method.
abstract voidputAddress(long offset, long value)
abstract voidputAddress(long offset, Address value)
abstract voidputByte(long offset, byte value)
Writes an 8 bit integer value at the given offset.
abstract voidputDouble(long offset, double value)
Writes a 64 bit floating point value at the given offset.
abstract voidputFloat(long offset, float value)
Writes a 32 bit floating point value at the given offset.
abstract voidputInt(long offset, int value)
Writes a 32 bit integer value at the given offset.
abstract voidputLong(long offset, long value)
Writes a 64 bit integer value at the given offset.
abstract voidputNativeLong(long offset, long value)
abstract voidputPointer(long offset, Pointer value)
abstract voidputShort(long offset, short value)
Writes a 16 bit integer value at the given offset.
abstract voidputString(long offset, String string, int maxLength, Charset cs)
abstract voidsetMemory(long offset, long size, byte value)
abstract MemoryIOslice(long offset)
abstract MemoryIOslice(long offset, long size)
abstract voidtransferTo(long offset, MemoryIO other, long otherOffset, long count)
static MemoryIOwrap(Pointer ptr)
static MemoryIOwrap(Pointer ptr, int size)
static MemoryIOwrap(ByteBuffer buffer)

Method Detail

address

public abstract long address()
Gets the native address of this memory object (optional operation).

Returns: The native address of this memory object.

Throws: UnsupportedOperationException If this memory object is not backed by native memory.

allocate

public static final MemoryIO allocate(int size)
Allocates a new block of java heap memory and wraps it in a MemoryIO accessor.

Parameters: size The size in bytes of memory to allocate.

Returns: A new MemoryIO instance that can access the memory.

allocateDirect

public static final MemoryIO allocateDirect(int size)
Allocates a new block of native memory and wraps it in a MemoryIO accessor.

Parameters: size The size in bytes of memory to allocate.

Returns: A new MemoryIO instance that can access the memory.

allocateDirect

public static final MemoryIO allocateDirect(int size, boolean clear)
Allocates a new block of native memory and wraps it in a MemoryIO accessor.

Parameters: size The size in bytes of memory to allocate. clear Whether the memory contents should be cleared, or left as random data.

Returns: A new MemoryIO instance that can access the memory.

get

public abstract void get(long offset, byte[] dst, int idx, int len)
Bulk byte get method. This method reads an array of bytes at the given offset into the given destination array.

Parameters: offset The offset at which the values will be read. dst The array into which values are to be written. idx The index within the destination array of the first value to be written. len The number of values to be written to the destination array.

get

public abstract void get(long offset, short[] dst, int idx, int len)
Bulk short get method. This method reads an array of 16 bit integers at the given offset into the given destination array.

Parameters: offset The offset at which the values will be read. dst The array into which values are to be written. idx The index within the destination array of the first value to be written. len The number of values to be written to the destination array.

get

public abstract void get(long offset, int[] dst, int idx, int len)
Bulk int get method. This method reads an array of 32 bit integers at the given offset into the given destination array.

Parameters: offset The offset at which the values will be read. dst The array into which values are to be written. idx The index within the destination array of the first value to be written. len The number of values to be written to the destination array.

get

public abstract void get(long offset, long[] dst, int idx, int len)
Bulk long get method. This method reads an array of 64 bit integers at the given offset into the given destination array.

Parameters: offset The offset at which the values will be read. dst The array into which values are to be written. idx The index within the destination array of the first value to be written. len The number of values to be written to the destination array.

get

public abstract void get(long offset, float[] dst, int idx, int len)
Bulk float get method. This method reads an array of 32 bit floats at the given offset into the given destination array.

Parameters: offset The offset at which the values will be read. dst The array into which values are to be written. idx The index within the destination array of the first value to be written. len The number of values to be written to the destination array.

get

public abstract void get(long offset, double[] dst, int idx, int len)
Bulk double get method. This method reads an array of 64 bit floats at the given offset into the given destination array.

Parameters: offset The offset at which the values will be read. dst The array into which values are to be written. idx The index within the destination array of the first value to be written. len The number of values to be written to the destination array.

getAddress

public abstract long getAddress(long offset)

getByte

public abstract byte getByte(long offset)
Reads a 8 bit integer at the given offset.

Parameters: offset The offset from which the integer will be read.

Returns: The byte value at the offset.

getDouble

public abstract double getDouble(long offset)
Reads a 64 bit floating point value at the given offset.

Parameters: offset The offset from which the integer will be read.

Returns: The double value at the offset.

getFloat

public abstract float getFloat(long offset)
Reads a 32 bit floating point value at the given offset.

Parameters: offset The offset from which the integer will be read.

Returns: The float value at the offset.

getInt

public abstract int getInt(long offset)
Reads a 32 bit integer at the given offset.

Parameters: offset The offset from which the integer will be read.

Returns: The int value at the offset.

getLong

public abstract long getLong(long offset)
Reads a 64 bit integer at the given offset.

Parameters: offset The offset from which the integer will be read.

Returns: The long value at the offset.

getMemoryIO

public abstract MemoryIO getMemoryIO(long offset)

getMemoryIO

public abstract MemoryIO getMemoryIO(long offset, long size)

getNativeLong

public abstract long getNativeLong(long offset)

getPointer

public abstract Pointer getPointer(long offset)

getShort

public abstract short getShort(long offset)
Reads a 16 bit integer at the given offset.

Parameters: offset The offset from which the integer will be read.

Returns: The short value at the offset.

getString

public abstract String getString(long offset, int maxLength, Charset cs)

getString

public abstract String getString(long offset)

indexOf

public abstract int indexOf(long offset, byte value)

indexOf

public abstract int indexOf(long offset, byte value, int maxlen)

isDirect

public abstract boolean isDirect()
Tells whether or not this memory object is direct. Memory objects can be either direct (representing native memory), or non-direct (representing java heap memory).

Returns: true if, and only if, this memory object is direct

put

public abstract void put(long offset, byte[] src, int idx, int len)
Bulk byte put method. This method writes an array of bytes at the given offset from the given source array.

Parameters: offset The offset at which the values will be written. src The source array from which values are to be read. idx The index within the destination array of the first value to be read. len The number of values to be read from the source array.

put

public abstract void put(long offset, short[] src, int idx, int len)
Bulk short put method. This method writes an array of 16 bit integers at the given offset from the given array.

Parameters: offset The offset at which the values will be written. src The source array from which values are to be read. idx The index within the destination array of the first value to be read. len The number of values to be read from the source array.

put

public abstract void put(long offset, int[] src, int idx, int len)
Bulk int put method. This method writes an array of 32 bit integers at the given offset from the given array.

Parameters: offset The offset at which the values will be written. src The source array from which values are to be read. idx The index within the destination array of the first value to be read. len The number of values to be read from the source array.

put

public abstract void put(long offset, long[] src, int idx, int len)
Bulk long put method. This method writes an array of 64 bit integers at the given offset from the given array.

Parameters: offset The offset at which the values will be written. src The source array from which values are to be read. idx The index within the destination array of the first value to be read. len The number of values to be read from the source array.

put

public abstract void put(long offset, float[] src, int idx, int len)
Bulk float put method. This method writes an array of 32 bit floats at the given offset from the given array.

Parameters: offset The offset at which the values will be written. src The source array from which values are to be read. idx The index within the destination array of the first value to be read. len The number of values to be read from the source array.

put

public abstract void put(long offset, double[] src, int idx, int len)
Bulk double put method. This method writes an array of 64 bit floats at the given offset from the given array.

Parameters: offset The offset at which the values will be written. src The source array from which values are to be read. idx The index within the destination array of the first value to be read. len The number of values to be read from the source array.

putAddress

public abstract void putAddress(long offset, long value)

putAddress

public abstract void putAddress(long offset, Address value)

putByte

public abstract void putByte(long offset, byte value)
Writes an 8 bit integer value at the given offset.

Parameters: offset The offset at which the value will be written. value The value to be written.

putDouble

public abstract void putDouble(long offset, double value)
Writes a 64 bit floating point value at the given offset.

Parameters: offset The offset at which the value will be written. value The value to be written.

putFloat

public abstract void putFloat(long offset, float value)
Writes a 32 bit floating point value at the given offset.

Parameters: offset The offset at which the value will be written. value The value to be written.

putInt

public abstract void putInt(long offset, int value)
Writes a 32 bit integer value at the given offset.

Parameters: offset The offset at which the value will be written. value The value to be written.

putLong

public abstract void putLong(long offset, long value)
Writes a 64 bit integer value at the given offset.

Parameters: offset The offset at which the value will be written. value The value to be written.

putNativeLong

public abstract void putNativeLong(long offset, long value)

putPointer

public abstract void putPointer(long offset, Pointer value)

putShort

public abstract void putShort(long offset, short value)
Writes a 16 bit integer value at the given offset.

Parameters: offset The offset at which the value will be written. value The value to be written.

putString

public abstract void putString(long offset, String string, int maxLength, Charset cs)

setMemory

public abstract void setMemory(long offset, long size, byte value)

slice

public abstract MemoryIO slice(long offset)

slice

public abstract MemoryIO slice(long offset, long size)

transferTo

public abstract void transferTo(long offset, MemoryIO other, long otherOffset, long count)

wrap

public static final MemoryIO wrap(Pointer ptr)

wrap

public static final MemoryIO wrap(Pointer ptr, int size)

wrap

public static final MemoryIO wrap(ByteBuffer buffer)