Returns the offset of the given value in memory from the given offset,
or -1 if the value is not found.
Deprecated.
setString
(long offset,
WString
value)
Copy string
value
to the location being pointed to as a
wide string (
wchar_t*
).
(package private) void
setValue
(long offset,
Object
value,
Class
<?> type)
setWideString
(long offset,
String
value)
Copy string
value
to the location being pointed to as a
wide string (
wchar_t*
).
Pointer
share
(long offset)
Provide a view of this memory using the given offset to calculate a new base address.
Pointer
share
(long offset,
long sz)
Provide a view of this memory using the given offset to calculate a
new base address, bounds-limiting the memory with the given size.
String
toString
()
write
(long offset,
byte[] buf,
int index,
int length)
Indirect the native pointer, copying
into
memory pointed to by
native pointer, from the specified array.
write
(long offset,
char[] buf,
int index,
int length)
Indirect the native pointer, copying
into
memory pointed to by
native pointer, from the specified array.
write
(long offset,
double[] buf,
int index,
int length)
Indirect the native pointer, copying
into
memory pointed to by
native pointer, from the specified array.
write
(long offset,
float[] buf,
int index,
int length)
Indirect the native pointer, copying
into
memory pointed to by
native pointer, from the specified array.
write
(long offset,
int[] buf,
int index,
int length)
Indirect the native pointer, copying
into
memory pointed to by
native pointer, from the specified array.
write
(long offset,
long[] buf,
int index,
int length)
Indirect the native pointer, copying
into
memory pointed to by
native pointer, from the specified array.
write
(long bOff,
Pointer
[] buf,
int index,
int length)
Write the given array of Pointer to native memory.
write
(long offset,
short[] buf,
int index,
int length)
Indirect the native pointer, copying
into
memory pointed to by
native pointer, from the specified array.
Pointer
public Pointer(long peer)
Create from native pointer. Don't use this unless you know what
you're doing.
createConstant
public static final Pointer createConstant(int peer)
Convenience constant, equivalent to
(void*)CONSTANT
.
This version will avoid setting any of the high bits on 64-bit
systems.
public Pointer share(long offset,
long sz)
Provide a view of this memory using the given offset to calculate a
new base address, bounds-limiting the memory with the given size.
public long indexOf(long offset,
byte value)
Returns the offset of the given value in memory from the given offset,
or -1 if the value is not found.
int length)
Indirect the native pointer, copying
from
memory pointed to by
native pointer, into the specified array.
Parameters:
offset
- byte offset from pointer into which data is copied
buf
-
byte
array into which data is copied
index
- array index from which to start copying
length
- number of elements from native pointer that must be copied
int length)
Indirect the native pointer, copying
from
memory pointed to by
native pointer, into the specified array.
Parameters:
offset
- byte offset from pointer from which data is copied
buf
-
short
array into which data is copied
index
- array index to which data is copied
length
- number of elements from native pointer that must be copied
int length)
Indirect the native pointer, copying
from
memory pointed to by
native pointer, into the specified array.
Parameters:
offset
- byte offset from pointer from which data is copied
buf
-
char
array into which data is copied
index
- array index to which data is copied
length
- number of elements from native pointer that must be copied
int length)
Indirect the native pointer, copying
from
memory pointed to by
native pointer, into the specified array.
Parameters:
offset
- byte offset from pointer from which data is copied
buf
-
int
array into which data is copied
index
- array index to which data is copied
length
- number of elements from native pointer that must be copied
int length)
Indirect the native pointer, copying
from
memory pointed to by
native pointer, into the specified array.
Parameters:
offset
- byte offset from pointer from which data is copied
buf
-
long
array into which data is copied
index
- array index to which data is copied
length
- number of elements from native pointer that must be copied
int length)
Indirect the native pointer, copying
from
memory pointed to by
native pointer, into the specified array.
Parameters:
offset
- byte offset from pointer from which data is copied
buf
-
float
array into which data is copied
index
- array index to which data is copied
length
- number of elements from native pointer that must be copied
int length)
Indirect the native pointer, copying
from
memory pointed to by
native pointer, into the specified array.
Parameters:
offset
- byte offset from pointer from which data is copied
buf
-
double
array into which data is copied
index
- array index to which data is copied
length
- number of elements from native pointer that must be copied
int length)
Indirect the native pointer, copying
from
memory pointed to by
native pointer, into the specified array.
Parameters:
offset
- byte offset from pointer from which data is copied
buf
-
Pointer
array into which data is copied
index
- array index to which data is copied
length
- number of elements from native pointer that must be copied
int length)
Indirect the native pointer, copying
into
memory pointed to by
native pointer, from the specified array.
Parameters:
offset
- byte offset from pointer into which data is copied
buf
-
byte
array from which to copy
index
- array index from which to start copying
length
- number of elements from
buf
that must be
copied
int length)
Indirect the native pointer, copying
into
memory pointed to by
native pointer, from the specified array.
Parameters:
offset
- byte offset from pointer into which data is copied
buf
-
short
array from which to copy
index
- array index from which to start copying
length
- number of elements from
buf
that must be
copied
int length)
Indirect the native pointer, copying
into
memory pointed to by
native pointer, from the specified array.
Parameters:
offset
- byte offset from pointer into which data is copied
buf
-
char
array from which to copy
index
- array index from which to start copying
length
- number of elements from
buf
that must be
copied
int length)
Indirect the native pointer, copying
into
memory pointed to by
native pointer, from the specified array.
Parameters:
offset
- byte offset from pointer into which data is copied
buf
-
int
array from which to copy
index
- array index from which to start copying
length
- number of elements from
buf
that must be
copied
int length)
Indirect the native pointer, copying
into
memory pointed to by
native pointer, from the specified array.
Parameters:
offset
- byte offset from pointer into which data is copied
buf
-
long
array from which to copy
index
- array index from which to start copying
length
- number of elements from
buf
that must be
copied
int length)
Indirect the native pointer, copying
into
memory pointed to by
native pointer, from the specified array.
Parameters:
offset
- byte offset from pointer into which data is copied
buf
-
float
array from which to copy
index
- array index from which to start copying
length
- number of elements from
buf
that must be
copied
int length)
Indirect the native pointer, copying
into
memory pointed to by
native pointer, from the specified array.
Parameters:
offset
- byte offset from pointer into which data is copied
buf
-
double
array from which to copy
index
- array index from which to start copying
length
- number of elements from
buf
that must be
copied
Parameters:
bOff
- byte offset from pointer into which data is copied
buf
-
Pointer
array from which to copy
index
- array index from which to start copying
length
- number of elements from
buf
that must be
copied
getByte
public byte getByte(long offset)
Indirect the native pointer as a pointer to
byte
. This is
equivalent to the expression
*((jbyte *)((char *)Pointer + offset))
.
Parameters:
offset
- offset from pointer to perform the indirection
Returns:
the
byte
value being pointed to
getChar
public char getChar(long offset)
Indirect the native pointer as a pointer to
wchar_t
. This
is equivalent to the expression
*((wchar_t*)((char *)Pointer + offset))
.
Parameters:
offset
- offset from pointer to perform the indirection
Returns:
the
wchar_t
value being pointed to
getShort
public short getShort(long offset)
Indirect the native pointer as a pointer to
short
. This is
equivalent to the expression
*((jshort *)((char *)Pointer + offset))
.
Parameters:
offset
- byte offset from pointer to perform the indirection
Returns:
the
short
value being pointed to
getInt
public int getInt(long offset)
Indirect the native pointer as a pointer to
int
. This is
equivalent to the expression
*((jint *)((char *)Pointer + offset))
.
Parameters:
offset
- byte offset from pointer to perform the indirection
Returns:
the
int
value being pointed to
getLong
public long getLong(long offset)
Indirect the native pointer as a pointer to
long
. This is
equivalent to the expression
*((jlong *)((char *)Pointer + offset))
.
Parameters:
offset
- byte offset from pointer to perform the indirection
Returns:
the
long
value being pointed to
getNativeLong
public NativeLong getNativeLong(long offset)
Indirect the native pointer as a pointer to
long
. This is
equivalent to the expression
*((long *)((char *)Pointer + offset))
.
Parameters:
offset
- byte offset from pointer to perform the indirection
Returns:
the
long
value being pointed to
getFloat
public float getFloat(long offset)
Indirect the native pointer as a pointer to
float
. This is
equivalent to the expression
*((jfloat *)((char *)Pointer + offset))
.
Parameters:
offset
- byte offset from pointer to perform the indirection
Returns:
the
float
value being pointed to
getDouble
public double getDouble(long offset)
Indirect the native pointer as a pointer to
double
. This
is equivalent to the expression
*((jdouble *)((char *)Pointer + offset))
.
Parameters:
offset
- byte offset from pointer to perform the indirection
Returns:
the
double
value being pointed to
getPointer
public Pointer getPointer(long offset)
Indirect the native pointer as a pointer to pointer. This is equivalent
to the expression
*((void **)((char *)Pointer + offset))
.
Parameters:
offset
- byte offset from pointer to perform the indirection
Returns:
a
Pointer
equivalent of the pointer value
being pointed to, or
null
if the pointer value is
NULL
;
public ByteBuffer getByteBuffer(long offset,
long length)
Get a ByteBuffer mapped to the memory pointed to by the pointer,
ensuring the buffer uses native byte order.
Parameters:
offset
- byte offset from pointer to start the buffer
length
- Length of ByteBuffer
Returns:
a direct ByteBuffer that accesses the memory being pointed to,
public
String
getString(long offset,
boolean wide)
Deprecated.
Copy native memory to a Java String. If
wide
is true,
access the memory as an array of
wchar_t
, otherwise
as an array of
char
, using the default platform encoding.
Parameters:
offset
- byte offset from pointer to obtain the native string
v * @param wide whether to convert from a wide or standard C string
Returns:
the
String
value being pointed to
getString
public String getString(long offset)
Parameters:
offset
- byte offset from pointer to start reading bytes
Returns:
the
String
value being pointed to
public String getString(long offset,
String encoding)
Copy native memory to a Java String using the requested encoding.
Parameters:
offset
- byte offset from pointer to obtain the native string
encoding
- the desired encoding
Returns:
the
String
value being pointed to
public byte[] getByteArray(long offset,
int arraySize)
Read a native array of bytes of size
arraySize
from the
given
offset
from this
Pointer
.
public char[] getCharArray(long offset,
int arraySize)
Read a native array of wchar_t of size
arraySize
from the
given
offset
from this
Pointer
.
public short[] getShortArray(long offset,
int arraySize)
Read a native array of int16 of size
arraySize
from the
given
offset
from this
Pointer
.
public int[] getIntArray(long offset,
int arraySize)
Read a native array of int32 of size
arraySize
from the
given
offset
from this
Pointer
.
public long[] getLongArray(long offset,
int arraySize)
Read a native array of int64 of size
arraySize
from the
given
offset
from this
Pointer
.
public float[] getFloatArray(long offset,
int arraySize)
Read a native array of float of size
arraySize
from the
given
offset
from this
Pointer
.
public double[] getDoubleArray(long offset,
int arraySize)
Read a native array of double of size
arraySize
from the
given
offset
from this
Pointer
.
getPointerArray
public Pointer[] getPointerArray(long offset)
Returns an array of
Pointer
. The array length is
determined by a NULL-valued terminating element.
getStringArray
public String[] getStringArray(long offset)
Returns an array of
String
based on a native array
of
char *
. The array length is determined by a
NULL-valued terminating element.
The strings are decoded using the encoding returned by
Native.getDefaultStringEncoding()
.
public String[] getStringArray(long offset,
String encoding)
Returns an array of
String
based on a native array
of
char *
, using the requested encoding. The array length
is determined by a NULL-valued terminating element.
public String[] getStringArray(long offset,
int length)
Returns an array of
String
based on a native array
of
char *
, using the given array length.
The strings are decoded using the encoding returned by
Native.getDefaultStringEncoding()
.
public
String
[] getStringArray(long offset,
boolean wide)
Deprecated.
Returns an array of
String
based on a native array
of
char*
or
wchar_t*
based on the
wide
parameter. The array length is determined by a
NULL-valued terminating element.
int length,
boolean wide)
Deprecated.
Returns an array of
String
based on a native array
of
char*
or
wchar_t*
based on the
wide
parameter, using the given array length.
String
encoding)
Returns an array of
String
based on a native array
of
char*
or
wchar_t*
based on the
wide
parameter, using the given array length.
Parameters:
offset
-
length
-
encoding
-
public void setByte(long offset,
byte value)
Set
value
at location being pointed to. This is equivalent
to the expression
*((jbyte *)((char *)Pointer + offset)) = value
.
Parameters:
offset
- byte offset from pointer at which
value
must be set
value
-
byte
value to set
public void setShort(long offset,
short value)
Set
value
at location being pointed to. This is equivalent
to the expression
*((jshort *)((char *)Pointer + offset)) = value
.
Parameters:
offset
- byte offset from pointer at which
value
must be set
value
-
short
value to set
public void setChar(long offset,
char value)
Set
value
at location being pointed to. This is equivalent
to the expression
*((wchar_t *)((char *)Pointer + offset)) = value
.
Parameters:
offset
- byte offset from pointer at which
value
must be set
value
-
char
value to set
public void setInt(long offset,
int value)
Set
value
at location being pointed to. This is equivalent
to the expression
*((jint *)((char *)Pointer + offset)) = value
.
Parameters:
offset
- byte offset from pointer at which
value
must be set
value
-
int
value to set
public void setLong(long offset,
long value)
Set
value
at location being pointed to. This is equivalent
to the expression
*((jlong *)((char *)Pointer + offset)) = value
.
Parameters:
offset
- byte offset from pointer at which
value
must be set
value
-
long
value to set
public void setNativeLong(long offset,
NativeLong value)
Set
value
at location being pointed to. This is equivalent
to the expression
*((long *)((char *)Pointer + offset)) = value
.
Parameters:
offset
- byte offset from pointer at which
value
must be set
value
-
long
value to set
public void setFloat(long offset,
float value)
Set
value
at location being pointed to. This is equivalent
to the expression
*((jfloat *)((char *)Pointer + offset)) = value
.
Parameters:
offset
- byte offset from pointer at which
value
must be set
value
-
float
value to set
public void setDouble(long offset,
double value)
Set
value
at location being pointed to. This is equivalent
to the expression
*((jdouble *)((char *)Pointer + offset)) = value
.
Parameters:
offset
- byte offset from pointer at which
value
must be set
value
-
double
value to set
public void setPointer(long offset,
Pointer value)
Set
value
at location being pointed to. This is equivalent
to the expression
*((void **)((char *)Pointer + offset)) = value
.
Parameters:
offset
- byte offset from pointer at which
value
must be set
value
-
Pointer
holding the actual pointer value to
set, which may be
null
to indicate a
NULL
pointer.
boolean wide)
Deprecated.
Copy string
value
to the location being pointed to.
Parameters:
offset
- byte offset from pointer at which characters in
value
must be set
value
-
java.lang.String
value to set
wide
- whether to write the native string as an array of
wchar_t
. If false, writes as a NUL-terminated array of
char
using the encoding indicated by
Native.getDefaultStringEncoding()
.
public void setWideString(long offset,
String value)
Copy string
value
to the location being pointed to as a
wide string (
wchar_t*
).
Parameters:
offset
- byte offset from pointer at which characters in
value
must be set
value
-
java.lang.String
value to set
public void setString(long offset,
WString value)
Copy string
value
to the location being pointed to as a
wide string (
wchar_t*
).
Parameters:
offset
- byte offset from pointer at which characters in
value
must be set
value
-
WString
value to set
public void setString(long offset,
String value)
Parameters:
offset
- byte offset from pointer at which characters in
value
must be set
value
-
java.lang.String
value to set
String
encoding)
Copy string
value
to the location being pointed to, using
the requested encoding.
Parameters:
offset
- byte offset from pointer at which characters in
value
must be set
value
-
java.lang.String
value to set
encoding
- desired encoding