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
-
-
Field Summary
-
Fields inherited from class org.asciidoctor.jruby.internal.RubyObjectWrapper
rubyNode, runtime
-
-
Constructor Summary
Constructors Constructor Description ReaderImpl(org.jruby.runtime.builtin.IRubyObject rubyNode)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleanadvance()Advance to the next line by discarding the line at the front of the stackjava.lang.StringgetDir()Get the name of the directory of the current filejava.lang.StringgetFile()Get the name of the file of the current line.intgetLineno()Deprecated.intgetLineNumber()Get the 1-based offset of the current line.booleanhasMoreLines()Check whether there are any lines left to read.booleanisNextLineEmpty()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.java.util.List<java.lang.String>lines()java.lang.StringpeekLine()Peek at the next line of source data.java.util.List<java.lang.String>peekLines(int lineCount)Peek at the next multiple lines of source data.java.lang.Stringread()Get the remaining lines of source data joined as a String.java.lang.StringreadLine()Get the next line of source data.java.util.List<java.lang.String>readLines()Get the remaining lines of source data.voidrestoreLine(java.lang.String line)Push the String line onto the beginning of the Array of source data.voidrestoreLines(java.util.List<java.lang.String> lines)Push multiple lines onto the beginning of the Array of source data.voidterminate()Public: Advance to the end of the reader, consuming all remaining lines-
Methods inherited from class org.asciidoctor.jruby.internal.RubyObjectWrapper
getBoolean, getInt, getList, getProperty, getRubyObject, getRubyProperty, getRuntime, getString, getSymbol, setBoolean, setInt, setRubyProperty, setString, setSymbol, toJava, toJava
-
-
-
-
Method Detail
-
getLineno
@Deprecated public int getLineno()
Deprecated.Description copied from interface:ReaderGet the 1-based offset of the current line.
-
getLineNumber
public int getLineNumber()
Description copied from interface:ReaderGet the 1-based offset of the current line.- Specified by:
getLineNumberin interfaceReader- Returns:
- 1-based offset.
-
getFile
public java.lang.String getFile()
Description copied from interface:ReaderGet the name of the file of the current line.
-
getDir
public java.lang.String getDir()
Description copied from interface:ReaderGet the name of the directory of the current file
-
hasMoreLines
public boolean hasMoreLines()
Description copied from interface:ReaderCheck 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:
hasMoreLinesin interfaceReader- Returns:
- True if there are more lines, False if there are not.
-
isNextLineEmpty
public boolean isNextLineEmpty()
Description copied from interface:ReaderPeek 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:
isNextLineEmptyin interfaceReader- Returns:
- True if the there are no more lines or if the next line is empty
-
read
public java.lang.String read()
Description copied from interface:ReaderGet the remaining lines of source data joined as a String. Delegates to Reader#read_lines, then joins the result.
-
readLines
public java.util.List<java.lang.String> readLines()
Description copied from interface:ReaderGet 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.
-
readLine
public java.lang.String readLine()
Description copied from interface:ReaderGet the next line of source data. Consumes the line returned.
-
restoreLine
public void restoreLine(java.lang.String line)
Description copied from interface:ReaderPush 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:
restoreLinein interfaceReader
-
restoreLines
public void restoreLines(java.util.List<java.lang.String> lines)
Description copied from interface:ReaderPush 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:
restoreLinesin interfaceReader
-
peekLine
public java.lang.String peekLine()
Description copied from interface:ReaderPeek 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
public java.util.List<java.lang.String> peekLines(int lineCount)
Description copied from interface:ReaderPeek at the next multiple lines of source data. Processes the lines, if not already marked as processed, but does not consume them.
-
advance
public boolean advance()
Description copied from interface:ReaderAdvance to the next line by discarding the line at the front of the stack
-
-