Package org.jsoup.internal
Class ControllableInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
org.jsoup.internal.ControllableInputStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
A jsoup internal class (so don't use it as there is no contract API) that enables controls on a Buffered Input Stream,
namely a maximum read size, and the ability to Thread.interrupt() the read.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final BufferedInputStream
private final boolean
private int
private boolean
private int
private final int
private Progress
<?> private Object
private int
private int
private long
private long
Fields inherited from class java.io.FilterInputStream
in
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
ControllableInputStream
(BufferedInputStream in, int maxSize) -
Method Summary
Modifier and TypeMethodDescriptionprivate void
private boolean
expired()
void
mark
(int readlimit) <ProgressContext>
ControllableInputStreamonProgress
(int contentLength, Progress<ProgressContext> callback, ProgressContext context) int
read
(byte[] b, int off, int len) static ByteBuffer
readToByteBuffer
(InputStream in, int max) Reads this inputstream to a ByteBuffer.void
reset()
timeout
(long startTimeNanos, long timeoutMillis) static ControllableInputStream
wrap
(InputStream in, int bufferSize, int maxSize) If this InputStream is not already a ControllableInputStream, let it be one.Methods inherited from class java.io.FilterInputStream
available, close, markSupported, read, read, skip
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Field Details
-
buff
-
capped
private final boolean capped -
maxSize
private final int maxSize -
startTime
private long startTime -
timeout
private long timeout -
remaining
private int remaining -
markPos
private int markPos -
interrupted
private boolean interrupted -
progress
-
progressContext
-
contentLength
private int contentLength -
readPos
private int readPos
-
-
Constructor Details
-
ControllableInputStream
-
-
Method Details
-
wrap
If this InputStream is not already a ControllableInputStream, let it be one.- Parameters:
in
- the input stream to (maybe) wrapbufferSize
- the buffer size to use when readingmaxSize
- the maximum size to allow to be read. 0 == infinite.- Returns:
- a controllable input stream
-
read
- Overrides:
read
in classFilterInputStream
- Throws:
IOException
-
readToByteBuffer
Reads this inputstream to a ByteBuffer. The supplied max may be less than the inputstream's max, to support reading just the first bytes.- Throws:
IOException
-
reset
- Overrides:
reset
in classFilterInputStream
- Throws:
IOException
-
mark
public void mark(int readlimit) - Overrides:
mark
in classFilterInputStream
-
timeout
-
emitProgress
private void emitProgress() -
onProgress
public <ProgressContext> ControllableInputStream onProgress(int contentLength, Progress<ProgressContext> callback, ProgressContext context) -
expired
private boolean expired() -
inputStream
-