Interface SequentialSource

All Superinterfaces:
AutoCloseable, Closeable
All Known Implementing Classes:
InputStreamSource, RandomAccessSource

interface SequentialSource extends Closeable
A SequentialSource provides access to sequential data for parsing.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Returns offset of next byte to be returned by a read method.
    boolean
    Returns true if this source has been closed.
    boolean
    Returns true if the end of the data source has been reached.
    int
    This will peek at the next byte.
    int
    Read a single byte of data.
    int
    read(byte[] b)
    Read a buffer of data.
    int
    read(byte[] b, int offset, int length)
    Read a buffer of data.
    byte[]
    readFully(int length)
    Reads a given number of bytes in its entirety.
    void
    unread(byte[] bytes)
    Unreads an array of bytes.
    void
    unread(byte[] bytes, int start, int len)
    Unreads a portion of an array of bytes.
    void
    unread(int b)
    Unreads a single byte.

    Methods inherited from interface java.io.Closeable

    close
  • Method Details

    • read

      int read() throws IOException
      Read a single byte of data.
      Returns:
      The byte of data that is being read.
      Throws:
      IOException - If there is an error while reading the data.
    • read

      int read(byte[] b) throws IOException
      Read a buffer of data.
      Parameters:
      b - The buffer to write the data to.
      Returns:
      The number of bytes that were actually read.
      Throws:
      IOException - If there was an error while reading the data.
    • read

      int read(byte[] b, int offset, int length) throws IOException
      Read a buffer of data.
      Parameters:
      b - The buffer to write the data to.
      offset - Offset into the buffer to start writing.
      length - The amount of data to attempt to read.
      Returns:
      The number of bytes that were actually read.
      Throws:
      IOException - If there was an error while reading the data.
    • getPosition

      long getPosition() throws IOException
      Returns offset of next byte to be returned by a read method.
      Returns:
      offset of next byte which will be returned with next read() (if no more bytes are left it returns a value >= length of source).
      Throws:
      IOException - If there was an error while reading the data.
    • peek

      int peek() throws IOException
      This will peek at the next byte.
      Returns:
      The next byte on the stream, leaving it as available to read.
      Throws:
      IOException - If there is an error reading the next byte.
    • unread

      void unread(int b) throws IOException
      Unreads a single byte.
      Parameters:
      b - byte array to push back
      Throws:
      IOException - if there is an error while unreading
    • unread

      void unread(byte[] bytes) throws IOException
      Unreads an array of bytes.
      Parameters:
      bytes - byte array to be unread
      Throws:
      IOException - if there is an error while unreading
    • unread

      void unread(byte[] bytes, int start, int len) throws IOException
      Unreads a portion of an array of bytes.
      Parameters:
      bytes - byte array to be unread
      start - start index
      len - number of bytes to be unread
      Throws:
      IOException - if there is an error while unreading
    • readFully

      byte[] readFully(int length) throws IOException
      Reads a given number of bytes in its entirety.
      Parameters:
      length - the number of bytes to be read
      Returns:
      a byte array containing the bytes just read
      Throws:
      IOException - if an I/O error occurs while reading data
    • isEOF

      boolean isEOF() throws IOException
      Returns true if the end of the data source has been reached.
      Returns:
      true if we are at the end of the data.
      Throws:
      IOException - If there is an error reading the next byte.
    • isClosed

      boolean isClosed() throws IOException
      Returns true if this source has been closed.
      Returns:
      true if the source has been closed
      Throws:
      IOException