APIdia Launch Partner
Top Description Fields Constructors Methods
java.nio

pack-priv sealed Class HeapCharBuffer

extends CharBuffer
permits HeapCharBufferR
Class Inheritance
Known Direct Subclasses
java.nio.HeapCharBufferR
Imports
java.lang.foreign.MemorySegment, jdk.internal.foreign.AbstractMemorySegmentImpl, .MemorySessionImpl, .SegmentFactories, jdk.internal.vm.annotation.ForceInline, java.util.Objects

A read/write HeapCharBuffer.

Field Summary

Modifier and TypeField and Description
private static final long
private static final long
Inherited from java.nio.CharBuffer:
hbisReadOnlyoffset

Constructor Summary

AccessConstructor and Description
pack-priv
HeapCharBuffer(int cap, int lim, MemorySegment segment)

pack-priv
HeapCharBuffer(char[] buf, int off, int len, MemorySegment segment)

protected
HeapCharBuffer(char[] buf, int mark, int pos, int lim, int cap, int off, MemorySegment segment)

Method Summary

Modifier and TypeMethod and Description
public CharBuffer
append(CharSequence csq, int start, int end)

Overrides java.nio.CharBuffer.append.

Implements java.lang.Appendable.append.

Appends a subsequence of the specified character sequence to this buffer  (optional operation).

public CharBuffer
append(CharSequence csq)

Overrides java.nio.CharBuffer.append.

Implements java.lang.Appendable.append.

Appends the specified character sequence to this buffer  (optional operation).

public CharBuffer
asReadOnlyBuffer()

Implements abstract java.nio.CharBuffer.asReadOnlyBuffer.

Creates a new, read-only char buffer that shares this buffer's content.

pack-priv ByteOrder
public CharBuffer
compact()

Implements abstract java.nio.CharBuffer.compact.

Compacts this buffer  (optional operation).

public CharBuffer
duplicate()

Implements abstract java.nio.CharBuffer.duplicate.

Creates a new char buffer that shares this buffer's content.

public char
get()

Implements abstract java.nio.CharBuffer.get.

Relative get method.

public char
get(int i)

Implements abstract java.nio.CharBuffer.get.

Absolute get method.

public CharBuffer
get(char[] dst, int offset, int length)

Overrides java.nio.CharBuffer.get.

Relative bulk get method.

public CharBuffer
get(int index, char[] dst, int offset, int length)

Overrides java.nio.CharBuffer.get.

Absolute bulk get method.

pack-priv char
getUnchecked(int i)

Implements abstract java.nio.CharBuffer.getUnchecked.

Absolute get method.

public boolean
isDirect()

Implements abstract java.nio.CharBuffer.isDirect.

Tells whether or not this char buffer is direct.

public boolean
isReadOnly()

Implements abstract java.nio.Buffer.isReadOnly.

Tells whether or not this buffer is read-only.

protected int
ix(int i)

public ByteOrder
order()

Implements abstract java.nio.CharBuffer.order.

Retrieves this buffer's byte order.

public CharBuffer
put(char x)

Implements abstract java.nio.CharBuffer.put.

Relative put method  (optional operation).

public CharBuffer
put(int i, char x)

Implements abstract java.nio.CharBuffer.put.

Absolute put method  (optional operation).

public CharBuffer
put(char[] src, int offset, int length)

Overrides java.nio.CharBuffer.put.

Relative bulk put method  (optional operation).

public CharBuffer
put(CharBuffer src)

Overrides java.nio.CharBuffer.put.

Relative bulk put method  (optional operation).

public CharBuffer
put(int index, CharBuffer src, int offset, int length)

Overrides java.nio.CharBuffer.put.

Absolute bulk put method  (optional operation).

public CharBuffer
put(int index, char[] src, int offset, int length)

Overrides java.nio.CharBuffer.put.

Absolute bulk put method  (optional operation).

public CharBuffer
put(String src, int start, int end)

Overrides java.nio.CharBuffer.put.

Relative bulk put method  (optional operation).

public CharBuffer
slice()

Implements abstract java.nio.CharBuffer.slice.

Creates a new char buffer whose content is a shared subsequence of this buffer's content.

public CharBuffer
slice(int index, int length)

Implements abstract java.nio.CharBuffer.slice.

Creates a new char buffer whose content is a shared subsequence of this buffer's content.

public CharBuffer
subSequence(int start, int end)

Implements abstract java.nio.CharBuffer.subSequence.

Implements java.lang.CharSequence.subSequence.

Creates a new character buffer that represents the specified subsequence of this buffer, relative to the current position.

pack-priv String
toString(int start, int end)

Implements abstract java.nio.CharBuffer.toString.

