Class ParsingReader

Direct Known Subclasses:
CombinedLogReader

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

    • parser

      protected final Parser parser
    • valueBuffer

      protected StringBuilder valueBuffer
    • lineNumber

      protected long lineNumber
  • Constructor Details

    • ParsingReader

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

      public ParsingReader(File file, String charsetName)
    • ParsingReader

      public ParsingReader(Reader reader)
  • Method Details

    • getLineNumber

      public long getLineNumber()
      Returns the current 0-based line number, i.e. the number of line breaks consumed so far.
    • getCharsetName

      public String getCharsetName()
      Returns the charset name given to the constructor or null if the default charset or a Reader is used.
    • 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
    • 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
    • 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
    • fillRecord

      protected boolean fillRecord(Record record) throws Throwable
      Description copied from class: AbstractReader
      Populates the given record with the next row's values; returns false at the end of the input.
      Specified by:
      fillRecord in class AbstractReader
      Throws:
      Throwable
    • matchDOUBLE

      protected void matchDOUBLE()
      Consumes a decimal number such as 1,234.56 or .5 and appends it, without the commas, to valueBuffer.
    • matchINTEGER

      protected void matchINTEGER()
      Consumes an integer that may contain grouping commas and appends its digits to valueBuffer.
    • matchDIGITS

      protected void matchDIGITS()
      Consumes one or more digits and appends them to valueBuffer.
    • matchDIGIT

      protected void matchDIGIT()
      Consumes one digit (0-9) and appends it to valueBuffer, throwing if the next character is not a digit.
    • peekCHARACTER

      protected boolean peekCHARACTER()
      Indicates if the next character is an ASCII letter, without consuming it.
    • matchCHARACTER

      protected void matchCHARACTER()
      Consumes one ASCII letter and appends it to valueBuffer, throwing if the next character is not a letter.
    • matchNEWLINES

      protected void matchNEWLINES()
      Consumes one or more consecutive line breaks (LF, CR or CR LF), counting each in getLineNumber().
    • matchNEWLINE

      protected void matchNEWLINE()
      Consumes one line break (LF, CR or CR LF), increments the line number and starts a new parser column count; throws if there is no line break.
    • matchLINE

      protected void matchLINE()
      Consumes the rest of the current line, appending it to valueBuffer, followed by its line break if there is one.
    • isLetter

      protected boolean isLetter(int c)
      Indicates if the character is an ASCII letter (a-z or A-Z).
    • isDigit

      protected boolean isDigit(int c)
      Indicates if the character is an ASCII digit (0-9).
    • isNewLine

      protected boolean isNewLine(int c)
      Indicates if the character is a carriage return or line feed.
    • match

      protected void match(int c)
      Consumes the given character and appends it to valueBuffer, throwing if the next character differs.
    • isLineageSupported

      public boolean isLineageSupported()
      Description copied from class: DataReader
      Indicates if this reader can capture record and field lineage (false unless overridden by a reader that supports it).
      Overrides:
      isLineageSupported in class DataReader
    • 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