Class InputStreamBufferByteSequence

java.lang.Object
ghidra.util.bytesearch.InputStreamBufferByteSequence
All Implemented Interfaces:
ByteSequence

public class InputStreamBufferByteSequence extends Object implements ByteSequence
ByteSequence that buffers an InputStream
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    byte
    getByte(int index)
    Returns the byte at the given index.
    byte[]
    getBytes(int index, int length)
    Returns a byte array containing the bytes from the given range.
    int
    Returns the length of available bytes.
    boolean
    hasAvailableBytes(int index, int length)
    A convenience method for checking if this sequence can provide a range of bytes from some offset.
    void
    load(InputStream is, int amount)
    Loads data into this byte sequence from the given input stream

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • InputStreamBufferByteSequence

      public InputStreamBufferByteSequence(int bufferSize)
  • Method Details

    • load

      public void load(InputStream is, int amount) throws IOException
      Loads data into this byte sequence from the given input stream
      Parameters:
      is - the input stream to read bytes from
      amount - the number of bytes to read from the stream
      Throws:
      IOException - if an error occurs reading from the stream
    • getLength

      public int getLength()
      Description copied from interface: ByteSequence
      Returns the length of available bytes.
      Specified by:
      getLength in interface ByteSequence
      Returns:
      the length of the sequence of bytes
    • getByte

      public byte getByte(int index)
      Description copied from interface: ByteSequence
      Returns the byte at the given index. The index must between 0 and the extended length.
      Specified by:
      getByte in interface ByteSequence
      Parameters:
      index - the index in the byte sequence to retrieve a byte value
      Returns:
      the byte at the given index
    • hasAvailableBytes

      public boolean hasAvailableBytes(int index, int length)
      Description copied from interface: ByteSequence
      A convenience method for checking if this sequence can provide a range of bytes from some offset.
      Specified by:
      hasAvailableBytes in interface ByteSequence
      Parameters:
      index - the index of the start of the range to check for available bytes
      length - the length of the range to check for available bytes
      Returns:
      true if bytes are available for the given range
    • getBytes

      public byte[] getBytes(int index, int length)
      Description copied from interface: ByteSequence
      Returns a byte array containing the bytes from the given range.
      Specified by:
      getBytes in interface ByteSequence
      Parameters:
      index - the start index of the range to get bytes
      length - the number of bytes to get
      Returns:
      a byte array containing the bytes from the given range