Package jnr.ffi.provider
Class BoundedMemoryIO
java.lang.Object
jnr.ffi.Pointer
jnr.ffi.provider.AbstractMemoryIO
jnr.ffi.provider.BoundedMemoryIO
- All Implemented Interfaces:
DelegatingMemoryIO
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal Objectarray()Returns the array that backs this pointer.final intReturns the length of this pointer's backing array that is used by this pointer.final intReturns the offset within this pointer's backing array of the first element.voidcheckBounds(long offset, long length) Checks that the memory region is within the bounds of this memory objectbooleanvoidget(long offset, byte[] dst, int off, int len) Bulk get method for multiplebytevalues.voidget(long offset, double[] dst, int off, int len) Bulk get method for multipledoublevalues.voidget(long offset, float[] dst, int off, int len) Bulk get method for multiplefloatvalues.voidget(long offset, int[] dst, int off, int len) Bulk get method for multipleintvalues.voidget(long offset, long[] dst, int off, int len) Bulk get method for multiplelongvalues.voidget(long offset, short[] dst, int off, int len) Bulk get method for multipleshortvalues.longgetAddress(long offset) Reads a native memory address value at the given offset.bytegetByte(long offset) Reads anbyte(8 bit) value at the given offset.doublegetDouble(long offset) Reads adouble(64 bit) value at the given offset.floatgetFloat(long offset) Reads afloat(32 bit) value at the given offset.intgetInt(long offset) Reads anint(32 bit) value at the given offset.longgetLongLong(long offset) Reads along(64 bit) value at the given offset.getPointer(long offset) Reads anPointervalue at the given offset.getPointer(long offset, long size) Reads anPointervalue at the given offset.shortgetShort(long offset) Reads ashort(16 bit) value at the given offset.getString(long offset) Reads anStringvalue at the given offset.Reads aStringvalue at the given offset, using a specificCharsetfinal booleanhasArray()Indicates whether thisPointerinstance is backed by an array.inthashCode()intindexOf(long offset, byte value) Returns the location of a byte value within the memory area represented by thisPointer.intindexOf(long offset, byte value, int maxlen) Returns the location of a byte value within the memory area represented by thisPointer.voidput(long offset, byte[] dst, int off, int len) Bulk put method for multiplebytevalues.voidput(long offset, double[] src, int off, int len) Bulk put method for multipledoublevalues.voidput(long offset, float[] src, int off, int len) Bulk put method for multiplefloatvalues.voidput(long offset, int[] src, int off, int len) Bulk put method for multipleintvalues.voidput(long offset, long[] src, int off, int len) Bulk put method for multiplelongvalues.voidput(long offset, short[] dst, int off, int len) Bulk put method for multipleshortvalues.voidputAddress(long offset, long value) Writes a native memory address value at the given offset.voidputAddress(long offset, Address value) Writes a native memory address value at the given offset.voidputByte(long offset, byte value) Writes abyte(8 bit) value at the given offset.voidputDouble(long offset, double value) Writes adouble(64 bit, double precision) value at the given offset.voidputFloat(long offset, float value) Writes afloat(32 bit, single precision) value at the given offset.voidputInt(long offset, int value) Writes anint(32 bit) value at the given offset.voidputLongLong(long offset, long value) Writes along(64 bit) value at the given offset.voidputPointer(long offset, Pointer value) Writes aPointervalue at the given offset.voidputShort(long offset, short value) Writes ashort(16 bit) value at the given offset.voidWrites aStringvalue at the given offset, using a specificCharsetvoidsetMemory(long offset, long size, byte value) Sets the value of each byte in the memory area represented by thisPointer.longsize()Gets the size of this memory object in bytes (optional operation).voidtransferFrom(long offset, Pointer other, long otherOffset, long count) Bulk data transfer from one memory location to another.voidtransferTo(long offset, Pointer other, long otherOffset, long count) Bulk data transfer from one memory location to another.Methods inherited from class jnr.ffi.provider.AbstractMemoryIO
checkBounds, getInt, getLong, getNativeLong, putInt, putLong, putNativeLong, slice, sliceMethods inherited from class jnr.ffi.Pointer
address, get, getNullTerminatedPointerArray, getNullTerminatedStringArray, getRuntime, isDirect, newIntPointer, put, toString, wrap, wrap, wrap
-
Constructor Details
-
BoundedMemoryIO
-
-
Method Details
-
size
public long size()Description copied from class:PointerGets the size of this memory object in bytes (optional operation).- Specified by:
sizein classPointer- Returns:
- the size of the memory area this
Pointerpoints to. If the size is unknown,Long.MAX_VALUEis returned}.
-
hasArray
public final boolean hasArray()Description copied from class:PointerIndicates whether thisPointerinstance is backed by an array. -
array
Description copied from class:PointerReturns the array that backs this pointer. -
arrayOffset
public final int arrayOffset()Description copied from class:PointerReturns the offset within this pointer's backing array of the first element.- Specified by:
arrayOffsetin classPointer- Returns:
- The offset of the first element on the backing array
-
arrayLength
public final int arrayLength()Description copied from class:PointerReturns the length of this pointer's backing array that is used by this pointer.- Specified by:
arrayLengthin classPointer- Returns:
- The length of the backing array used
-
checkBounds
public void checkBounds(long offset, long length) Description copied from class:PointerChecks that the memory region is within the bounds of this memory object- Overrides:
checkBoundsin classAbstractMemoryIO- Parameters:
offset- the starting point within this memory region.length- the length of the memory region in bytes
-
getDelegatedMemoryIO
- Specified by:
getDelegatedMemoryIOin interfaceDelegatingMemoryIO
-
hashCode
public int hashCode() -
equals
-
getByte
public byte getByte(long offset) Description copied from class:PointerReads anbyte(8 bit) value at the given offset. -
getShort
public short getShort(long offset) Description copied from class:PointerReads ashort(16 bit) value at the given offset. -
getInt
public int getInt(long offset) Description copied from class:PointerReads anint(32 bit) value at the given offset. -
getLongLong
public long getLongLong(long offset) Description copied from class:PointerReads along(64 bit) value at the given offset.- Specified by:
getLongLongin classPointer- Parameters:
offset- The offset from the start of the memory thisPointerrepresents at which the value will be read.- Returns:
- the
longvalue at the offset.
-
getFloat
public float getFloat(long offset) Description copied from class:PointerReads afloat(32 bit) value at the given offset. -
getDouble
public double getDouble(long offset) Description copied from class:PointerReads adouble(64 bit) value at the given offset. -
getPointer
Description copied from class:PointerReads anPointervalue at the given offset.- Specified by:
getPointerin classPointer- Parameters:
offset- the offset from the start of the memory thisPointerrepresents at which the value will be read.- Returns:
- the
Pointervalue read from memory.
-
getPointer
Description copied from class:PointerReads anPointervalue at the given offset.- Specified by:
getPointerin classPointer- Parameters:
offset- the offset from the start of the memory thisPointerrepresents at which the value will be read.size- the maximum size of the memory location the returnedPointerrepresents.- Returns:
- the
Pointervalue read from memory.
-
putByte
public void putByte(long offset, byte value) Description copied from class:PointerWrites abyte(8 bit) value at the given offset. -
putShort
public void putShort(long offset, short value) Description copied from class:PointerWrites ashort(16 bit) value at the given offset. -
putInt
public void putInt(long offset, int value) Description copied from class:PointerWrites anint(32 bit) value at the given offset. -
putLongLong
public void putLongLong(long offset, long value) Description copied from class:PointerWrites along(64 bit) value at the given offset.- Specified by:
putLongLongin classPointer- Parameters:
offset- The offset from the start of the memory thisPointerrepresents at which the value will be written.value- thelongvalue to be written.
-
putFloat
public void putFloat(long offset, float value) Description copied from class:PointerWrites afloat(32 bit, single precision) value at the given offset. -
putDouble
public void putDouble(long offset, double value) Description copied from class:PointerWrites adouble(64 bit, double precision) value at the given offset. -
putPointer
Description copied from class:PointerWrites aPointervalue at the given offset.- Specified by:
putPointerin classPointer- Parameters:
offset- The offset from the start of the memory thisPointerrepresents at which the value will be written.value- thePointervalue to be written to memory.
-
get
public void get(long offset, byte[] dst, int off, int len) Description copied from class:PointerBulk get method for multiplebytevalues. This method reads multiplebytevalues from consecutive addresses, beginning at the given offset, and stores them in an array.- Specified by:
getin classPointer- Parameters:
offset- the offset from the start of the memory thisPointerrepresents at which the first value will be read.dst- the array into which values are to be stored.off- the start index in thedstarray to begin storing the values.len- the number of values to be read.
-
put
public void put(long offset, byte[] dst, int off, int len) Description copied from class:PointerBulk put method for multiplebytevalues. This method writes multiplebytevalues to consecutive addresses, beginning at the given offset, from an array.- Specified by:
putin classPointer- Parameters:
offset- the offset from the start of the memory thisPointerrepresents at which the first value will be written.dst- the array to get values from.off- the start index in thedstarray to begin reading values.len- the number of values to be written.
-
get
public void get(long offset, short[] dst, int off, int len) Description copied from class:PointerBulk get method for multipleshortvalues. This method reads multipleshortvalues from consecutive addresses, beginning at the given offset, and stores them in an array.- Specified by:
getin classPointer- Parameters:
offset- The offset from the start of the memory thisPointerrepresents at which the first value will be read.dst- The array into which values are to be stored.off- the start index in thedstarray to begin storing the values.len- the number of values to be read.
-
put
public void put(long offset, short[] dst, int off, int len) Description copied from class:PointerBulk put method for multipleshortvalues. This method writes multipleshortvalues to consecutive addresses, beginning at the given offset, from an array.- Specified by:
putin classPointer- Parameters:
offset- the offset from the start of the memory thisPointerrepresents at which the first value will be written.dst- the array to get values from.off- the start index in thedstarray to begin reading values.len- the number of values to be written.
-
get
public void get(long offset, int[] dst, int off, int len) Description copied from class:PointerBulk get method for multipleintvalues. This method reads multipleintvalues from consecutive addresses, beginning at the given offset, and stores them in an array.- Specified by:
getin classPointer- Parameters:
offset- The offset from the start of the memory thisPointerrepresents at which the first value will be read.dst- The array into which values are to be stored.off- the start index in thedstarray to begin storing the values.len- the number of values to be read.
-
put
public void put(long offset, int[] src, int off, int len) Description copied from class:PointerBulk put method for multipleintvalues. This method writes multipleintvalues to consecutive addresses, beginning at the given offset, from an array.- Specified by:
putin classPointer- Parameters:
offset- the offset from the start of the memory thisPointerrepresents at which the first value will be written.src- the array to get values from.off- the start index in thedstarray to begin reading values.len- the number of values to be written.
-
get
public void get(long offset, long[] dst, int off, int len) Description copied from class:PointerBulk get method for multiplelongvalues. This method reads multiplelongvalues from consecutive addresses, beginning at the given offset, and stores them in an array.- Specified by:
getin classPointer- Parameters:
offset- The offset from the start of the memory thisPointerrepresents at which the first value will be read.dst- The array into which values are to be stored.off- the start index in thedstarray to begin storing the values.len- the number of values to be read.
-
put
public void put(long offset, long[] src, int off, int len) Description copied from class:PointerBulk put method for multiplelongvalues. This method writes multiplelongvalues to consecutive addresses, beginning at the given offset, from an array.- Specified by:
putin classPointer- Parameters:
offset- the offset from the start of the memory thisPointerrepresents at which the first value will be written.src- the array to get values from.off- the start index in thedstarray to begin reading values.len- the number of values to be written.
-
get
public void get(long offset, float[] dst, int off, int len) Description copied from class:PointerBulk get method for multiplefloatvalues. This method reads multiplefloatvalues from consecutive addresses, beginning at the given offset, and stores them in an array.- Specified by:
getin classPointer- Parameters:
offset- The offset from the start of the memory thisPointerrepresents at which the first value will be read.dst- The array into which values are to be stored.off- the start index in thedstarray to begin storing the values.len- the number of values to be read.
-
put
public void put(long offset, float[] src, int off, int len) Description copied from class:PointerBulk put method for multiplefloatvalues. This method writes multiplefloatvalues to consecutive addresses, beginning at the given offset, from an array.- Specified by:
putin classPointer- Parameters:
offset- the offset from the start of the memory thisPointerrepresents at which the first value will be written.src- the array to get values from.off- the start index in thedstarray to begin reading values.len- the number of values to be written.
-
get
public void get(long offset, double[] dst, int off, int len) Description copied from class:PointerBulk get method for multipledoublevalues. This method reads multipledoublevalues from consecutive addresses, beginning at the given offset, and stores them in an array.- Specified by:
getin classPointer- Parameters:
offset- The offset from the start of the memory thisPointerrepresents at which the first value will be read.dst- The array into which values are to be stored.off- the start index in thedstarray to begin storing the values.len- the number of values to be read.
-
put
public void put(long offset, double[] src, int off, int len) Description copied from class:PointerBulk put method for multipledoublevalues. This method writes multipledoublevalues to consecutive addresses, beginning at the given offset, from an array.- Specified by:
putin classPointer- Parameters:
offset- the offset from the start of the memory thisPointerrepresents at which the first value will be written.src- the array to get values from.off- the start index in thedstarray to begin reading values.len- the number of values to be written.
-
getAddress
public long getAddress(long offset) Description copied from class:PointerReads a native memory address value at the given offset.A native address can be either 32 or 64 bits in size, depending on the cpu architecture.
- Overrides:
getAddressin classAbstractMemoryIO- Parameters:
offset- The offset from the start of the memory thisPointerrepresents at which the value will be read.- Returns:
- the native address value contained in the memory at the offset
- See Also:
-
getString
Description copied from class:PointerReads aStringvalue at the given offset, using a specificCharset- Specified by:
getStringin classPointer- Parameters:
offset- the offset from the start of the memory thisPointerrepresents at which the value will be read.maxLength- the maximum size of memory to search for a NUL byte.cs- theCharsetto use to decode the string.- Returns:
- the
Stringvalue read from memory.
-
getString
Description copied from class:PointerReads anStringvalue at the given offset. -
putAddress
public void putAddress(long offset, long value) Description copied from class:PointerWrites a native memory address value at the given offset.A native address can be either 32 or 64 bits in size, depending on the cpu architecture.
- Overrides:
putAddressin classAbstractMemoryIO- Parameters:
offset- The offset from the start of the memory thisPointerrepresents at which the value will be written.value- The native address value to be written.- See Also:
-
putAddress
Description copied from class:PointerWrites a native memory address value at the given offset.A native address can be either 32 or 64 bits in size, depending on the cpu architecture.
- Overrides:
putAddressin classAbstractMemoryIO- Parameters:
offset- The offset from the start of the memory thisPointerrepresents at which the value will be written.value- The native address value to be written.- See Also:
-
putString
Description copied from class:PointerWrites aStringvalue at the given offset, using a specificCharset- Specified by:
putStringin classPointer- Parameters:
offset- the offset from the start of the memory thisPointerrepresents at which the value will be written.string- the string to be written.maxLength- the maximum size of memory to use to store the string.cs- theCharsetto use to decode the string.
-
indexOf
public int indexOf(long offset, byte value) Description copied from class:PointerReturns the location of a byte value within the memory area represented by thisPointer.- Overrides:
indexOfin classAbstractMemoryIO- Parameters:
offset- the offset from the start of the memory location thisPointerrepresents to begin searching.value- thebytevalue to locate.- Returns:
- the offset from the start of the search area (i.e. relative to the offset parameter), or -1 if not found.
-
indexOf
public int indexOf(long offset, byte value, int maxlen) Description copied from class:PointerReturns the location of a byte value within the memory area represented by thisPointer.- Specified by:
indexOfin classPointer- Parameters:
offset- the offset from the start of the memory location thisPointerrepresents to begin searching.value- thebytevalue to locate.maxlen- the maximum number of bytes to search for the desired value.- Returns:
- the offset from the start of the search area (i.e. relative to the offset parameter), or -1 if not found.
-
setMemory
public void setMemory(long offset, long size, byte value) Description copied from class:PointerSets the value of each byte in the memory area represented by thisPointer. to a specified value. -
transferFrom
Description copied from class:PointerBulk data transfer from one memory location to another.- Overrides:
transferFromin classAbstractMemoryIO- Parameters:
offset- the offset from the start of the memory location thisPointerrepresents to begin copying to.other- the destination memory location to transfer data from.otherOffset- the offset from the start of the memory location the destinationPointerrepresents to begin copying from.count- the number of bytes to transfer.
-
transferTo
Description copied from class:PointerBulk data transfer from one memory location to another.- Overrides:
transferToin classAbstractMemoryIO- Parameters:
offset- the offset from the start of the memory location thisPointerrepresents to begin copying from.other- the destination memory location to transfer data to.otherOffset- the offset from the start of the memory location the destinationPointerrepresents to begin copying to.count- the number of bytes to transfer.
-