jnr.ffi.provider
Class AbstractMemoryIO

java.lang.Object
  extended by jnr.ffi.Pointer
      extended by jnr.ffi.provider.AbstractMemoryIO
Direct Known Subclasses:
AbstractArrayMemoryIO, AbstractBufferMemoryIO, BoundedMemoryIO, InAccessibleMemoryIO, ShareMemoryIO, TransientNativeMemory

public abstract class AbstractMemoryIO
extends Pointer

Base implementations of some MemoryIO operations.


Constructor Summary
protected AbstractMemoryIO(Runtime runtime)
           
 
Method Summary
 void checkBounds(long offset, long size)
          Checks that the memory region is within the bounds of this memory object
protected static void checkBounds(long size, long off, long len)
           
 long getAddress(long offset)
           
 long getInt(Type type, long offset)
          Reads an integer value of the given type, at the given offset.
 long getLong(long offset)
          Reads a long (64 bit) value at the given offset.
 long getNativeLong(long offset)
          Reads a native long value at the given offset.
 Runtime getRuntime()
          Gets the Runtime this Pointer instance belongs to.
 int indexOf(long offset, byte value)
          Returns the location of a byte value within the memory area represented by this Pointer.
 void putAddress(long offset, Address value)
           
 void putAddress(long offset, long value)
           
 void putInt(Type type, long offset, long value)
          Writes an integer of a specific type, at the given offset.
 void putLong(long offset, long value)
          Writes a native long value at the given offset.
 void putNativeLong(long offset, long value)
          Writes a native long value at the given offset.
 AbstractMemoryIO slice(long offset)
          Creates a new Pointer representing a sub-region of the memory referred to by this Pointer.
 AbstractMemoryIO slice(long offset, long size)
          Creates a new Pointer representing a sub-region of the memory referred to by this Pointer.
 void transferFrom(long offset, Pointer other, long otherOffset, long count)
          Bulk data transfer from one memory location to another.
 void transferTo(long offset, Pointer other, long otherOffset, long count)
          Bulk data transfer from one memory location to another.
 
Methods inherited from class jnr.ffi.Pointer
address, array, arrayLength, arrayOffset, get, get, get, get, get, get, get, getByte, getDouble, getFloat, getInt, getLongLong, getNullTerminatedPointerArray, getNullTerminatedStringArray, getPointer, getPointer, getShort, getString, getString, hasArray, indexOf, isDirect, newIntPointer, put, put, put, put, put, put, put, putByte, putDouble, putFloat, putInt, putLongLong, putPointer, putShort, putString, setMemory, size, wrap, wrap, wrap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractMemoryIO

protected AbstractMemoryIO(Runtime runtime)
Method Detail

checkBounds

protected static final void checkBounds(long size,
                                        long off,
                                        long len)

getRuntime

public final Runtime getRuntime()
Description copied from class: Pointer
Gets the Runtime this Pointer instance belongs to.

Specified by:
getRuntime in class Pointer
Returns:
the Runtime instance of this Pointer.

indexOf

public int indexOf(long offset,
                   byte value)
Description copied from class: Pointer
Returns the location of a byte value within the memory area represented by this Pointer.

Specified by:
indexOf in class Pointer
Parameters:
offset - the offset from the start of the memory location this Pointer represents to begin searching.
value - the byte value to locate.
Returns:
the offset from the start of the search area (i.e. relative to the offset parameter), or -1 if not found.

getAddress

public long getAddress(long offset)
Specified by:
getAddress in class Pointer

putAddress

public void putAddress(long offset,
                       long value)
Specified by:
putAddress in class Pointer

checkBounds

public void checkBounds(long offset,
                        long size)
Description copied from class: Pointer
Checks that the memory region is within the bounds of this memory object

Specified by:
checkBounds in class Pointer
Parameters:
offset - the starting point within this memory region.
size - the length of the memory region in bytes

putAddress

public void putAddress(long offset,
                       Address value)
Specified by:
putAddress in class Pointer

getNativeLong

