com.go.trove.io
Class PushbackPositionReader

java.lang.Object
  |
  +--java.io.Reader
        |
        +--java.io.FilterReader
              |
              +--com.go.trove.io.PositionReader
                    |
                    +--com.go.trove.io.PushbackPositionReader
Direct Known Subclasses:
SourceReader

public class PushbackPositionReader
extends PositionReader

The PushbackPositionReader is a kind of pushback reader that tracks the postion in the stream of the next character to be read. The java.io.PushbackReader allows arbitrary characters to be pushed back. Since this Reader may need to keep track of how many characters were scanned from the underlying Reader to actually produce a character, the unread operation cannot accept any arbitrary character.

Version:
12 , 12/11/00
Author:
Brian S O'Neill
See Also:
java.io.PushbackReader

Fields inherited from class com.go.trove.io.PositionReader
mPosition, mPosReader
 
Fields inherited from class java.io.FilterReader
in
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
PushbackPositionReader(java.io.Reader reader)
           
PushbackPositionReader(java.io.Reader reader, int pushback)
           
 
Method Summary
 int getStartPosition()
           
 int peek()
           
 int read()
           
 void unread()
          Unread the last character read.
 void unread(int amount)
          Unread the last several characters read.
protected  void unreadHook(int c)
          A hook call from the unread method(s).
 
Methods inherited from class com.go.trove.io.PositionReader
close, getNextPosition, read
 
Methods inherited from class java.io.FilterReader
mark, markSupported, ready, reset, skip
 
Methods inherited from class java.io.Reader
read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PushbackPositionReader

public PushbackPositionReader(java.io.Reader reader)

PushbackPositionReader

public PushbackPositionReader(java.io.Reader reader,
                              int pushback)
Method Detail

getStartPosition

public int getStartPosition()
Returns:
the start position of the last read character.

read

public int read()
         throws java.io.IOException
Overrides:
read in class PositionReader

peek

public int peek()
         throws java.io.IOException

unread

public void unread(int amount)
            throws java.io.IOException
Unread the last several characters read.

Unlike PushbackReader, unread does not allow arbitrary characters to to be unread. Rather, it functions like an undo operation.

Parameters:
amount - Amount of characters to unread.
See Also:
java.io.PushbackReader#unread(int)

unread

public void unread()
            throws java.io.IOException
Unread the last character read.

Unlike PushbackReader, unread does not allow arbitrary characters to to be unread. Rather, it functions like an undo operation.

See Also:
java.io.PushbackReader#unread(int)

unreadHook

protected void unreadHook(int c)
A hook call from the unread method(s). Every unread character is passed to this method.