This class defines four categories of operations upon char buffers:
Absolute and relative get and
put methods that read and write
single chars;
Absolute and relative bulk get
methods that transfer contiguous sequences of chars from this buffer
into an array;
Absolute and relative bulk put
methods that transfer contiguous sequences of chars from a
char array, a string, or some other char
buffer into this buffer;
A method for compacting
a char buffer.
Char buffers can be created either by allocation, which allocates space for the buffer's
content, by wrapping an existing
char array or string into a buffer, or by creating a
view of an existing byte buffer.
Like a byte buffer, a char buffer is either direct or non-direct. A
char buffer created via the wrap methods of this class will
be non-direct. A char buffer created as a view of a byte buffer will
be direct if, and only if, the byte buffer itself is direct. Whether or not
a char buffer is direct may be determined by invoking the isDirect method.
This class implements the CharSequence interface so that
character buffers may be used wherever character sequences are accepted, for
example in the regular-expression package java..
The methods defined by CharSequence operate relative to the current
position of the buffer when they are invoked.
Methods in this class that do not otherwise have a value to return are specified to return the buffer upon which they are invoked. This allows method invocations to be chained. The sequence of statements
cb.put("text/"); cb.put(subtype); cb.put("; charset="); cb.put(enc);
cb.put("text/").put(subtype).put("; charset=").put(enc);
| Modifier and Type | Field and Description |
|---|---|
| private static final long | |
| pack-priv final char[] | |
| pack-priv boolean | |
| pack-priv final int |
| Access | Constructor and Description |
|---|---|
| pack-priv | |
| pack-priv | |
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public static CharBuffer | Returns: The new char bufferThe new buffer's capacity, in chars capacity)Allocates a new char buffer. |
| public CharBuffer | Returns: This bufferThe character sequence to append. If csq)csq is
null, then the four characters "null" are
appended to this character buffer.Implements java. Appends the specified character sequence to this buffer (optional operation). |
| public CharBuffer | Returns: This bufferThe character sequence from which a subsequence will be
appended. If csq, int start, int end)csq is null, then characters
will be appended as if csq contained the four
characters "null".Implements java. Appends a subsequence of the specified character sequence to this buffer (optional operation). |
| public CharBuffer | Returns: This bufferThe 16-bit char to append c)Implements java. Appends the specified char to this buffer (optional operation). |
| public final char[] | Returns: The array that backs this bufferImplements abstract java. Returns the char array that backs this buffer (optional operation). |
| public final int | Returns: The offset within this buffer's array of the first element of the bufferImplements abstract java. Returns the offset within this buffer's backing array of the first element of the buffer (optional operation). |
| public abstract CharBuffer | Returns: The new, read-only char bufferCreates a new, read-only char buffer that shares this buffer's content. |
| pack-priv Object | |
| public final char | Returns: The character at indexposition() + indexThe index of the character to be read, relative to the position;
must be non-negative and smaller than index)remaining()Implements java. Reads the character at the given index relative to the current position. |
| pack-priv abstract ByteOrder | |
| public IntStream | chars()
Overrides default java. Returns a stream of |
| public final CharBuffer | |
| public abstract CharBuffer | |
| private static int | |
| public int | Returns: A negative integer, zero, or a positive integer as this buffer is less than, equal to, or greater than the given bufferImplements java. Compares this buffer to another. |
| public abstract CharBuffer | Returns: The new char bufferImplements abstract java. Creates a new char buffer that shares this buffer's content. |
| public boolean | Returns: true if, and only if, this buffer is equal to the
given objectThe object to which this buffer is to be compared ob)Overrides java. Tells whether or not this buffer is equal to another object. |
| public final CharBuffer | |
| public abstract char | |
| public abstract char | Returns: The char at the given indexThe index from which the char will be read index)Absolute get method. |
| public CharBuffer | Returns: This bufferThe array into which chars are to be written dst, int The offset within the array of the first char to be
written; must be non-negative and no larger than
offset, int dst.lengthThe maximum number of chars to be written to the given
array; must be non-negative and no larger than
length)dst.length - offsetRelative bulk get method. |
| public CharBuffer | |
| public CharBuffer | Returns: This bufferThe index in this buffer from which the first char will be
read; must be non-negative and less than index, char[] limit()The destination array dst, int The offset within the array of the first char to be
written; must be non-negative and less than
offset, int dst.lengthThe number of chars to be written to the given array;
must be non-negative and no larger than the smaller of
length)limit() - index and dst.length - offsetAbsolute bulk get method. |
| public CharBuffer | Returns: This bufferThe index in this buffer from which the first char will be
read; must be non-negative and less than index, char[] limit()The destination array dst)Absolute bulk get method. |
| pack-priv CharBuffer | |
| public void | getChars(int
The index in this buffer, relative to the current position,
of the first character to
read; must be non-negative and less than
srcBegin, int limit() - position()The index in this buffer, relative to the current position,
after the last character to read;
must be greater than or equal to srcEnd, char[] srcBegin and less than
or equal to limit() - position()The destination array dst, int The offset within the array of the first character to be
written; must be non-negative and less than dstBegin)dst.lengthOverrides default java. Relative bulk get method. |
| pack-priv abstract char | Returns: The char at the given indexThe index from which the char will be read index)Absolute get method. |
| public final boolean | Returns: true if, and only if, this buffer
is backed by an array and is not read-onlyImplements abstract java. Tells whether or not this buffer is backed by an accessible char array. |
| public int | Returns: The current hash code of this bufferOverrides java. Returns the current hash code of this buffer. |
| pack-priv AbstractMemorySegmentImpl | heapSegment(Object base, long offset, long length, boolean readOnly, MemorySessionImpl bufferScope)
Implements abstract java.
|
| pack-priv boolean | Returns: true if, and only, this buffer has addressable memoryTells whether this buffer has addressable memory, e.g., a Java array or a native address. |
| public abstract boolean | Returns: true if, and only if, this buffer is directImplements abstract java. Tells whether or not this char buffer is direct. |
| public final boolean | Returns: true if there are 0 remaining characters,
otherwise falseOverrides default java. Returns |
| public final int | Returns: The length of this character bufferImplements java. Returns the length of this character buffer. |
| public final CharBuffer | |
| public final CharBuffer | |
| public int | Returns: The relative index of the first mismatch between this and the given buffer, otherwise -1 if no mismatch.The byte buffer to be tested for a mismatch with this buffer that)Finds and returns the relative index of the first mismatch between this buffer and a given buffer. |
| public abstract ByteOrder | |
| public final CharBuffer | |
| public abstract CharBuffer | |
| public abstract CharBuffer | Returns: This bufferThe index at which the char will be written index, char The char value to be written c)Absolute put method (optional operation). |
| public CharBuffer | Returns: This bufferThe source buffer from which chars are to be read;
must not be this buffer src)Relative bulk put method (optional operation). |
| public CharBuffer | Returns: This bufferThe index in this buffer at which the first char will be
written; must be non-negative and less than index, CharBuffer limit()The buffer from which chars are to be read src, int The index within the source buffer of the first char to be
read; must be non-negative and less than offset, int src.limit()The number of chars to be read from the given buffer;
must be non-negative and no larger than the smaller of
length)limit() - index and src.limit() - offsetAbsolute bulk put method (optional operation). |
| public CharBuffer | Returns: This bufferThe array from which chars are to be read src, int The offset within the array of the first char to be read;
must be non-negative and no larger than offset, int src.lengthThe number of chars to be read from the given array;
must be non-negative and no larger than
length)src.length - offsetRelative bulk put method (optional operation). |
| public final CharBuffer | |
| public CharBuffer | Returns: This bufferThe index in this buffer at which the first char will be
written; must be non-negative and less than index, char[] limit()The array from which chars are to be read src, int The offset within the array of the first char to be read;
must be non-negative and less than offset, int src.lengthThe number of chars to be read from the given array;
must be non-negative and no larger than the smaller of
length)limit() - index and src.length - offsetAbsolute bulk put method (optional operation). |
| public CharBuffer | Returns: This bufferThe index in this buffer at which the first char will be
written; must be non-negative and less than index, char[] limit()The array from which chars are to be read src)Absolute bulk put method (optional operation). |
| public CharBuffer | Returns: This bufferThe string from which chars are to be read src, int The offset within the string of the first char to be read;
must be non-negative and no larger than
start, int string.length()The offset within the string of the last char to be read,
plus one; must be non-negative and no larger than
end)string.length()Relative bulk put method (optional operation). |
| public final CharBuffer | |
| pack-priv CharBuffer | |
| pack-priv void | |
| public int | Returns: The number of characters added to the buffer, possibly zero, or -1 if this source of characters is at its endthe buffer to read characters into target)Implements java. Attempts to read characters into the specified character buffer. |
| public final CharBuffer | reset()
Overrides java. Resets this buffer's position to the previously-marked position. |
| public final CharBuffer | |
| pack-priv int | scaleShifts()
Implements abstract java. Returns the scale shifts for this Buffer. |
| public abstract CharBuffer | Returns: The new char bufferImplements abstract java. Creates a new char buffer whose content is a shared subsequence of this buffer's content. |
| public abstract CharBuffer | Returns: The new bufferThe position in this buffer at which the content of the new
buffer will start; must be non-negative and no larger than
index, int limit()The number of elements the new buffer will contain; must be
non-negative and no larger than length)limit() - indexImplements abstract java. Creates a new char buffer whose content is a shared subsequence of this buffer's content. |
| public abstract CharBuffer | Returns: The new character bufferThe index, relative to the current position, of the first
character in the subsequence; must be non-negative and no larger
than start, int remaining()The index, relative to the current position, of the character
following the last character in the subsequence; must be no
smaller than end)start and no larger than
remaining()Redeclares java. Creates a new character buffer that represents the specified subsequence of this buffer, relative to the current position. |
| public String | Returns: The specified stringOverrides java. Implements java. Returns a string containing the characters in this buffer. |
| pack-priv abstract String | |
| public static CharBuffer | Returns: The new char bufferThe array that will back the new buffer array, int The offset of the subarray to be used; must be non-negative and
no larger than offset, int array.length. The new buffer's position
will be set to this value.The length of the subarray to be used;
must be non-negative and no larger than
length)array.length - offset.
The new buffer's limit will be set to offset + length.Wraps a char array into a buffer. |
| public static CharBuffer | Returns: The new char bufferThe array that will back this buffer array)Wraps a char array into a buffer. |
| public static CharBuffer | Returns: The new character bufferThe character sequence from which the new character buffer is to
be created csq, int The index of the first character to be used;
must be non-negative and no larger than start, int csq.length().
The new buffer's position will be set to this value.The index of the character following the last character to be
used; must be no smaller than end)start and no larger
than csq.length().
The new buffer's limit will be set to this value.Wraps a character sequence into a buffer. |
| public static CharBuffer | Returns: The new character bufferThe character sequence from which the new character buffer is to
be created csq)Wraps a character sequence into a buffer. |