Class InternalByteArray

java.lang.Object
com.oracle.truffle.api.strings.InternalByteArray

public final class InternalByteArray extends Object
Wrapper object containing a TruffleString's internal byte array, along with a byte offset and length defining the region in use.
Since:
22.1
  • Method Details

    • getArray

      public byte[] getArray()
      Get the internal byte array. Do not modify the array's contents!
      Since:
      22.1
    • getOffset

      public int getOffset()
      Get the string region's starting index.
      Since:
      22.1
    • getLength

      public int getLength()
      Get the string region's length.
      Since:
      22.1
    • getEnd

      public int getEnd()
      Get the string region's end (offset + length).
      Since:
      22.1
    • get

      public byte get(int index)
      Read the byte at getArray()[getOffset() + index] and return it as a byte, similar to TruffleString.ReadByteNode. Consider using TruffleString.ReadByteNode (and TruffleString.MaterializeNode before) instead if not needing the byte[] for other purposes, as that will avoid extra copying if the string is stored in native memory.
      Since:
      22.2