Class ReaderImpl

java.lang.Object
org.asciidoctor.jruby.internal.RubyObjectWrapper
org.asciidoctor.jruby.extension.internal.ReaderImpl
All Implemented Interfaces:
Reader
Direct Known Subclasses:
PreprocessorReaderImpl

public class ReaderImpl extends RubyObjectWrapper implements Reader
  • Constructor Details

    • ReaderImpl

      public ReaderImpl(org.jruby.runtime.builtin.IRubyObject rubyNode)
  • Method Details

    • getLineno

      @Deprecated public int getLineno()
      Deprecated.
      Description copied from interface: Reader
      Get the 1-based offset of the current line.
      Specified by:
      getLineno in interface Reader
      Returns:
      1-based offset.
    • getLineNumber

      public int getLineNumber()
      Description copied from interface: Reader
      Get the 1-based offset of the current line.
      Specified by:
      getLineNumber in interface Reader
      Returns:
      1-based offset.
    • getFile

      public String getFile()
      Description copied from interface: Reader
      Get the name of the file of the current line.
      Specified by:
      getFile in interface Reader
      Returns:
      file name
    • getDir

      public String getDir()
      Description copied from interface: Reader
      Get the name of the directory of the current file
      Specified by:
      getDir in interface Reader
      Returns:
      directory name
    • hasMoreLines

      public boolean hasMoreLines()
      Description copied from interface: Reader
      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.
      Specified by:
      hasMoreLines in interface Reader
      Returns:
      True if there are more lines, False if there are not.
    • isNextLineEmpty

      public boolean isNextLineEmpty()
      Description copied from interface: Reader
      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.
      Specified by:
      isNextLineEmpty in interface Reader
      Returns:
      True if the there are no more lines or if the next line is empty
    • read

      public String read()
      Description copied from interface: Reader
      Get the remaining lines of source data joined as a String. Delegates to Reader#read_lines, then joins the result.
      Specified by:
      read in interface Reader
      Returns:
      the lines read joined as a String
    • readLines

      public List<String> readLines()
      Description copied from interface: Reader
      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.
      Specified by:
      readLines in interface Reader
      Returns:
      the lines read as a String Array
    • readLine

      public String readLine()
      Description copied from interface: Reader
      Get the next line of source data. Consumes the line returned.
      Specified by:
      readLine in interface Reader
      Returns:
      the String of the next line of the source data if data is present or nulll if there is no more data.
    • lines

      public List<String> lines()
      Specified by:
      lines in interface Reader
    • restoreLine

      public void restoreLine(String line)
      Description copied from interface: Reader
      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.
      Specified by:
      restoreLine in interface Reader
    • restoreLines

      public void restoreLines(List<String> lines)
      Description copied from interface: Reader
      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.
      Specified by:
      restoreLines in interface Reader
    • peekLine

      public String peekLine()
      Description copied from interface: Reader
      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.
      Specified by:
      peekLine in interface Reader
    • peekLines

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

      public boolean advance()
      Description copied from interface: Reader
      Advance to the next line by discarding the line at the front of the stack
      Specified by:
      advance in interface Reader
      Returns:
      a Boolean indicating whether there was a line to discard.
    • terminate

      public void terminate()
      Description copied from interface: Reader
      Public: Advance to the end of the reader, consuming all remaining lines
      Specified by:
      terminate in interface Reader