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.NativeDeallocator| 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(int 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(int size) |
ByteBuffer |
asBuffer()
Same as
Pointer.asByteBuffer(), but can be overridden to return subclasses of Buffer. |
BytePointer |
capacity(int 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(int 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() |
BytePointer |
limit(int limit)
Sets the limit and returns this.
|
BytePointer |
position(int 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(int 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.
|
address, asByteBuffer, capacity, deallocate, deallocate, deallocateReferences, deallocator, deallocator, equals, fill, hashCode, init, isNull, limit, memchr, memcmp, memcpy, memmove, memset, offsetof, position, put, setNull, sizeof, toString, 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(int 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(int size)
public BytePointer position(int position)
Pointerarray.position(i)
statement sort of equivalent to the array[i] statement in C++.position in class Pointerposition - the new positionPointer.position(int)public BytePointer limit(int limit)
Pointerlimit in class Pointerlimit - the new limitPointer.limit(int)public BytePointer capacity(int capacity)
Pointercapacity in class Pointercapacity - the new capacityPointer.capacity(int)public byte[] getStringBytes()
public String getString(String charsetName) throws UnsupportedEncodingException
charsetName - the charset in which the bytes are encodedUnsupportedEncodingExceptionpublic String getString()
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(int i)
byte value of a native arraypublic BytePointer put(byte b)
put(0, b)public BytePointer put(int 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()Copyright © 2015. All Rights Reserved.