Class CodePointBuffer.Builder

java.lang.Object
org.antlr.v4.runtime.CodePointBuffer.Builder
Enclosing class:
CodePointBuffer

public static class CodePointBuffer.Builder extends Object
  • Field Details

  • Constructor Details

    • Builder

      private Builder(int initialBufferSize)
  • Method Details

    • getType

    • getByteBuffer

      ByteBuffer getByteBuffer()
    • getCharBuffer

      CharBuffer getCharBuffer()
    • getIntBuffer

      IntBuffer getIntBuffer()
    • build

      public CodePointBuffer build()
    • roundUpToNextPowerOfTwo

      private static int roundUpToNextPowerOfTwo(int i)
    • ensureRemaining

      public void ensureRemaining(int remainingNeeded)
    • append

      public void append(CharBuffer utf16In)
      Appends UTF-16 code units from utf16In.

      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 as CharBuffer.wrap(CharSequence)) fall back to a zero-copy CharSequence interface path without throwing ReadOnlyBufferException.

      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

      void append(String utf16In)
      Appends UTF-16 code units directly from a String without allocating a temporary CharBuffer or intermediate char array.

      Uses a highly optimized monomorphic String conversion path, allowing HotSpot C2 to inline String.charAt(int) directly down to raw memory reads on the hot CharStreams.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

      private void appendStringByte(String utf16In, int start)
    • appendStringChar

      private void appendStringChar(String utf16In, int start)
    • appendStringInt

      private void appendStringInt(String utf16In, int start)
    • 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

      private void appendCharSequenceByte(CharSequence utf16In, int start, int end)
    • appendCharSequenceChar

      private void appendCharSequenceChar(CharSequence utf16In, int start, int end)
    • appendCharSequenceInt

      private void appendCharSequenceInt(CharSequence utf16In, int start, int end)
    • byteToCharBuffer

      private void byteToCharBuffer(int toAppend)
    • byteToIntBuffer

      private void byteToIntBuffer(int toAppend)
    • charToIntBuffer

      private void charToIntBuffer(int toAppend)