Inherited from java.nio.CharBuffer:
allocateappendarrayarrayOffsetbasecharAtcharsclearcompareToequalsflipgetgetgetArraygetCharshasArrayhashCodeheapSegmentisAddressableisEmptylengthlimitmarkmismatchpositionputputputputArrayputBufferreadresetrewindscaleShiftstoStringwrapwrapwrapwrap

Field Detail

ARRAY_BASE_OFFSETback to summary
private static final long ARRAY_BASE_OFFSET

Hides java.nio.CharBuffer.ARRAY_BASE_OFFSET.

ARRAY_INDEX_SCALEback to summary
private static final long ARRAY_INDEX_SCALE

Constructor Detail

HeapCharBufferback to summary
pack-priv HeapCharBuffer(int cap, int lim, MemorySegment segment)
HeapCharBufferback to summary
pack-priv HeapCharBuffer(char[] buf, int off, int len, MemorySegment segment)
HeapCharBufferback to summary
protected HeapCharBuffer(char[] buf, int mark, int pos, int lim, int cap, int off, MemorySegment segment)

Method Detail

appendback to summary
public CharBuffer append(CharSequence csq, int start, int end)

Overrides java.nio.CharBuffer.append.

Implements java.lang.Appendable.append.

Doc from java.nio.CharBuffer.append.

Appends a subsequence of the specified character sequence to this buffer  (optional operation).

An invocation of this method of the form dst.append(csq, start, end) when csq is not null, behaves in exactly the same way as the invocation

dst.put(csq.subSequence(start, end).toString())
dst.put(csq.subSequence(start, end).toString())
appendback to summary
public CharBuffer append(CharSequence csq)

Overrides java.nio.CharBuffer.append.

Implements java.lang.Appendable.append.

Doc from java.nio.CharBuffer.append.

Appends the specified character sequence to this buffer  (optional operation).

An invocation of this method of the form dst.append(csq) behaves in exactly the same way as the invocation

dst.put(csq.toString())
dst.put(csq.toString())

Depending on the specification of toString for the character sequence csq, the entire sequence may not be appended. For instance, invoking the toString method of a character buffer will return a subsequence whose content depends upon the buffer's position and limit.

asReadOnlyBufferback to summary
public CharBuffer asReadOnlyBuffer()

Implements abstract java.nio.CharBuffer.asReadOnlyBuffer.

Doc from java.nio.CharBuffer.asReadOnlyBuffer.

Creates a new, read-only char buffer that shares this buffer's content.

The content of the new buffer will be that of this buffer. Changes to this buffer's content will be visible in the new buffer; the new buffer itself, however, will be read-only and will not allow the shared content to be modified. The two buffers' position, limit, and mark values will be independent.

The new buffer's capacity, limit, position, mark values, and byte order will be identical to those of this buffer.

If this buffer is itself read-only then this method behaves in exactly the same way as the duplicate method.

charRegionOrderback to summary
pack-priv ByteOrder charRegionOrder()

Implements abstract java.nio.CharBuffer.charRegionOrder.

compactback to summary
public CharBuffer compact()

Implements abstract java.nio.CharBuffer.compact.

Doc from java.nio.CharBuffer.compact.

Compacts this buffer  (optional operation).

The chars between the buffer's current position and its limit, if any, are copied to the beginning of the buffer. That is, the char at index p = position() is copied to index zero, the char at index p + 1 is copied to index one, and so forth until the char at index limit() - 1 is copied to index n = limit() - 1 - p. The buffer's position is then set to n+1 and its limit is set to its capacity. The mark, if defined, is discarded.

The buffer's position is set to the number of chars copied, rather than to zero, so that an invocation of this method can be followed immediately by an invocation of another relative put method.

duplicateback to summary
public CharBuffer duplicate()

Implements abstract java.nio.CharBuffer.duplicate.

Doc from java.nio.CharBuffer.duplicate.

Creates a new char buffer that shares this buffer's content.

The content of the new buffer will be that of this buffer. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position, limit, and mark values will be independent.

The new buffer's capacity, limit, position, mark values, and byte order will be identical to those of this buffer. The new buffer will be direct if, and only if, this buffer is direct, and it will be read-only if, and only if, this buffer is read-only.

getback to summary
public char get()

Implements abstract java.nio.CharBuffer.get.

Doc from java.nio.CharBuffer.get.

Relative get method. Reads the char at this buffer's current position, and then increments the position.

getback to summary
public char get(int i)

Implements abstract java.nio.CharBuffer.get.

Doc from java.nio.CharBuffer.get.

Absolute get method. Reads the char at the given index.

getback to summary
public CharBuffer get(char[] dst, int offset, int length)

