|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.InputStream org.archive.io.RecordingInputStream
public class RecordingInputStream
Stream which records all data read from it, which it acquires from a wrapped input stream. Makes use of a RecordingOutputStream for recording because of its being file backed so we can write massive amounts of data w/o worrying about overflowing memory.
Field Summary | |
---|---|
protected byte[] |
drainBuffer
Reusable buffer to avoid reallocation on each readFullyUntil |
protected static java.util.logging.Logger |
logger
|
Constructor Summary | |
---|---|
RecordingInputStream(int bufferSize,
java.lang.String backingFilename)
Create a new RecordingInputStream. |
Method Summary | |
---|---|
void |
close()
|
void |
closeRecorder()
|
void |
copyContentBodyTo(java.io.File tempFile)
|
long |
getContentBegin()
|
ReplayInputStream |
getContentReplayInputStream()
|
byte[] |
getDigestValue()
Return the digest value for any recorded, digested data. |
ReplayCharSequence |
getReplayCharSequence()
|
ReplayCharSequence |
getReplayCharSequence(java.lang.String characterEncoding)
|
ReplayInputStream |
getReplayInputStream()
|
long |
getResponseContentLength()
|
long |
getSize()
|
boolean |
isOpen()
|
void |
mark(int readlimit)
|
void |
markContentBegin()
|
boolean |
markSupported()
|
void |
open(java.io.InputStream wrappedStream)
|
int |
read()
|
int |
read(byte[] b)
|
int |
read(byte[] b,
int off,
int len)
|
long |
readFully()
|
void |
readFullyOrUntil(long softMaxLength)
Read all of a stream (Or read until we timeout or have read to the max). |
void |
reset()
|
void |
setDigest(java.security.MessageDigest md)
Sets a digest function which may be applied to recorded data. |
void |
setDigest(java.lang.String algorithm)
Sets a digest algorithm which may be applied to recorded data. |
void |
setLimits(long hardMax,
long timeoutMs,
long maxRateKBps)
Set limits to be enforced by internal recording-out |
void |
setSha1Digest()
Convenience method for setting SHA1 digest. |
void |
startDigest()
|
Methods inherited from class java.io.InputStream |
---|
available, skip |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static java.util.logging.Logger logger
protected byte[] drainBuffer
Constructor Detail |
---|
public RecordingInputStream(int bufferSize, java.lang.String backingFilename)
bufferSize
- Size of buffer to use.backingFilename
- Name of backing file.Method Detail |
---|
public void open(java.io.InputStream wrappedStream) throws java.io.IOException
java.io.IOException
public int read() throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
public int read(byte[] b, int off, int len) throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
public int read(byte[] b) throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in class java.io.InputStream
java.io.IOException
public ReplayInputStream getReplayInputStream() throws java.io.IOException
java.io.IOException
public ReplayInputStream getContentReplayInputStream() throws java.io.IOException
java.io.IOException
public long readFully() throws java.io.IOException
java.io.IOException
public void readFullyOrUntil(long softMaxLength) throws java.io.IOException, RecorderLengthExceededException, RecorderTimeoutException, java.lang.InterruptedException
softMaxLength
- Maximum length to read; if zero or < 0, then no
limit. If met, return normally.hardMaxLength
- Maximum length to read; if zero or < 0, then no
limit. If exceeded, throw RecorderLengthExceededExceptiontimeout
- Timeout in milliseconds for total read; if zero or
negative, timeout is Long.MAX_VALUE
. If exceeded, throw
RecorderTimeoutExceptionmaxBytesPerMs
- How many bytes per millisecond.
java.io.IOException
- failed read.
RecorderLengthExceededException
RecorderTimeoutException
java.lang.InterruptedException
public long getSize()
public void markContentBegin()
public long getContentBegin()
public void startDigest()
public void setSha1Digest()
public void setDigest(java.lang.String algorithm)
algorithm
- public void setDigest(java.security.MessageDigest md)
md
- public byte[] getDigestValue()
public ReplayCharSequence getReplayCharSequence() throws java.io.IOException
java.io.IOException
public ReplayCharSequence getReplayCharSequence(java.lang.String characterEncoding) throws java.io.IOException
characterEncoding
- Encoding of recorded stream.
java.io.IOException
public long getResponseContentLength()
public void closeRecorder() throws java.io.IOException
java.io.IOException
public void copyContentBodyTo(java.io.File tempFile) throws java.io.IOException
tempFile
-
java.io.IOException
public boolean isOpen()
public void mark(int readlimit)
mark
in class java.io.InputStream
public boolean markSupported()
markSupported
in class java.io.InputStream
public void reset() throws java.io.IOException
reset
in class java.io.InputStream
java.io.IOException
public void setLimits(long hardMax, long timeoutMs, long maxRateKBps)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |