public class BytePointer extends Pointer
signed char, including strings.
All operations take into account the position and limit, when appropriate.Pointer.CustomDeallocator, Pointer.Deallocator, Pointer.DeallocatorReference, Pointer.DeallocatorThread, Pointer.NativeDeallocatoraddress, capacity, deallocatorThread, limit, maxBytes, maxPhysicalBytes, maxRetries, position| Constructor and Description |
|---|
BytePointer() |
BytePointer(byte... array)
Allocates enough memory for the array and copies it.
|
BytePointer(ByteBuffer buffer)
For direct buffers, calls
Pointer.Pointer(Buffer), while for buffers
backed with an array, allocates enough memory for the array and copies it. |
BytePointer(long size)
Allocates a native
signed char array of the given size. |
BytePointer(Pointer p) |
BytePointer(String s)
Allocates enough memory for the encoded string and actually encodes it
in the platform's default charset before copying it.
|
BytePointer(String s,
String charsetName)
Allocates enough memory for the encoded string and actually encodes it
in the named charset before copying it.
|
| Modifier and Type | Method and Description |
|---|---|
private void |
allocateArray(long size) |
ByteBuffer |
asBuffer()
Same as
Pointer.asByteBuffer(), but can be overridden to return subclasses of Buffer. |
BytePointer |
capacity(long capacity)
Sets the capacity and returns this.
|
byte |
get() |
BytePointer |
get(byte[] array) |
BytePointer |
get(byte[] array,
int offset,
int length)
Reads a portion of the native array into a Java array.
|
byte |
get(long i) |
boolean |
getBool()
Returns
getBool(0). |
boolean |
getBool(long i)
Returns the
bool value at the i-th byte in the native array. |
char |
getChar()
Returns
getChar(0). |
char |
getChar(long i)
Returns the
char value at the i-th byte in the native array. |
double |
getDouble()
Returns
getDouble(0). |
double |
getDouble(long i)
Returns the
double value at the i-th byte in the native array. |
float |
getFloat()
Returns
getFloat(0). |
float |
getFloat(long i)
Returns the
float value at the i-th byte in the native array. |
int |
getInt()
Returns
getInt(0). |
int |
getInt(long i)
Returns the
int value at the i-th byte in the native array. |
long |
getLong()
Returns
getLong(0). |
long |
getLong(long i)
Returns the
long value at the i-th byte in the native array. |
Pointer |
getPointer()
Returns
getPointer(0). |
Pointer |
getPointer(long i)
Returns the
Pointer value at the i-th byte in the native array. |
short |
getShort()
Returns
getShort(0). |
short |
getShort(long i)
Returns the
short value at the i-th byte in the native array. |
String |
getString()
Decodes the native bytes assuming they are encoded in the platform's default charset.
|
String |
getString(String charsetName)
Decodes the native bytes assuming they are encoded in the named charset.
|
byte[] |
getStringBytes()
Returns the bytes, assuming a null-terminated string if
limit <= position. |
BytePointer |
limit(long limit)
Sets the limit and returns this.
|
BytePointer |
position(long position)
Sets the position and returns this.
|
BytePointer |
put(byte... array) |
BytePointer |
put(byte b) |
BytePointer |
put(byte[] array,
int offset,
int length)
Writes a portion of a Java array into the native array.
|
BytePointer |
put(long i,
byte b)
Copies the
byte value to the i-th element of a native array. |
BytePointer |
putBool(boolean b)
Returns
putBool(0, s). |
BytePointer |
putBool(long i,
boolean b)
Sets the
bool value at the i-th byte in the native array. |
BytePointer |
putChar(char c)
Returns
putChar(0, s). |
BytePointer |
putChar(long i,
char c)
Sets the
char value at the i-th byte in the native array. |
BytePointer |
putDouble(double d)
Returns
putDouble(0, s). |
BytePointer |
putDouble(long i,
double d)
Sets the
double value at the i-th byte in the native array. |
BytePointer |
putFloat(float f)
Returns
putFloat(0, s). |
BytePointer |
putFloat(long i,
float f)
Sets the
float value at the i-th byte in the native array. |
BytePointer |
putInt(int j)
Returns
putInt(0, s). |
BytePointer |
putInt(long i,
int j)
Sets the
int value at the i-th byte in the native array. |
BytePointer |
putLong(long j)
Returns
putLong(0, s). |
BytePointer |
putLong(long i,
long j)
Sets the
long value at the i-th byte in the native array. |
BytePointer |
putPointer(long i,
Pointer p)
Sets the
Pointer value at the i-th byte in the native array. |
BytePointer |
putPointer(Pointer p)
Returns
putPointer(0, s). |
BytePointer |
putShort(long i,
short s)
Sets the
short value at the i-th byte in the native array. |
BytePointer |
putShort(short s)
Returns
putShort(0, s). |
BytePointer |
putString(String s)
Encodes the String into the platform's default charset and copies it in
native memory, including a terminating null byte.
|
BytePointer |
putString(String s,
String charsetName)
Encodes the String into the named charset and copies it in native memory,
including a terminating null byte.
|
static BytePointer |
strcat(BytePointer dst,
BytePointer src) |
static BytePointer |
strchr(BytePointer str,
int ch) |
static int |
strcmp(BytePointer str1,
BytePointer str2) |
static int |
strcoll(BytePointer str1,
BytePointer str2) |
static BytePointer |
strcpy(BytePointer dst,
BytePointer src) |
static long |
strcspn(BytePointer str1,
BytePointer str2) |
static BytePointer |
strerror(int errnum) |
static long |
strlen(BytePointer str) |
static BytePointer |
strncat(BytePointer dst,
BytePointer src,
long n) |
static int |
strncmp(BytePointer str1,
BytePointer str2,
long n) |
static BytePointer |
strncpy(BytePointer dst,
BytePointer src,
long n) |
static BytePointer |
strpbrk(BytePointer str1,
BytePointer str2) |
static BytePointer |
strrchr(BytePointer str,
int ch) |
static long |
strspn(BytePointer str1,
BytePointer str2) |
static BytePointer |
strstr(BytePointer str1,
BytePointer str2) |
static BytePointer |
strtok(BytePointer str,
BytePointer delim) |
static long |
strxfrm(BytePointer dst,
BytePointer src,
long n) |
address, asByteBuffer, availablePhysicalBytes, calloc, capacity, close, deallocate, deallocate, deallocateReferences, deallocator, deallocator, equals, fill, formatBytes, free, hashCode, init, isNull, limit, malloc, maxBytes, maxPhysicalBytes, memchr, memcmp, memcpy, memmove, memset, offsetof, parseBytes, physicalBytes, position, put, realloc, setNull, sizeof, toString, totalBytes, totalPhysicalBytes, withDeallocator, zeropublic BytePointer(String s, String charsetName) throws UnsupportedEncodingException
s - the String to encode and copycharsetName - the charset in which the bytes are encodedUnsupportedEncodingExceptionputString(String, String)public BytePointer(String s)
s - the String to encode and copyputString(String)public BytePointer(byte... array)
array - the array to copyput(byte[])public BytePointer(ByteBuffer buffer)
Pointer.Pointer(Buffer), while for buffers
backed with an array, allocates enough memory for the array and copies it.buffer - the Buffer to reference or copyput(byte[])public BytePointer(long size)
signed char array of the given size.size - the number of signed char elements to allocatepublic BytePointer()
Pointer.Pointer()public BytePointer(Pointer p)
Pointer.Pointer(Pointer)private void allocateArray(long size)
public BytePointer position(long position)
Pointerarray.position(i)
statement sort of equivalent to the array[i] statement in C++.position in class Pointerposition - the new positionPointer.position(long)public BytePointer limit(long limit)
Pointerlimit in class Pointerlimit - the new limitPointer.limit(long)public BytePointer capacity(long capacity)
Pointercapacity in class Pointercapacity - the new capacityPointer.capacity(long)public byte[] getStringBytes()
limit <= position.public String getString(String charsetName) throws UnsupportedEncodingException
limit <= position.charsetName - the charset in which the bytes are encodedUnsupportedEncodingExceptionpublic String getString()
limit <= position.public BytePointer putString(String s, String charsetName) throws UnsupportedEncodingException
s - the String to encode and copycharsetName - the charset in which to encode the bytesUnsupportedEncodingExceptionString.getBytes(String),
put(byte[])public BytePointer putString(String s)
s - the String to encode and copyString.getBytes(),
put(byte[])public byte get()
get(0)public byte get(long i)
byte value of a native arraypublic BytePointer put(byte b)
put(0, b)public BytePointer put(long i, byte b)
byte value to the i-th element of a native array.i - the index into the arrayb - the byte value to copypublic BytePointer get(byte[] array)
get(array, 0, array.length)public BytePointer put(byte... array)
put(array, 0, array.length)public BytePointer get(byte[] array, int offset, int length)
array - the array to write tooffset - the offset into the array where to start writinglength - the length of data to read and writepublic BytePointer put(byte[] array, int offset, int length)
array - the array to read fromoffset - the offset into the array where to start readinglength - the length of data to read and writepublic final ByteBuffer asBuffer()
PointerPointer.asByteBuffer(), but can be overridden to return subclasses of Buffer.asBuffer in class PointerasByteBuffer()asBuffer(),
ShortPointer.asBuffer(),
IntPointer.asBuffer(),
LongPointer.asBuffer(),
FloatPointer.asBuffer(),
DoublePointer.asBuffer(),
CharPointer.asBuffer()public short getShort()
getShort(0).@ValueGetter @Cast(value="short") public short getShort(long i)
short value at the i-th byte in the native array.public BytePointer putShort(short s)
putShort(0, s).@ValueSetter @Cast(value="short") public BytePointer putShort(long i, short s)
short value at the i-th byte in the native array.public int getInt()
getInt(0).@ValueGetter @Cast(value="int") public int getInt(long i)
int value at the i-th byte in the native array.public BytePointer putInt(int j)
putInt(0, s).@ValueSetter @Cast(value="int") public BytePointer putInt(long i, int j)
int value at the i-th byte in the native array.public long getLong()
getLong(0).@ValueGetter @Cast(value="long long") public long getLong(long i)
long value at the i-th byte in the native array.public BytePointer putLong(long j)
putLong(0, s).@ValueSetter @Cast(value="long long") public BytePointer putLong(long i, long j)
long value at the i-th byte in the native array.public float getFloat()
getFloat(0).@ValueGetter @Cast(value="float") public float getFloat(long i)
float value at the i-th byte in the native array.public BytePointer putFloat(float f)
putFloat(0, s).@ValueSetter @Cast(value="float") public BytePointer putFloat(long i, float f)
float value at the i-th byte in the native array.public double getDouble()
getDouble(0).@ValueGetter @Cast(value="double") public double getDouble(long i)
double value at the i-th byte in the native array.public BytePointer putDouble(double d)
putDouble(0, s).@ValueSetter @Cast(value="double") public BytePointer putDouble(long i, double d)
double value at the i-th byte in the native array.public boolean getBool()
getBool(0).@ValueGetter @Cast(value="bool") public boolean getBool(long i)
bool value at the i-th byte in the native array.public BytePointer putBool(boolean b)
putBool(0, s).@ValueSetter @Cast(value="bool") public BytePointer putBool(long i, boolean b)
bool value at the i-th byte in the native array.public char getChar()
getChar(0).@ValueGetter @Cast(value="short") public char getChar(long i)
char value at the i-th byte in the native array.public BytePointer putChar(char c)
putChar(0, s).@ValueSetter @Cast(value="short") public BytePointer putChar(long i, char c)
char value at the i-th byte in the native array.public Pointer getPointer()
getPointer(0).@ValueGetter @Cast(value="void*") public Pointer getPointer(long i)
Pointer value at the i-th byte in the native array.public BytePointer putPointer(Pointer p)
putPointer(0, s).@ValueSetter @Cast(value="void*") public BytePointer putPointer(long i, Pointer p)
Pointer value at the i-th byte in the native array.@Cast(value="char*") public static BytePointer strcat(@Cast(value="char*") BytePointer dst, @Cast(value="char*") BytePointer src)
@Cast(value="char*") public static BytePointer strchr(@Cast(value="char*") BytePointer str, int ch)
public static int strcmp(@Cast(value="char*") BytePointer str1, @Cast(value="char*") BytePointer str2)
public static int strcoll(@Cast(value="char*") BytePointer str1, @Cast(value="char*") BytePointer str2)
@Cast(value="char*") public static BytePointer strcpy(@Cast(value="char*") BytePointer dst, @Cast(value="char*") BytePointer src)
@Cast(value="size_t") public static long strcspn(@Cast(value="char*") BytePointer str1, @Cast(value="char*") BytePointer str2)
@Cast(value="char*") public static BytePointer strerror(int errnum)
@Cast(value="size_t") public static long strlen(@Cast(value="char*") BytePointer str)
@Cast(value="char*") public static BytePointer strncat(@Cast(value="char*") BytePointer dst, @Cast(value="char*") BytePointer src, @Cast(value="size_t") long n)
public static int strncmp(@Cast(value="char*") BytePointer str1, @Cast(value="char*") BytePointer str2, @Cast(value="size_t") long n)
@Cast(value="char*") public static BytePointer strncpy(@Cast(value="char*") BytePointer dst, @Cast(value="char*") BytePointer src, @Cast(value="size_t") long n)
@Cast(value="char*") public static BytePointer strpbrk(@Cast(value="char*") BytePointer str1, @Cast(value="char*") BytePointer str2)
@Cast(value="char*") public static BytePointer strrchr(@Cast(value="char*") BytePointer str, int ch)
@Cast(value="size_t") public static long strspn(@Cast(value="char*") BytePointer str1, @Cast(value="char*") BytePointer str2)
@Cast(value="char*") public static BytePointer strstr(@Cast(value="char*") BytePointer str1, @Cast(value="char*") BytePointer str2)
@Cast(value="char*") public static BytePointer strtok(@Cast(value="char*") BytePointer str, @Cast(value="char*") BytePointer delim)
@Cast(value="size_t") public static long strxfrm(@Cast(value="char*") BytePointer dst, @Cast(value="char*") BytePointer src, @Cast(value="size_t") long n)
Copyright © 2018. All rights reserved.