net.sf.japaki.text
Class ParseReader

java.lang.Object
  extended by net.sf.japaki.text.ParseReader
All Implemented Interfaces:
Closeable, RestorableIO<ParseReader>, PathTracker
Direct Known Subclasses:
ReaderWithPosition

public abstract class ParseReader
extends Object
implements RestorableIO<ParseReader>, PathTracker

A ParseReader is used for parsing an input stream. It stores all necessary information about the input stream and the parsing status.


Constructor Summary
ParseReader()
           
 
Method Summary
abstract  void checkForException(String errorMessage)
          Creates a parsing exception with the specified error message.
abstract  boolean eof()
          Checks if the input stream is at its end.
abstract  ParsePosition getPosition()
          Returns the current parse position.
abstract  String getSource()
          Returns the current line of the input stream.
abstract  void newLine()
          Forwards to the next line in the input stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.japaki.io.RestorableIO
copyFrom, deepCopy
 
Methods inherited from interface java.io.Closeable
close
 
Methods inherited from interface net.sf.japaki.text.PathTracker
getPath
 

Constructor Detail

ParseReader

public ParseReader()
Method Detail

newLine

public abstract void newLine()
                      throws IOException,
                             ParseException
Forwards to the next line in the input stream.

Throws:
IOException - if an I/O error occurs
ParseException - if end of current line was not reached

eof

public abstract boolean eof()
Checks if the input stream is at its end.

Returns:
true if end of file is reached

getSource

public abstract String getSource()
Returns the current line of the input stream.

Returns:
A string containing the contents of the last line read, not including any line-termination characters, or null if the end of the stream has been reached.
See Also:
BufferedReader.readLine()

getPosition

public abstract ParsePosition getPosition()
Returns the current parse position.

Returns:
the current parse position

checkForException

public abstract void checkForException(String errorMessage)
                                throws ParsingException
Creates a parsing exception with the specified error message.

Parameters:
errorMessage - message set in the exception
Throws:
ParsingException - if the error index of the parse position is set.