Interface RandomAccessReader

All Known Implementing Classes:
ClassfileReader, RandomAccessArrayReader, RandomAccessByteBufferReader, RandomAccessFileChannelReader

public interface RandomAccessReader
Interface for random access to values in byte order.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    read(long srcOffset, byte[] dstArr, int dstArrStart, int numBytes)
    Read bytes into a byte array.
    int
    read(long srcOffset, ByteBuffer dstBuf, int dstBufStart, int numBytes)
    Read bytes into a ByteBuffer.
    byte
    readByte(long offset)
    Read a byte at a specific offset (without changing the current cursor offset).
    int
    readInt(long offset)
    Read a int at a specific offset (without changing the current cursor offset).
    long
    readLong(long offset)
    Read a long at a specific offset (without changing the current cursor offset).
    short
    readShort(long offset)
    Read a short at a specific offset (without changing the current cursor offset).
    readString(long offset, int numBytes)
    Reads the "modified UTF8" format defined in the Java classfile spec.
    readString(long offset, int numBytes, boolean replaceSlashWithDot, boolean stripLSemicolon)
    Reads the "modified UTF8" format defined in the Java classfile spec, optionally replacing '/' with '.', and optionally removing the prefix "L" and the suffix ";".
    int
    readUnsignedByte(long offset)
    Read an unsigned byte at a specific offset (without changing the current cursor offset).
    long
    readUnsignedInt(long offset)
    Read a unsigned int at a specific offset (without changing the current cursor offset).
    int
    readUnsignedShort(long offset)
    Read a unsigned short at a specific offset (without changing the current cursor offset).
  • Method Details

    • read

      int read(long srcOffset, ByteBuffer dstBuf, int dstBufStart, int numBytes) throws IOException
      Read bytes into a ByteBuffer.
      Parameters:
      srcOffset - The offset to start reading from.
      dstBuf - The ByteBuffer to write into.
      dstBufStart - The offset within the destination buffer to start writing at.
      numBytes - The number of bytes to read.
      Returns:
      The number of bytes actually read, or -1 if no more bytes could be read.
      Throws:
      IOException - If there was an exception while reading.
    • read

      int read(long srcOffset, byte[] dstArr, int dstArrStart, int numBytes) throws IOException
      Read bytes into a byte array.
      Parameters:
      srcOffset - The offset to start reading from.
      dstArr - The byte array to write into.
      dstArrStart - The offset within the destination array to start writing at.
      numBytes - The number of bytes to read.
      Returns:
      The number of bytes actually read, or -1 if no more bytes could be read.
      Throws:
      IOException - If there was an exception while reading.
    • readByte

      byte readByte(long offset) throws IOException
      Read a byte at a specific offset (without changing the current cursor offset).
      Parameters:
      offset - The buffer offset to read from.
      Returns:
      The byte at the offset.
      Throws:
      IOException - If there was an exception while reading.
    • readUnsignedByte

      int readUnsignedByte(long offset) throws IOException
      Read an unsigned byte at a specific offset (without changing the current cursor offset).
      Parameters:
      offset - The buffer offset to read from.
      Returns:
      The unsigned byte at the offset.
      Throws:
      IOException - If there was an exception while reading.
    • readShort

      short readShort(long offset) throws IOException
      Read a short at a specific offset (without changing the current cursor offset).
      Parameters:
      offset - The buffer offset to read from.
      Returns:
      The short at the offset.
      Throws:
      IOException - If there was an exception while reading.
    • readUnsignedShort

      int readUnsignedShort(long offset) throws IOException
      Read a unsigned short at a specific offset (without changing the current cursor offset).
      Parameters:
      offset - The buffer offset to read from.
      Returns:
      The unsigned short at the offset.
      Throws:
      IOException - If there was an exception while reading.
    • readInt

      int readInt(long offset) throws IOException
      Read a int at a specific offset (without changing the current cursor offset).
      Parameters:
      offset - The buffer offset to read from.
      Returns:
      The int at the offset.
      Throws:
      IOException - If there was an exception while reading.
    • readUnsignedInt

      long readUnsignedInt(long offset) throws IOException
      Read a unsigned int at a specific offset (without changing the current cursor offset).
      Parameters:
      offset - The buffer offset to read from.
      Returns:
      The int at the offset, as a long.
      Throws:
      IOException - If there was an exception while reading.
    • readLong

      long readLong(long offset) throws IOException
      Read a long at a specific offset (without changing the current cursor offset).
      Parameters:
      offset - The buffer offset to read from.
      Returns:
      The long at the offset.
      Throws:
      IOException - If there was an exception while reading.
    • readString

      String readString(long offset, int numBytes, boolean replaceSlashWithDot, boolean stripLSemicolon) throws IOException
      Reads the "modified UTF8" format defined in the Java classfile spec, optionally replacing '/' with '.', and optionally removing the prefix "L" and the suffix ";".
      Parameters:
      offset - The start offset of the string.
      numBytes - The number of bytes of the UTF8 encoding of the string.
      replaceSlashWithDot - If true, replace '/' with '.'.
      stripLSemicolon - If true, string final ';' character.
      Returns:
      The string.
      Throws:
      IOException - If an I/O exception occurs.
    • readString

      String readString(long offset, int numBytes) throws IOException
      Reads the "modified UTF8" format defined in the Java classfile spec.
      Parameters:
      offset - The start offset of the string.
      numBytes - The number of bytes of the UTF8 encoding of the string.
      Returns:
      The string.
      Throws:
      IOException - If an I/O exception occurs.