public class UnreliableFilterInputStream
extends java.io.FilterInputStream
Modifier and Type | Field and Description |
---|---|
private int |
bytesReadBeforeException |
private int |
currNumErrors
Current number of errors that have been triggered.
|
private boolean |
isFakeIOException |
private int |
marked |
private int |
maxNumErrors
Max number of errors that can be triggered.
|
private int |
position |
private int |
resetCount |
private int |
resetIntervalBeforeException
used to control whether an exception would be thrown based on the reset
recurrence; not applicable if set to zero.
|
Constructor and Description |
---|
UnreliableFilterInputStream(java.io.InputStream in,
boolean isFakeIOException) |
Modifier and Type | Method and Description |
---|---|
int |
getBytesReadBeforeException() |
int |
getCurrNumErrors() |
int |
getMarked() |
int |
getMaxNumErrors() |
int |
getPosition() |
int |
getResetCount() |
int |
getResetIntervalBeforeException() |
boolean |
isFakeIOException() |
void |
mark(int readlimit) |
int |
read() |
int |
read(byte[] b,
int off,
int len) |
void |
reset() |
java.lang.String |
toString() |
private void |
triggerError() |
UnreliableFilterInputStream |
withBytesReadBeforeException(int bytesReadBeforeException) |
UnreliableFilterInputStream |
withMaxNumErrors(int maxNumErrors) |
UnreliableFilterInputStream |
withResetIntervalBeforeException(int resetIntervalBeforeException) |
private int maxNumErrors
private int currNumErrors
private int bytesReadBeforeException
private int marked
private int position
private final boolean isFakeIOException
private int resetCount
private int resetIntervalBeforeException
public UnreliableFilterInputStream(java.io.InputStream in, boolean isFakeIOException)
public int read() throws java.io.IOException
read
in class java.io.FilterInputStream
java.io.IOException
public int read(byte[] b, int off, int len) throws java.io.IOException
read
in class java.io.FilterInputStream
java.io.IOException
public void mark(int readlimit)
mark
in class java.io.FilterInputStream
public void reset() throws java.io.IOException
reset
in class java.io.FilterInputStream
java.io.IOException
private void triggerError() throws FakeIOException
FakeIOException
public int getCurrNumErrors()
public int getMaxNumErrors()
public UnreliableFilterInputStream withMaxNumErrors(int maxNumErrors)
public UnreliableFilterInputStream withBytesReadBeforeException(int bytesReadBeforeException)
public int getBytesReadBeforeException()
public UnreliableFilterInputStream withResetIntervalBeforeException(int resetIntervalBeforeException)
resetIntervalBeforeException
- used to control whether an exception would be thrown based on
the reset recurrence; not applicable if set to zero. For
example, if resetIntervalBeforeException == n, the exception
can only be thrown before the n_th reset (or after the n_th
minus 1 reset), 2n_th reset (or after the 2n_th minus 1)
reset), etc.public int getResetIntervalBeforeException()
public int getMarked()
public int getPosition()
public boolean isFakeIOException()
public int getResetCount()
public java.lang.String toString()
toString
in class java.lang.Object