public final long getNativeLong(long offset)
Description copied from class: Pointer
Reads a native long value at the given offset.

A native long can be either 32 or 64 bits in size, depending on the cpu architecture, and the C ABI in use.

For windows, a long is always 32 bits (4 bytes) in size, but on unix systems, a long on a 32bit system is 32 bits, and on a 64bit system, is 64 bits.

Specified by:
getNativeLong in class Pointer
Parameters:
offset - The offset from the start of the memory this Pointer represents at which the value will be read.
Returns:
the native long value at the offset.
See Also:
NativeLong

putNativeLong

public void putNativeLong(long offset,
                          long value)
Description copied from class: Pointer
Writes a native long value at the given offset.

A native long can be either 32 or 64 bits in size, depending on the cpu architecture, and the C ABI in use.

For windows, a long is always 32 bits (4 bytes) in size, but on unix systems, a long on a 32bit system is 32 bits, and on a 64bit system, is 64 bits.

Specified by:
putNativeLong in class Pointer
Parameters:
offset - The offset from the start of the memory this Pointer represents at which the value will be written.
value - the native long value to be written.

getLong

public long getLong(long offset)
Description copied from class: Pointer
Reads a long (64 bit) value at the given offset.

Specified by:
getLong in class Pointer
Parameters:
offset - The offset from the start of the memory this Pointer represents at which the value will be read.
Returns:
the long value at the offset.

putLong

public void putLong(long offset,
                    long value)
Description copied from class: Pointer
Writes a native long value at the given offset.

Specified by:
putLong in class Pointer
Parameters:
offset - The offset from the start of the memory this Pointer represents at which the value will be written.
value - the long value to be written.

putInt

public void putInt(Type type,
                   long offset,
                   long value)
Description copied from class: Pointer
Writes an integer of a specific type, at the given offset.

Specified by:
putInt in class Pointer
offset - The offset from the start of the memory this Pointer represents at which the value will be written.
value - the int value to be written.

getInt

public long getInt(Type type,
                   long offset)
Description copied from class: Pointer
Reads an integer value of the given type, at the given offset.

Specified by:
getInt in class Pointer
Parameters:
type - Type of integer to read.
offset - The offset from the start of the memory this Pointer represents at which the value will be read.
Returns:
the int value contained in the memory at the offset.

slice

public AbstractMemoryIO slice(long offset)
Description copied from class: Pointer
Creates a new Pointer representing a sub-region of the memory referred to by this Pointer.

Specified by:
slice in class Pointer
Parameters:
offset - the offset from the start of the memory this Pointer represents at which the new Pointer will start.
Returns:
a Pointer instance representing the new sub-region.

slice

public AbstractMemoryIO slice(long offset,
                              long size)
Description copied from class: Pointer
Creates a new Pointer representing a sub-region of the memory referred to by this Pointer.

Specified by:
slice in class Pointer
Parameters:
offset - the offset from the start of the memory this Pointer represents at which the new Pointer will start.
size - the maximum size of the memory sub-region.
Returns:
a Pointer instance representing the new sub-region.

transferTo

public void transferTo(long offset,
                       Pointer other,
                       long otherOffset,
                       long count)
Description copied from class: Pointer
Bulk data transfer from one memory location to another.

Specified by:
transferTo in class Pointer
Parameters:
offset - the offset from the start of the memory location this Pointer represents to begin copying from.
other - the destination memory location to transfer data to.
otherOffset - the offset from the start of the memory location the destination Pointer represents to begin copying to.
count - the number of bytes to transfer.

transferFrom

public void transferFrom(long offset,
                         Pointer other,
                         long otherOffset,
                         long count)
Description copied from class: Pointer
Bulk data transfer from one memory location to another.

Specified by:
transferFrom in class Pointer
Parameters:
offset - the offset from the start of the memory location this Pointer represents to begin copying to.
other - the destination memory location to transfer data from.
otherOffset - the offset from the start of the memory location the destination Pointer represents to begin copying from.
count - the number of bytes to transfer.


Copyright © 2012. All Rights Reserved.