Class TextReader

Direct Known Subclasses:
CSVReader, FixedWidthReader

public abstract class TextReader extends AbstractReader
Abstract super-class for obtaining records from a text stream.
  • Field Details

  • Constructor Details

    • TextReader

      public TextReader(File file)
      Creates a reader for the file using the default charset; the file is opened by this constructor rather than by open().
    • TextReader

      public TextReader(Reader reader)
  • Method Details

    • 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
    • open

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

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

      public File getFile()
      Returns the source file or null if this reader was created from a Reader.
    • getLineNumber

      public long getLineNumber()
      Returns the underlying stream's current line number, which starts at 0 and increases with each line terminator read.
    • addLineage

      protected Record addLineage(Record record)
      Description copied from class: DataReader
      Called by DataReader.read() for each record from DataReader.readImpl() while lineage is saved; the default copies recordLineage into every field along with its original index and name. Overrides set their source details on recordLineage first and end with super.addLineage(record).
      Overrides:
      addLineage in class DataReader
    • 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 AbstractReader
    • 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):

      Overrides:
      readImpl in class AbstractReader
      Throws:
      Throwable