Overrides java.nio.CharBuffer.get.

Doc from java.nio.CharBuffer.get.

Relative bulk get method.

This method transfers chars from this buffer into the given destination array. If there are fewer chars remaining in the buffer than are required to satisfy the request, that is, if length > remaining(), then no chars are transferred and a BufferUnderflowException is thrown.

Otherwise, this method copies length chars from this buffer into the given array, starting at the current position of this buffer and at the given offset in the array. The position of this buffer is then incremented by length.

In other words, an invocation of this method of the form src.get(dst, off, len) has exactly the same effect as the loop

for (int i = off; i < off + len; i++) dst[i] = src.get();
for (int i = off; i < off + len; i++)
    dst[i] = src.get();
except that it first checks that there are sufficient chars in this buffer and it is potentially much more efficient.
getback to summary
public CharBuffer get(int index, char[] dst, int offset, int length)

Overrides java.nio.CharBuffer.get.

Doc from java.nio.CharBuffer.get.

Absolute bulk get method.

This method transfers length chars from this buffer into the given array, starting at the given index in this buffer and at the given offset in the array. The position of this buffer is unchanged.

An invocation of this method of the form src.get(index, dst, offset, length) has exactly the same effect as the following loop except that it first checks the consistency of the supplied parameters and it is potentially much more efficient:

for (int i = offset, j = index; i < offset + length; i++, j++) dst[i] = src.get(j);
for (int i = offset, j = index; i < offset + length; i++, j++)
    dst[i] = src.get(j);
getUncheckedback to summary
pack-priv char getUnchecked(int i)

Implements abstract java.nio.CharBuffer.getUnchecked.

Doc from java.nio.CharBuffer.getUnchecked.

Absolute get method. Reads the char at the given index without any validation of the index.

isDirectback to summary
public boolean isDirect()

Implements abstract java.nio.CharBuffer.isDirect.

Doc from java.nio.CharBuffer.isDirect.

Tells whether or not this char buffer is direct.

isReadOnlyback to summary
public boolean isReadOnly()

Implements abstract java.nio.Buffer.isReadOnly.

Doc from java.nio.Buffer.isReadOnly.

Tells whether or not this buffer is read-only.

ixback to summary
protected int ix(int i)
orderback to summary
public ByteOrder order()

Implements abstract java.nio.CharBuffer.order.

Doc from java.nio.CharBuffer.order.

Retrieves this buffer's byte order.

The byte order of a char buffer created by allocation or by wrapping an existing char array is the native order of the underlying hardware. The byte order of a char buffer created as a view of a byte buffer is that of the byte buffer at the moment that the view is created.

putback to summary
public CharBuffer put(char x)

Implements abstract java.nio.CharBuffer.put.

Doc from java.nio.CharBuffer.put.

Relative put method  (optional operation).

Writes the given char into this buffer at the current position, and then increments the position.

putback to summary
public CharBuffer put(int i, char x)

Implements abstract java.nio.CharBuffer.put.

Doc from java.nio.CharBuffer.put.

Absolute put method  (optional operation).

Writes the given char into this buffer at the given index.

putback to summary
public CharBuffer put(char[] src, int offset, int length)

Overrides java.nio.CharBuffer.put.

Doc from java.nio.CharBuffer.put.

Relative bulk put method  (optional operation).

This method transfers chars into this buffer from the given source array. If there are more chars to be copied from the array than remain in this buffer, that is, if length > remaining(), then no chars are transferred and a BufferOverflowException is thrown.

Otherwise, this method copies length chars from the given array into this buffer, starting at the given offset in the array and at the current position of this buffer. The position of this buffer is then incremented by length.

In other words, an invocation of this method of the form dst.put(src, off, len) has exactly the same effect as the loop

for (int i = off; i < off + len; i++) dst.put(src[i]);
for (int i = off; i < off + len; i++)
    dst.put(src[i]);
except that it first checks that there is sufficient space in this buffer and it is potentially much more efficient.
putback to summary
public CharBuffer put(CharBuffer src)

Overrides java.nio.CharBuffer.put.

Doc from java.nio.CharBuffer.put.

Relative bulk put method  (optional operation).

This method transfers the chars remaining in the given source buffer into this buffer. If there are more chars remaining in the source buffer than in this buffer, that is, if src.remaining() > remaining(), then no chars are transferred and a BufferOverflowException is thrown.

Otherwise, this method copies n = src.remaining() chars from the given buffer into this buffer, starting at each buffer's current position. The positions of both buffers are then incremented by n.

In other words, an invocation of this method of the form dst.put(src) has exactly the same effect as the loop

while (src.hasRemaining()) dst.put(src.get());
while (src.hasRemaining())
    dst.put(src.get());
