public class CharPointer extends Pointer
short
for UTF-16.
All operations take into account the position and limit, when appropriate.Pointer.CustomDeallocator, Pointer.Deallocator, Pointer.NativeDeallocator
Constructor and Description |
---|
CharPointer() |
CharPointer(char... array)
Allocates enough memory for the array and copies it.
|
CharPointer(CharBuffer buffer)
For direct buffers, calls
Pointer.Pointer(Buffer) , while for buffers
backed with an array, allocates enough memory for the array and copies it. |
CharPointer(int size)
Allocates a native
short array of the given size. |
CharPointer(Pointer p) |
CharPointer(String s)
Allocates enough memory for the String and copies it.
|
Modifier and Type | Method and Description |
---|---|
private void |
allocateArray(int size) |
CharBuffer |
asBuffer()
Same as
Pointer.asByteBuffer() , but can be overridden to return subclasses of Buffer. |
CharPointer |
capacity(int capacity)
Sets the capacity and returns this.
|
char |
get() |
CharPointer |
get(char[] array) |
CharPointer |
get(char[] array,
int offset,
int length)
Reads a portion of the native array into a Java array.
|
char |
get(int i) |
String |
getString() |
char[] |
getStringChars() |
CharPointer |
limit(int limit)
Sets the limit and returns this.
|
CharPointer |
position(int position)
Sets the position and returns this.
|
CharPointer |
put(char... array) |
CharPointer |
put(char c) |
CharPointer |
put(char[] array,
int offset,
int length)
Writes a portion of a Java array into the native array.
|
CharPointer |
put(int i,
char c)
Copies the
char value to the i-th element of a native array. |
CharPointer |
putString(String s)
Copies the String chars into native memory, including a terminating null char.
|
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, zero
public CharPointer(String s)
s
- the String to copyputString(String)
public CharPointer(char... array)
array
- the array to copyput(char[])
public CharPointer(CharBuffer 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(char[])
public CharPointer(int size)
short
array of the given size.size
- the number of short
elements to allocatepublic CharPointer()
Pointer.Pointer()
public CharPointer(Pointer p)
Pointer.Pointer(Pointer)
private void allocateArray(int size)
public CharPointer position(int position)
Pointer
array.position(i)
statement sort of equivalent to the array[i]
statement in C++.position
in class Pointer
position
- the new positionPointer.position(int)
public CharPointer limit(int limit)
Pointer
limit
in class Pointer
limit
- the new limitPointer.limit(int)
public CharPointer capacity(int capacity)
Pointer
capacity
in class Pointer
capacity
- the new capacityPointer.capacity(int)
public char[] getStringChars()
public String getString()
public CharPointer putString(String s)
s
- the String to copyString.toCharArray()
,
put(char[])
public char get()
get(0)
public char get(int i)
char
value of a native arraypublic CharPointer put(char c)
put(0, c)
public CharPointer put(int i, char c)
char
value to the i-th element of a native array.i
- the index into the arrayc
- the char
value to copypublic CharPointer get(char[] array)
get(array, 0, array.length)
public CharPointer put(char... array)
put(array, 0, array.length)
public CharPointer get(char[] 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 CharPointer put(char[] 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 CharBuffer asBuffer()
Pointer
Pointer.asByteBuffer()
, but can be overridden to return subclasses of Buffer.asBuffer
in class Pointer
asByteBuffer().asCharBuffer()
BytePointer.asBuffer()
,
ShortPointer.asBuffer()
,
IntPointer.asBuffer()
,
LongPointer.asBuffer()
,
FloatPointer.asBuffer()
,
DoublePointer.asBuffer()
,
asBuffer()
Copyright © 2015. All Rights Reserved.