Package jnr.ffi.provider
Class BoundedMemoryIO
- java.lang.Object
-
- jnr.ffi.Pointer
-
- jnr.ffi.provider.AbstractMemoryIO
-
- jnr.ffi.provider.BoundedMemoryIO
-
- All Implemented Interfaces:
DelegatingMemoryIO
public final class BoundedMemoryIO extends AbstractMemoryIO implements DelegatingMemoryIO
-
-
Constructor Summary
Constructors Constructor Description BoundedMemoryIO(Pointer parent, long offset, long size)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
array()
Returns the array that backs this pointer.int
arrayLength()
Returns the length of this pointer's backing array that is used by this pointer.int
arrayOffset()
Returns the offset within this pointer's backing array of the first element.void
checkBounds(long offset, long length)
Checks that the memory region is within the bounds of this memory objectboolean
equals(java.lang.Object obj)
void
get(long offset, byte[] dst, int off, int len)
Bulk get method for multiplebyte
values.void
get(long offset, double[] dst, int off, int len)
Bulk get method for multipledouble
values.void
get(long offset, float[] dst, int off, int len)
Bulk get method for multiplefloat
values.void
get(long offset, int[] dst, int off, int len)
Bulk get method for multipleint
values.void
get(long offset, long[] dst, int off, int len)
Bulk get method for multiplelong
values.void
get(long offset, short[] dst, int off, int len)
Bulk get method for multipleshort
values.long
getAddress(long offset)
Reads a native memory address value at the given offset.byte
getByte(long offset)
Reads anbyte
(8 bit) value at the given offset.Pointer
getDelegatedMemoryIO()
double
getDouble(long offset)
Reads adouble
(64 bit) value at the given offset.float
getFloat(long offset)
Reads afloat
(32 bit) value at the given offset.int
getInt(long offset)
Reads anint
(32 bit) value at the given offset.long
getLongLong(long offset)
Reads along
(64 bit) value at the given offset.Pointer
getPointer(long offset)
Reads anPointer
value at the given offset.Pointer
getPointer(long offset, long size)
Reads anPointer
value at the given offset.short
getShort(long offset)
Reads ashort
(16 bit) value at the given offset.java.lang.String
getString(long offset)
Reads anString
value at the given offset.java.lang.String
getString(long offset, int maxLength, java.nio.charset.Charset cs)
Reads aString
value at the given offset, using a specificCharset
boolean
hasArray()
Indicates whether thisPointer
instance is backed by an array.int
hashCode()
int
indexOf(long offset, byte value)
Returns the location of a byte value within the memory area represented by thisPointer
.int
indexOf(long offset, byte value, int maxlen)
Returns the location of a byte value within the memory area represented by thisPointer
.void
put(long offset, byte[] dst, int off, int len)
Bulk put method for multiplebyte
values.void
put(long offset, double[] src, int off, int len)
Bulk put method for multipledouble
values.void
put(long offset, float[] src, int off, int len)
Bulk put method for multiplefloat
values.void
put(long offset, int[] src, int off, int len)
Bulk put method for multipleint
values.void
put(long offset, long[] src, int off, int len)
Bulk put method for multiplelong
values.void
put(long offset, short[] dst, int off, int len)
Bulk put method for multipleshort
values.void
putAddress(long offset, long value)
Writes a native memory address value at the given offset.void
putAddress(long offset, Address value)
Writes a native memory address value at the given offset.void
putByte(long offset, byte value)
Writes abyte
(8 bit) value at the given offset.void
putDouble(long offset, double value)
Writes adouble
(64 bit, double precision) value at the given offset.void
putFloat(long offset, float value)
Writes afloat
(32 bit, single precision) value at the given offset.void
putInt(long offset, int value)
Writes anint
(32 bit) value at the given offset.void
putLongLong(long offset, long value)
Writes along
(64 bit) value at the given offset.void
putPointer(long offset, Pointer value)
Writes aPointer
value at the given offset.void
putShort(long offset, short value)
Writes ashort
(16 bit) value at the given offset.void
putString(long offset, java.lang.String string, int maxLength, java.nio.charset.Charset cs)
Writes aString
value at the given offset, using a specificCharset
void
setMemory(long offset, long size, byte value)
Sets the value of each byte in the memory area represented by thisPointer
.long
size()
Gets the size of this memory object in bytes (optional operation).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.provider.AbstractMemoryIO
checkBounds, getInt, getLong, getNativeLong, putInt, putLong, putNativeLong, slice, slice
-
Methods inherited from class jnr.ffi.Pointer
address, get, getNullTerminatedPointerArray, getNullTerminatedStringArray, getRuntime, isDirect, newIntPointer, put, toString, wrap, wrap, wrap
-
-
-
-
Constructor Detail
-
BoundedMemoryIO
public BoundedMemoryIO(Pointer parent, long offset, long size)
-
-
Method Detail
-
size
public long size()
Description copied from class:Pointer
Gets the size of this memory object in bytes (optional operation).
-
hasArray
public final boolean hasArray()
Description copied from class:Pointer
Indicates whether thisPointer
instance is backed by an array.
-
array
public final java.lang.Object array()
Description copied from class:Pointer
Returns the array that backs this pointer.
-
arrayOffset
public final int arrayOffset()
Description copied from class:Pointer
Returns the offset within this pointer's backing array of the first element.- Specified by:
arrayOffset
in classPointer
- Returns:
- The offset of the first element on the backing array
-
arrayLength
public final int arrayLength()
Description copied from class:Pointer
Returns the length of this pointer's backing array that is used by this pointer.- Specified by:
arrayLength
in classPointer
- Returns:
- The length of the backing array used
-
checkBounds
public void checkBounds(long offset, long length)
Description copied from class:Pointer
Checks that the memory region is within the bounds of this memory object- Overrides:
checkBounds
in classAbstractMemoryIO
- Parameters:
offset
- the starting point within this memory region.length
- the length of the memory region in bytes
-
getDelegatedMemoryIO
public Pointer getDelegatedMemoryIO()
- Specified by:
getDelegatedMemoryIO
in interfaceDelegatingMemoryIO
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
getByte
public byte getByte(long offset)
Description copied from class:Pointer
Reads anbyte
(8 bit) value at the given offset.
-
getShort
public short getShort(long offset)
Description copied from class:Pointer
Reads ashort
(16 bit) value at the given offset.
-
getInt
public int getInt(long offset)
Description copied from class:Pointer
Reads anint
(32 bit) value at the given offset.
-
getLongLong
public long getLongLong(long offset)
Description copied from class:Pointer
Reads along
(64 bit) value at the given offset.- Specified by:
getLongLong
in classPointer
- Parameters:
offset
- The offset from the start of the memory thisPointer
represents at which the value will be read.- Returns:
- the
long
value at the offset.
-
getFloat
public float getFloat(long offset)
Description copied from class:Pointer
Reads afloat
(32 bit) value at the given offset.
-
getDouble
public double getDouble(long offset)
Description copied from class:Pointer
Reads adouble
(64 bit) value at the given offset.
-
getPointer
public Pointer getPointer(long offset)
Description copied from class:Pointer
Reads anPointer
value at the given offset.- Specified by:
getPointer
in classPointer
- Parameters:
offset
- the offset from the start of the memory thisPointer
represents at which the value will be read.- Returns:
- the
Pointer
value read from memory.
-
getPointer
public Pointer getPointer(long offset, long size)
Description copied from class:Pointer
Reads anPointer
value at the given offset.- Specified by:
getPointer
in classPointer
- Parameters:
offset
- the offset from the start of the memory thisPointer
represents at which the value will be read.size
- the maximum size of the memory location the returnedPointer
represents.- Returns:
- the
Pointer
value read from memory.
-
putByte
public void putByte(long offset, byte value)
Description copied from class:Pointer
Writes abyte
(8 bit) value at the given offset.
-
putShort
public void putShort(long offset, short value)
Description copied from class:Pointer
Writes ashort
(16 bit) value at the given offset.
-
putInt
public void putInt(long offset, int value)
Description copied from class:Pointer
Writes anint
(32 bit) value at the given offset.
-
putLongLong
public void putLongLong(long offset, long value)
Description copied from class:Pointer
Writes along
(64 bit) value at the given offset.- Specified by:
putLongLong
in classPointer
- Parameters:
offset
- The offset from the start of the memory thisPointer
represents at which the value will be written.value
- thelong
value to be written.
-
putFloat
public void putFloat(long offset, float value)
Description copied from class:Pointer
Writes afloat
(32 bit, single precision) value at the given offset.
-
putDouble
public void putDouble(long offset, double value)
Description copied from class:Pointer
Writes adouble
(64 bit, double precision) value at the given offset.
-
putPointer
public void putPointer(long offset, Pointer value)
Description copied from class:Pointer
Writes aPointer
value at the given offset.- Specified by:
putPointer
in classPointer
- Parameters:
offset
- The offset from the start of the memory thisPointer
represents at which the value will be written.value
- thePointer
value to be written to memory.
-
get
public void get(long offset, byte[] dst, int off, int len)
Description copied from class:Pointer
Bulk get method for multiplebyte
values. This method reads multiplebyte
values from consecutive addresses, beginning at the given offset, and stores them in an array.- Specified by:
get
in classPointer
- Parameters:
offset
- the offset from the start of the memory thisPointer
represents at which the first value will be read.dst
- the array into which values are to be stored.off
- the start index in thedst
array 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:Pointer
Bulk put method for multiplebyte
values. This method writes multiplebyte
values to consecutive addresses, beginning at the given offset, from an array.- Specified by:
put
in classPointer
- Parameters:
offset
- the offset from the start of the memory thisPointer
represents at which the first value will be written.dst
- the array to get values from.off
- the start index in thedst
array 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:Pointer
Bulk get method for multipleshort
values. This method reads multipleshort
values from consecutive addresses, beginning at the given offset, and stores them in an array.- Specified by:
get
in classPointer
- Parameters:
offset
- The offset from the start of the memory thisPointer
represents at which the first value will be read.dst
- The array into which values are to be stored.off
- the start index in thedst
array 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:Pointer
Bulk put method for multipleshort
values. This method writes multipleshort
values to consecutive addresses, beginning at the given offset, from an array.- Specified by:
put
in classPointer
- Parameters:
offset
- the offset from the start of the memory thisPointer
represents at which the first value will be written.dst
- the array to get values from.off
- the start index in thedst
array 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:Pointer
Bulk get method for multipleint
values. This method reads multipleint
values from consecutive addresses, beginning at the given offset, and stores them in an array.- Specified by:
get
in classPointer
- Parameters:
offset
- The offset from the start of the memory thisPointer
represents at which the first value will be read.dst
- The array into which values are to be stored.off
- the start index in thedst
array 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:Pointer
Bulk put method for multipleint
values. This method writes multipleint
values to consecutive addresses, beginning at the given offset, from an array.- Specified by:
put
in classPointer
- Parameters:
offset
- the offset from the start of the memory thisPointer
represents at which the first value will be written.src
- the array to get values from.off
- the start index in thedst
array 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:Pointer
Bulk get method for multiplelong
values. This method reads multiplelong
values from consecutive addresses, beginning at the given offset, and stores them in an array.- Specified by:
get
in classPointer
- Parameters:
offset
- The offset from the start of the memory thisPointer
represents at which the first value will be read.dst
- The array into which values are to be stored.off
- the start index in thedst
array 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:Pointer
Bulk put method for multiplelong
values. This method writes multiplelong
values to consecutive addresses, beginning at the given offset, from an array.- Specified by:
put
in classPointer
- Parameters:
offset
- the offset from the start of the memory thisPointer
represents at which the first value will be written.src
- the array to get values from.off
- the start index in thedst
array 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:Pointer
Bulk get method for multiplefloat
values. This method reads multiplefloat
values from consecutive addresses, beginning at the given offset, and stores them in an array.- Specified by:
get
in classPointer
- Parameters:
offset
- The offset from the start of the memory thisPointer
represents at which the first value will be read.dst
- The array into which values are to be stored.off
- the start index in thedst
array 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:Pointer
Bulk put method for multiplefloat
values. This method writes multiplefloat
values to consecutive addresses, beginning at the given offset, from an array.- Specified by:
put
in classPointer
- Parameters:
offset
- the offset from the start of the memory thisPointer
represents at which the first value will be written.src
- the array to get values from.off
- the start index in thedst
array 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:Pointer
Bulk get method for multipledouble
values. This method reads multipledouble
values from consecutive addresses, beginning at the given offset, and stores them in an array.- Specified by:
get
in classPointer
- Parameters:
offset
- The offset from the start of the memory thisPointer
represents at which the first value will be read.dst
- The array into which values are to be stored.off
- the start index in thedst
array 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:Pointer
Bulk put method for multipledouble
values. This method writes multipledouble
values to consecutive addresses, beginning at the given offset, from an array.- Specified by:
put
in classPointer
- Parameters:
offset
- the offset from the start of the memory thisPointer
represents at which the first value will be written.src
- the array to get values from.off
- the start index in thedst
array to begin reading values.len
- the number of values to be written.
-
getAddress
public long getAddress(long offset)
Description copied from class:Pointer
Reads 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:
getAddress
in classAbstractMemoryIO
- Parameters:
offset
- The offset from the start of the memory thisPointer
represents at which the value will be read.- Returns:
- the native address value contained in the memory at the offset
- See Also:
Address
-
getString
public java.lang.String getString(long offset, int maxLength, java.nio.charset.Charset cs)
Description copied from class:Pointer
Reads aString
value at the given offset, using a specificCharset
- Specified by:
getString
in classPointer
- Parameters:
offset
- the offset from the start of the memory thisPointer
represents at which the value will be read.maxLength
- the maximum size of memory to search for a NUL byte.cs
- theCharset
to use to decode the string.- Returns:
- the
String
value read from memory.
-
getString
public java.lang.String getString(long offset)
Description copied from class:Pointer
Reads anString
value at the given offset.
-
putAddress
public void putAddress(long offset, long value)
Description copied from class:Pointer
Writes 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:
putAddress
in classAbstractMemoryIO
- Parameters:
offset
- The offset from the start of the memory thisPointer
represents at which the value will be written.value
- The native address value to be written.- See Also:
Address
-
putAddress
public void putAddress(long offset, Address value)
Description copied from class:Pointer
Writes 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:
putAddress
in classAbstractMemoryIO
- Parameters:
offset
- The offset from the start of the memory thisPointer
represents at which the value will be written.value
- The native address value to be written.- See Also:
Address
-
putString
public void putString(long offset, java.lang.String string, int maxLength, java.nio.charset.Charset cs)
Description copied from class:Pointer
Writes aString
value at the given offset, using a specificCharset
- Specified by:
putString
in classPointer
- Parameters:
offset
- the offset from the start of the memory thisPointer
represents 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
- theCharset
to use to decode the string.
-
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 thisPointer
.- Overrides:
indexOf
in classAbstractMemoryIO
- Parameters:
offset
- the offset from the start of the memory location thisPointer
represents to begin searching.value
- thebyte
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.
-
indexOf
public int indexOf(long offset, byte value, int maxlen)
Description copied from class:Pointer
Returns the location of a byte value within the memory area represented by thisPointer
.- Specified by:
indexOf
in classPointer
- Parameters:
offset
- the offset from the start of the memory location thisPointer
represents to begin searching.value
- thebyte
value 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:Pointer
Sets the value of each byte in the memory area represented by thisPointer
. to a specified value.
-
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.- Overrides:
transferFrom
in classAbstractMemoryIO
- Parameters:
offset
- the offset from the start of the memory location thisPointer
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 destinationPointer
represents to begin copying from.count
- the number of bytes to transfer.
-
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.- Overrides:
transferTo
in classAbstractMemoryIO
- Parameters:
offset
- the offset from the start of the memory location thisPointer
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 destinationPointer
represents to begin copying to.count
- the number of bytes to transfer.
-
-