except that it first checks that there is sufficient space in this buffer and it is potentially much more efficient. If this buffer and the source buffer share the same backing array or memory, then the result will be as if the source elements were first copied to an intermediate location before being written into this buffer.
putback to summary
public CharBuffer put(int index, CharBuffer src, int offset, int length)

Overrides java.nio.CharBuffer.put.

Doc from java.nio.CharBuffer.put.

Absolute bulk put method  (optional operation).

This method transfers length chars into this buffer from the given source buffer, starting at the given offset in the source buffer and the given index in this buffer. The positions of both buffers are unchanged.

In other words, an invocation of this method of the form dst.put(index, src, offset, length) has exactly the same effect as the loop

for (int i = offset, j = index; i < offset + length; i++, j++) dst.put(j, src.get(i));
for (int i = offset, j = index; i < offset + length; i++, j++)
    dst.put(j, src.get(i));
except that it first checks the consistency of the supplied parameters and it is potentially much more efficient. If this buffer and the source buffer share the same backing array or memory, then the result will be as if the source elements were first copied to an intermediate location before being written into this buffer.
putback to summary
public CharBuffer put(int index, char[] src, int offset, int length)

Overrides java.nio.CharBuffer.put.

Doc from java.nio.CharBuffer.put.

Absolute bulk put method  (optional operation).

This method transfers length chars from the given array, starting at the given offset in the array and at the given index in this buffer. The position of this buffer is unchanged.

An invocation of this method of the form dst.put(index, src, offset, length) has exactly the same effect as the following loop except that it first checks the consistency of the supplied parameters and it is potentially much more efficient:

for (int i = offset, j = index; i < offset + length; i++, j++) dst.put(j, src[i]);
for (int i = offset, j = index; i < offset + length; i++, j++)
    dst.put(j, src[i]);
putback to summary
public CharBuffer put(String src, int start, int end)

Overrides java.nio.CharBuffer.put.

Doc from java.nio.CharBuffer.put.

Relative bulk put method  (optional operation).

This method transfers chars from the given string into this buffer. If there are more chars to be copied from the string than remain in this buffer, that is, if end - start > remaining(), then no chars are transferred and a BufferOverflowException is thrown.

Otherwise, this method copies n = end - start chars from the given string into this buffer, starting at the given start index and at the current position of this buffer. The position of this buffer is then incremented by n.

In other words, an invocation of this method of the form dst.put(src, start, end) has exactly the same effect as the loop

for (int i = start; i < end; i++) dst.put(src.charAt(i));
for (int i = start; i < end; i++)
    dst.put(src.charAt(i));
except that it first checks that there is sufficient space in this buffer and it is potentially much more efficient.
sliceback to summary
public CharBuffer slice()

Implements abstract java.nio.CharBuffer.slice.

Doc from java.nio.CharBuffer.slice.

Creates a new char buffer whose content is a shared subsequence of this buffer's content.

The content of the new buffer will start at this buffer's current position. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position, limit, and mark values will be independent.

The new buffer's position will be zero, its capacity and its limit will be the number of chars remaining in this buffer, its mark will be undefined, and its byte order will be identical to that of this buffer. The new buffer will be direct if, and only if, this buffer is direct, and it will be read-only if, and only if, this buffer is read-only.

sliceback to summary
public CharBuffer slice(int index, int length)

Implements abstract java.nio.CharBuffer.slice.

Doc from java.nio.CharBuffer.slice.

Creates a new char buffer whose content is a shared subsequence of this buffer's content.

The content of the new buffer will start at position index in this buffer, and will contain length elements. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position, limit, and mark values will be independent.

The new buffer's position will be zero, its capacity and its limit will be length, its mark will be undefined, and its byte order will be identical to that of this buffer. The new buffer will be direct if, and only if, this buffer is direct, and it will be read-only if, and only if, this buffer is read-only.

Annotations
@Override
subSequenceback to summary
public CharBuffer subSequence(int start, int end)

Implements abstract java.nio.CharBuffer.subSequence.

Implements java.lang.CharSequence.subSequence.

Doc from java.nio.CharBuffer.subSequence.

Creates a new character buffer that represents the specified subsequence of this buffer, relative to the current position.

The new buffer will share this buffer's content; that is, if the content of this buffer is mutable then modifications to one buffer will cause the other to be modified. The new buffer's capacity will be that of this buffer, its position will be position() + start, its limit will be position() + end, and its byte order will be identical to that of this buffer. The new buffer will be direct if, and only if, this buffer is direct, and it will be read-only if, and only if, this buffer is read-only.

toStringback to summary
pack-priv String toString(int start, int end)

Implements abstract java.nio.CharBuffer.toString.