net.sf.statcvs.util
Class LookaheadReader

java.lang.Object
  extended bynet.sf.statcvs.util.LookaheadReader

public class LookaheadReader
extends java.lang.Object

Wraps a Reader for line-by-line access. Allows reading the current line multiple times. At construction time, the LookaheadReader points to line 1 of the source reader. Calls to getCurrentLine() will return the first line of the source reader. A call to getNextLine() causes a readLine from the source reader. Subsequent calls to getCurrentLine() will return the second line of the source reader.

Version:
$Id: LookaheadReader.java,v 1.2 2003/06/02 23:18:58 cyganiak Exp $
Author:
Richard Cyganiak

Constructor Summary
LookaheadReader(java.io.Reader reader)
          Constructor
 
Method Summary
 java.lang.String getCurrentLine()
          Returns the current line without reading a line from the source reader.
 int getLineNumber()
          Returns the current line number
 java.lang.String getNextLine()
          Reads and returns a line from the source reader.
 boolean isAfterEnd()
          Returns true if the last call to getNextLine() returned null
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LookaheadReader

public LookaheadReader(java.io.Reader reader)
Constructor

Parameters:
reader - a BufferedReader
Method Detail

getCurrentLine

public java.lang.String getCurrentLine()
                                throws java.io.IOException
Returns the current line without reading a line from the source reader. At construction time, the source reader's first line is the current line.

Returns:
the current line, or null if at the end of the source reader
Throws:
java.io.IOException - on error while reading the source reader

getNextLine

public java.lang.String getNextLine()
                             throws java.io.IOException
Reads and returns a line from the source reader. The result of this call will be the new current line.

Returns:
the next line of the source reader, or null if at the end of the source reader
Throws:
java.io.IOException - on error while reading the source reader

getLineNumber

public int getLineNumber()
                  throws java.io.IOException
Returns the current line number

Returns:
the current line number, starting at 1
Throws:
java.io.IOException - on error while reading the underlying reader

isAfterEnd

public boolean isAfterEnd()
                   throws java.io.IOException
Returns true if the last call to getNextLine() returned null

Returns:
true if pointer is behind the end of the source reader
Throws:
java.io.IOException - on error while reading the source reader