com.thaiopensource.validate.auto
Class RewindableReader

java.lang.Object
  extended by java.io.Reader
      extended by com.thaiopensource.validate.auto.RewindableReader
All Implemented Interfaces:
Rewindable, Closeable, Readable

public class RewindableReader
extends Reader
implements Rewindable

Rewindable implementation over a reader. Modified from RewindableInputStream by replacing the input stream with a reader.

Author:
george

Nested Class Summary
(package private) static class RewindableReader.Block
           
 
Field Summary
private  RewindableReader.Block curBlock
           
private  int curBlockAvail
          If curBlockAvail > 0, then there are curBlockAvail chars available to be returned starting at curBlockPos in curBlock.buf.
private  int curBlockPos
           
private  boolean eof
          true if we have got an EOF from the underlying Reader
private  RewindableReader.Block head
           
private  Reader in
           
private  RewindableReader.Block lastBlock
           
private  boolean pretendClosed
           
private  boolean saving
          true unless willNotRewind has been called
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
RewindableReader(Reader in)
           
 
Method Summary
 boolean canRewind()
           
 void close()
           
 int read()
           
 int read(char[] b, int off, int len)
           
 void rewind()
           
 void willNotRewind()
           
 
Methods inherited from class java.io.Reader
mark, markSupported, read, read, ready, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

head

private RewindableReader.Block head

curBlockAvail

private int curBlockAvail
If curBlockAvail > 0, then there are curBlockAvail chars available to be returned starting at curBlockPos in curBlock.buf.


curBlock

private RewindableReader.Block curBlock

curBlockPos

private int curBlockPos

lastBlock

private RewindableReader.Block lastBlock

saving

private boolean saving
true unless willNotRewind has been called


in

private final Reader in

pretendClosed

private boolean pretendClosed

eof

private boolean eof
true if we have got an EOF from the underlying Reader

Constructor Detail

RewindableReader

public RewindableReader(Reader in)
Method Detail

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Specified by:
close in class Reader
Throws:
IOException

rewind

public void rewind()
Specified by:
rewind in interface Rewindable

canRewind

public boolean canRewind()
Specified by:
canRewind in interface Rewindable

willNotRewind

public void willNotRewind()
Specified by:
willNotRewind in interface Rewindable

read

public int read()
         throws IOException
Overrides:
read in class Reader
Throws:
IOException

read

public int read(char[] b,
                int off,
                int len)
         throws IOException
Specified by:
read in class Reader
Throws:
IOException