Class SequenceReader


public class SequenceReader extends DataReader
Combines one or more DataReaders into a single stream by reading from each until empty then moving to the next.
  • Constructor Details

    • SequenceReader

      public SequenceReader(DataReader... readers)
      Creates a reader over the given readers in order; each is opened only when reached and closed once exhausted.
  • Method Details

    • add

      public SequenceReader add(DataReader reader)
      Appends a reader to the sequence; must be called before open().
    • addExceptionProperties

      public DataException addExceptionProperties(DataException exception)
      Description copied from class: Endpoint
      Adds this endpoint's current state to a DataException. Since this method is called whenever an exception is thrown, subclasses should override it to add their specific information.
      Overrides:
      addExceptionProperties in class DataReader
    • getCount

      public int getCount()
      Returns the number of readers in the sequence.
    • remove

      public SequenceReader remove(DataReader reader)
      Takes a reader out of the sequence; must be called before open().
    • removeAllDataReader

      public SequenceReader removeAllDataReader()
      Empties the sequence; must be called before open().
    • get

      public DataReader get(int index)
      Returns the reader at the given 0-based position in the sequence.
    • open

      public void open() throws DataException
      Description copied from class: DataEndpoint
      Makes this endpoint ready for reading or writing.
      Overrides:
      open in class DataEndpoint
      Throws:
      DataException
    • available

      public int available()
      Description copied from class: DataReader
      Returns the number of records that can probably be read without blocking.
      Overrides:
      available in class DataReader
    • close

      public void close() throws DataException
      Description copied from class: DataEndpoint
      Indicates that this endpoint has finished reading or writing.
      Overrides:
      close in class DataEndpoint
      Throws:
      DataException
    • readImpl

      protected Record readImpl() throws Throwable
      Description copied from class: DataReader
      Overridden by subclasses to read the next record from this DataReader. The default implementation of DataReader.read() now insures that this method will not be called again after it returns a null.

      If no record is available, null will be returned.

      Contract for subclasses (see also docs/authoring/DataReader.md):

      Specified by:
      readImpl in class DataReader
      Throws:
      Throwable