public class RememberBytesInputStream
extends java.io.FilterInputStream
In record mode this stream remembers all the bytes a caller reads or skips. After reading some bytes this returns a 'replay' stream to re-read them.
A caller may call getReplaySteam to get a stream to re-read the the remembered bytes. Any number of calls to getReplayStream are supported.
The clear function causes this stream to forget the remembered bytes and re-enter record mode.
Modifier and Type | Field and Description |
---|---|
(package private) ByteHolder |
bh |
(package private) boolean |
recording |
(package private) boolean |
streamClosed |
Constructor and Description |
---|
RememberBytesInputStream(java.io.InputStream in,
ByteHolder bh)
Construct a RememberBytesInputStream.
|
Modifier and Type | Method and Description |
---|---|
int |
available()
Return the number of bytes remains in the byteHolder
for reading, without setting the write/read mode.
|
void |
clear()
Clear all the remembered bytes.
|
long |
fillBuf(int len)
read len bytes from the input stream, and store it in the byte holder.
|
ByteHolder |
getByteHolder()
Get the byteHolder.
|
java.io.InputStream |
getReplayStream()
Get an input stream for re-reading the remembered bytes.
|
int |
numBytesSaved()
Return the number of bytes that have been saved to this byte holder.
|
int |
putBuf(java.io.OutputStream out,
int len)
read len bytes from the byte holder, and write it to the output stream.
|
int |
read() |
int |
read(byte[] b,
int off,
int len) |
boolean |
recording()
Return true iff this RememberBytesInputStream is
in recording mode.
|
void |
setInput(java.io.InputStream in)
Set the InputStream from which this reads.
|
int |
shiftToFront()
remove the remaining bytes in the byteHolder to the beginning
set the position to start recording just after these bytes.
|
long |
skip(long count) |
java.lang.String |
toString() |
ByteHolder bh
boolean recording
boolean streamClosed
public RememberBytesInputStream(java.io.InputStream in, ByteHolder bh)
bh
- for storing the remembered bytes. (must be
in writing mode.public int read() throws java.io.IOException
read
in class java.io.FilterInputStream
java.io.IOException
- thrown on an io error spooling rememberd bytes
to backing storage.InputStream.read()
public int read(byte[] b, int off, int len) throws java.io.IOException
read
in class java.io.FilterInputStream
java.io.IOException
- thrown on an io error spooling rememberd bytes
to backing storage.InputStream.read()
public long fillBuf(int len) throws java.io.IOException
java.io.IOException
- thrown on an io error spooling rememberd bytes
to backing storage.public int putBuf(java.io.OutputStream out, int len) throws java.io.IOException
java.io.IOException
- thrown on an io error spooling rememberd bytes
to backing storage.public long skip(long count) throws java.io.IOException
skip
in class java.io.FilterInputStream
java.io.IOException
- thrown on an io error spooling rememberd bytes
to backing storage.InputStream.skip(long)
public java.io.InputStream getReplayStream() throws java.io.IOException
java.io.IOException
public ByteHolder getByteHolder() throws java.io.IOException
java.io.IOException
public void clear() throws java.io.IOException
java.io.IOException
- thrown on an io error clearing backing
storage.public void setInput(java.io.InputStream in)
Please note this does not clear remembered bytes.
public boolean recording()
public int available() throws java.io.IOException
available
in class java.io.FilterInputStream
java.io.IOException
public int numBytesSaved() throws java.io.IOException
java.io.IOException
public int shiftToFront() throws java.io.IOException
java.io.IOException
public java.lang.String toString()
toString
in class java.lang.Object
Object.toString()
Apache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.