Interface Reader

All Known Subinterfaces:
PreprocessorReader
All Known Implementing Classes:
PreprocessorReaderImpl, ReaderImpl

public interface Reader
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Advance to the next line by discarding the line at the front of the stack
    Get the name of the directory of the current file
    Get the name of the file of the current line.
    int
    Deprecated.
    Please use getLineNumber()
    int
    Get the 1-based offset of the current line.
    boolean
    Check whether there are any lines left to read.
    boolean
    Peek at the next line and check if it's empty (i.e., whitespace only) This method Does not consume the line from the stack.
     
    Peek at the next line of source data.
    peekLines(int lineCount)
    Peek at the next multiple lines of source data.
    Get the remaining lines of source data joined as a String.
    Get the next line of source data.
    Get the remaining lines of source data.
    void
    Push the String line onto the beginning of the Array of source data.
    void
    Push multiple lines onto the beginning of the Array of source data.
    void
    Public: Advance to the end of the reader, consuming all remaining lines
  • Method Details

    • getLineno

      @Deprecated int getLineno()
      Deprecated.
      Please use getLineNumber()
      Get the 1-based offset of the current line.
      Returns:
      1-based offset.
    • getLineNumber

      int getLineNumber()
      Get the 1-based offset of the current line.
      Returns:
      1-based offset.
    • getFile

      String getFile()
      Get the name of the file of the current line.
      Returns:
      file name
    • getDir

      String getDir()
      Get the name of the directory of the current file
      Returns:
      directory name
    • hasMoreLines

      boolean hasMoreLines()
      Check whether there are any lines left to read. If a previous call to this method resulted in a value of false, immediately returned the cached value. Otherwise, delegate to peek_line to determine if there is a next line available.
      Returns:
      True if there are more lines, False if there are not.
    • isNextLineEmpty

      boolean isNextLineEmpty()
      Peek at the next line and check if it's empty (i.e., whitespace only) This method Does not consume the line from the stack.
      Returns:
      True if the there are no more lines or if the next line is empty
    • read

      String read()
      Get the remaining lines of source data joined as a String. Delegates to Reader#read_lines, then joins the result.
      Returns:
      the lines read joined as a String
    • readLines

      List<String> readLines()
      Get the remaining lines of source data. This method calls Reader#read_line repeatedly until all lines are consumed and returns the lines as a String Array. This method differs from Reader#lines in that it processes each line in turn, hence triggering any preprocessors implemented in sub-classes.
      Returns:
      the lines read as a String Array
    • readLine

      String readLine()
      Get the next line of source data. Consumes the line returned.
      Returns:
      the String of the next line of the source data if data is present or nulll if there is no more data.
    • lines

      List<String> lines()
    • restoreLine

      void restoreLine(String line)
      Push the String line onto the beginning of the Array of source data. Since this line was (assumed to be) previously retrieved through the reader, it is marked as seen.
    • restoreLines

      void restoreLines(List<String> line)
      Push multiple lines onto the beginning of the Array of source data. Since this lines were (assumed to be) previously retrieved through the reader, they are marked as seen.
    • peekLine

      String peekLine()
      Peek at the next line of source data. Processes the line, if not already marked as processed, but does not consume it. This method will probe the reader for more lines.
    • peekLines

      List<String> peekLines(int lineCount)
      Peek at the next multiple lines of source data. Processes the lines, if not already marked as processed, but does not consume them.
      Parameters:
      lineCount - The Integer number of lines to peek.
      Returns:
    • advance

      boolean advance()
      Advance to the next line by discarding the line at the front of the stack
      Returns:
      a Boolean indicating whether there was a line to discard.
    • terminate

      void terminate()
      Public: Advance to the end of the reader, consuming all remaining lines