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) |
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 |
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()@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 © 2017. All rights reserved.