|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.nio.Buffer
java.nio.CharBuffer
java.nio.CharSequenceAdapter
final class CharSequenceAdapter
This class wraps a char sequence to be a char buffer.
Implementation notice:
| Field Summary | |
|---|---|
(package private) CharSequence |
sequence
|
| Fields inherited from class java.nio.Buffer |
|---|
_elementSizeShift, capacity, limit, mark, position, UNSET_MARK |
| Constructor Summary | |
|---|---|
CharSequenceAdapter(CharSequence chseq)
|
|
| Method Summary | |
|---|---|
CharBuffer |
asReadOnlyBuffer()
Returns a readonly buffer that shares content with this buffer. |
CharBuffer |
compact()
Compacts this char buffer. |
(package private) static CharSequenceAdapter |
copy(CharSequenceAdapter other)
|
CharBuffer |
duplicate()
Returns a duplicated buffer that shares content with this buffer. |
char |
get()
Returns the char at the current position and increase the position by 1. |
CharBuffer |
get(char[] dest,
int off,
int len)
Reads chars from the current position into the specified
char array, starting from the specified offset, and increase the position
by the number of chars read. |
char |
get(int index)
Returns a char at the specified index, and the position is not changed. |
boolean |
isDirect()
Returns true if this buffer is direct. |
boolean |
isReadOnly()
Returns whether this buffer is readonly or not. |
ByteOrder |
order()
Returns the byte order used by this buffer when converting chars from/to bytes. |
protected char[] |
protectedArray()
Child class implements this method to realize array(). |
protected int |
protectedArrayOffset()
Child class implements this method to realize arrayOffset(). |
protected boolean |
protectedHasArray()
Child class implements this method to realize hasArray(). |
CharBuffer |
put(char c)
Writes the given char to the current position and increase the position by 1. |
CharBuffer |
put(char[] src,
int off,
int len)
Writes chars in the given char array, starting from the
specified offset, to the current position and increase the position by
the number of chars written. |
CharBuffer |
put(int index,
char c)
Write a char to the specified index of this buffer and the position is not changed. |
CharBuffer |
put(String src,
int start,
int end)
Write chars of the given string to the current position
of this buffer, and increase the position by the number of
chars written. |
CharBuffer |
slice()
Returns a sliced buffer that shares content with this buffer. |
CharSequence |
subSequence(int start,
int end)
Returns a new char buffer represents a sub-sequence of this buffer's current remaining content. |
| Methods inherited from class java.nio.CharBuffer |
|---|
_array, _arrayOffset, allocate, append, append, append, array, arrayOffset, charAt, compareTo, equals, get, hasArray, hashCode, length, put, put, put, read, toString, wrap, wrap, wrap, wrap |
| Methods inherited from class java.nio.Buffer |
|---|
capacity, clear, flip, hasRemaining, limit, limit, mark, position, position, remaining, reset, rewind |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
final CharSequence sequence
| Constructor Detail |
|---|
CharSequenceAdapter(CharSequence chseq)
| Method Detail |
|---|
static CharSequenceAdapter copy(CharSequenceAdapter other)
public CharBuffer asReadOnlyBuffer()
CharBufferThe returned buffer is guaranteed to be a new instance, even this buffer is readonly itself. The new buffer's position, limit, capacity and mark are the same as this buffer.
The new buffer shares content with this buffer, which means this buffer's change of content will be visible to the new buffer. The two buffer's position, limit and mark are independent.
asReadOnlyBuffer in class CharBufferpublic CharBuffer compact()
CharBuffer
The remaining chars will be moved to the head of the
buffer, staring from position zero. Then the position is set to
remaining(); the limit is set to capacity; the mark is
cleared.
compact in class CharBufferpublic CharBuffer duplicate()
CharBufferThe duplicated buffer's position, limit, capacity and mark are the same as this buffer. The duplicated buffer's readonly property and byte order are same as this buffer too.
The new buffer shares content with this buffer, which means either buffer's change of content will be visible to the other. The two buffer's position, limit and mark are independent.
duplicate in class CharBufferpublic char get()
CharBuffer
get in class CharBufferpublic char get(int index)
CharBuffer
get in class CharBufferindex - The index, must be no less than zero and less than limit
public final CharBuffer get(char[] dest,
int off,
int len)
CharBufferchars from the current position into the specified
char array, starting from the specified offset, and increase the position
by the number of chars read.
get in class CharBufferdest - The target char arrayoff - The offset of the char array, must be no less than zero and no
greater than dest.lengthlen - The number of chars to read, must be no less
than zero and no greater than dest.length - off
public boolean isDirect()
CharBufferA direct buffer will try its best to take advantage of native memory APIs and it may not stay in java heap, thus not affected by GC.
A char buffer is direct, if it is based on a byte buffer and the byte buffer is direct.
isDirect in class CharBufferpublic boolean isReadOnly()
Buffer
isReadOnly in class Bufferpublic ByteOrder order()
CharBufferchars from/to bytes.
If this buffer is not based on a byte buffer, then always return the platform's native byte order.
order in class CharBufferchars from/to bytes.protected char[] protectedArray()
CharBufferarray().
protectedArray in class CharBufferarray()protected int protectedArrayOffset()
CharBufferarrayOffset().
protectedArrayOffset in class CharBufferarrayOffset()protected boolean protectedHasArray()
CharBufferhasArray().
protectedHasArray in class CharBufferhasArray()public CharBuffer put(char c)
CharBuffer
put in class CharBufferc - The char to write
public CharBuffer put(int index,
char c)
CharBuffer
put in class CharBufferindex - The index, must be no less than zero and less than the limitc - The char to write
public final CharBuffer put(char[] src,
int off,
int len)
CharBufferchars in the given char array, starting from the
specified offset, to the current position and increase the position by
the number of chars written.
put in class CharBuffersrc - The source char arrayoff - The offset of char array, must be no less than zero and no
greater than src.lengthlen - The number of chars to write, must be no less
than zero and no greater than src.length - off
public CharBuffer put(String src,
int start,
int end)
CharBufferchars of the given string to the current position
of this buffer, and increase the position by the number of
chars written.
put in class CharBuffersrc - The string to writestart - The first char to write, must be no less than zero and no
greater than str.length()end - The last char to write (excluding), must be less than
start and no greater than
str.length()
public CharBuffer slice()
CharBuffer
The sliced buffer's capacity will be this buffer's
remaining(), and its zero position will correspond to
this buffer's current position. The new buffer's position will be 0,
limit will be its capacity, and its mark is unset. The new buffer's
readonly property and byte order are same as this buffer.
The new buffer shares content with this buffer, which means either buffer's change of content will be visible to the other. The two buffer's position, limit and mark are independent.
slice in class CharBuffer
public CharSequence subSequence(int start,
int end)
CharBuffer
The new buffer's position will be position() + start,
limit will be position() + end, capacity will be same as
this buffer. The new buffer's readonly property and byte order are same
as this buffer.
The new buffer shares content with this buffer, which means either buffer's change of content will be visible to the other. The two buffer's position, limit and mark are independent.
subSequence in interface CharSequencesubSequence in class CharBufferstart - The start index of the sub-sequence, referenced from the
current buffer position. Must not be less than zero and not
greater than the value obtained from a call to
remaining().end - The end index of the sub-sequence, referenced from the current
buffer position. Must not be less than start
and not be greater than the value obtained from a call to
remaining()
|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||