public final class ConstrainableInputStream
extends java.io.BufferedInputStream
| Modifier and Type | Field and Description |
|---|---|
private boolean |
capped |
private static int |
DefaultSize |
private boolean |
interrupted |
private int |
maxSize |
private int |
remaining |
private long |
startTime |
private long |
timeout |
| Modifier | Constructor and Description |
|---|---|
private |
ConstrainableInputStream(java.io.InputStream in,
int bufferSize,
int maxSize) |
| Modifier and Type | Method and Description |
|---|---|
private boolean |
expired() |
int |
read(byte[] b,
int off,
int len) |
java.nio.ByteBuffer |
readToByteBuffer(int max)
Reads this inputstream to a ByteBuffer.
|
void |
reset() |
ConstrainableInputStream |
timeout(long startTimeNanos,
long timeoutMillis) |
static ConstrainableInputStream |
wrap(java.io.InputStream in,
int bufferSize,
int maxSize)
If this InputStream is not already a ConstrainableInputStream, let it be one.
|
private static final int DefaultSize
private final boolean capped
private final int maxSize
private long startTime
private long timeout
private int remaining
private boolean interrupted
private ConstrainableInputStream(java.io.InputStream in,
int bufferSize,
int maxSize)
public static ConstrainableInputStream wrap(java.io.InputStream in, int bufferSize, int maxSize)
in - the input stream to (maybe) wrapbufferSize - the buffer size to use when readingmaxSize - the maximum size to allow to be read. 0 == infinite.public int read(byte[] b,
int off,
int len)
throws java.io.IOException
read in class java.io.BufferedInputStreamjava.io.IOExceptionpublic java.nio.ByteBuffer readToByteBuffer(int max)
throws java.io.IOException
java.io.IOExceptionpublic void reset()
throws java.io.IOException
reset in class java.io.BufferedInputStreamjava.io.IOExceptionpublic ConstrainableInputStream timeout(long startTimeNanos, long timeoutMillis)
private boolean expired()