com.thaiopensource.validate.auto
Class RewindableInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by com.thaiopensource.validate.auto.RewindableInputStream
All Implemented Interfaces:
Rewindable, Closeable

public class RewindableInputStream
extends InputStream
implements Rewindable


Nested Class Summary
(package private) static class RewindableInputStream.Block
           
 
Field Summary
private  RewindableInputStream.Block curBlock
           
private  int curBlockAvail
          If curBlockAvail > 0, then there are curBlockAvail bytes 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 InputStream
private  RewindableInputStream.Block head
           
private  InputStream in
           
private  RewindableInputStream.Block lastBlock
           
private  boolean pretendClosed
           
private  boolean saving
          true unless willNotRewind has been called
 
Constructor Summary
RewindableInputStream(InputStream in)
           
 
Method Summary
 int available()
           
 boolean canRewind()
           
 void close()
           
 int read()
           
 int read(byte[] b, int off, int len)
           
 void rewind()
           
 void willNotRewind()
           
 
Methods inherited from class java.io.InputStream
mark, markSupported, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

head

private RewindableInputStream.Block head

curBlockAvail

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


curBlock

private RewindableInputStream.Block curBlock

curBlockPos

private int curBlockPos

lastBlock

private RewindableInputStream.Block lastBlock

saving

private boolean saving
true unless willNotRewind has been called


in

private final InputStream in

pretendClosed

private boolean pretendClosed

eof

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

Constructor Detail

RewindableInputStream

public RewindableInputStream(InputStream in)
Method Detail

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Overrides:
close in class InputStream
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
Specified by:
read in class InputStream
Throws:
IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws IOException
Overrides:
read in class InputStream
Throws:
IOException

available

public int available()
              throws IOException
Overrides:
available in class InputStream
Throws:
IOException