Class AbstractModule.ReaderHelper

  • Enclosing class:
    AbstractModule

    private static class AbstractModule.ReaderHelper
    extends java.lang.Object
    The reader helper provides a pushback interface for the reader to read and buffer complete lines.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.String buffer
      The line buffer containing the last line read.
      private java.io.BufferedReader reader
      The reader from which to read the text.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected ReaderHelper​(java.io.BufferedReader reader)
      Creates a new reader helper for the given buffered reader.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Closes the reader.
      boolean hasNext()
      Checks, whether the reader contains a next line.
      java.lang.String next()
      Returns the next line.
      void pushBack​(java.lang.String line)
      Pushes the given line back into the buffer.
      protected java.lang.String readLine()
      Reads the next line skipping all comment lines.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • buffer

        private java.lang.String buffer
        The line buffer containing the last line read.
      • reader

        private final java.io.BufferedReader reader
        The reader from which to read the text.
    • Constructor Detail

      • ReaderHelper

        protected ReaderHelper​(java.io.BufferedReader reader)
        Creates a new reader helper for the given buffered reader.
        Parameters:
        reader - the buffered reader that is the source of the text.
    • Method Detail

      • hasNext

        public boolean hasNext()
                        throws java.io.IOException
        Checks, whether the reader contains a next line. Returns false if the end of the stream has been reached.
        Returns:
        true, if there is a next line to read, false otherwise.
        Throws:
        java.io.IOException - if an error occures.
      • next

        public java.lang.String next()
        Returns the next line.
        Returns:
        the next line.
      • pushBack

        public void pushBack​(java.lang.String line)
        Pushes the given line back into the buffer. Only one line can be contained in the buffer at one time.
        Parameters:
        line - the line that should be pushed back into the buffer.
      • readLine

        protected java.lang.String readLine()
                                     throws java.io.IOException
        Reads the next line skipping all comment lines.
        Returns:
        the next line, or null if no line can be read.
        Throws:
        java.io.IOException - if an IO error occures.
      • close

        public void close()
                   throws java.io.IOException
        Closes the reader.
        Throws:
        java.io.IOException - if an IOError occurs.