Class CodePointBuffer.Builder
- Enclosing class:
- CodePointBuffer
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ByteBufferprivate CharBufferprivate IntBufferprivate intprivate CodePointBuffer.Type -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) voidAppends UTF-16 code units directly from aStringwithout allocating a temporaryCharBufferor intermediate char array.voidappend(CharBuffer utf16In) Appends UTF-16 code units fromutf16In.private voidappendArrayByte(char[] in, int start, int limit) private voidappendArrayChar(char[] in, int start, int limit) private voidappendArrayInt(char[] in, int start, int limit) private voidappendCharSequenceByte(CharSequence utf16In, int start, int end) private voidappendCharSequenceChar(CharSequence utf16In, int start, int end) private voidappendCharSequenceInt(CharSequence utf16In, int start, int end) private voidappendStringByte(String utf16In, int start) private voidappendStringChar(String utf16In, int start) private voidappendStringInt(String utf16In, int start) build()private voidbyteToCharBuffer(int toAppend) private voidbyteToIntBuffer(int toAppend) private voidcharToIntBuffer(int toAppend) voidensureRemaining(int remainingNeeded) (package private) ByteBuffer(package private) CharBuffer(package private) IntBuffer(package private) CodePointBuffer.TypegetType()private static introundUpToNextPowerOfTwo(int i)
-
Field Details
-
type
-
byteBuffer
-
charBuffer
-
intBuffer
-
prevHighSurrogate
private int prevHighSurrogate
-
-
Constructor Details
-
Builder
private Builder(int initialBufferSize)
-
-
Method Details
-
getType
CodePointBuffer.Type getType() -
getByteBuffer
ByteBuffer getByteBuffer() -
getCharBuffer
CharBuffer getCharBuffer() -
getIntBuffer
IntBuffer getIntBuffer() -
build
-
roundUpToNextPowerOfTwo
private static int roundUpToNextPowerOfTwo(int i) -
ensureRemaining
public void ensureRemaining(int remainingNeeded) -
append
Appends UTF-16 code units fromutf16In.Array-backed buffers use a specialized monomorphic
char[]conversion path to allow the HotSpot C2 compiler to inline accesses and eliminate bounds checks on the tight conversion loop. Non-array and read-only buffers (such asCharBuffer.wrap(CharSequence)) fall back to a zero-copyCharSequenceinterface path without throwingReadOnlyBufferException.Each call is treated as a complete UTF-16 sequence: an unpaired high surrogate at the end of a call is written as a lone code unit and is not carried across calls.
- Parameters:
utf16In- input buffer containing UTF-16 code units to append
-
append
Appends UTF-16 code units directly from aStringwithout allocating a temporaryCharBufferor intermediate char array.Uses a highly optimized monomorphic
Stringconversion path, allowing HotSpot C2 to inlineString.charAt(int)directly down to raw memory reads on the hotCharStreams.fromString(String)path.Package-private because the runtime's public string factory is
CharStreams.fromString(String).- Parameters:
utf16In- input string containing UTF-16 code units to append
-
appendStringByte
-
appendStringChar
-
appendStringInt
-
appendArrayByte
private void appendArrayByte(char[] in, int start, int limit) -
appendArrayChar
private void appendArrayChar(char[] in, int start, int limit) -
appendArrayInt
private void appendArrayInt(char[] in, int start, int limit) -
appendCharSequenceByte
-
appendCharSequenceChar
-
appendCharSequenceInt
-
byteToCharBuffer
private void byteToCharBuffer(int toAppend) -
byteToIntBuffer
private void byteToIntBuffer(int toAppend) -
charToIntBuffer
private void charToIntBuffer(int toAppend)
-