Class ConstrainableInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
java.io.BufferedInputStream
com.itextpdf.styledxmlparser.jsoup.internal.ConstrainableInputStream
- All Implemented Interfaces:
Closeable, AutoCloseable
A jsoup internal class (so don't use it as there is no contract API) that enables constraints on an Input Stream,
namely a maximum read size, and the ability to Thread.interrupt() the read.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final booleanprivate static final intprivate final intprivate intprivate longprivate longFields inherited from class FilterInputStream
in -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateConstrainableInputStream(InputStream in, int bufferSize, int maxSize) -
Method Summary
Modifier and TypeMethodDescriptionprivate booleanexpired()intread(byte[] b, int off, int len) readToByteBuffer(int max) Reads this inputstream to a ByteBuffer.voidreset()timeout(long startTimeNanos, long timeoutMillis) static ConstrainableInputStreamwrap(InputStream in, int bufferSize, int maxSize) If this InputStream is not already a ConstrainableInputStream, let it be one.Methods inherited from class BufferedInputStream
available, close, mark, markSupported, read, skip, transferToMethods inherited from class FilterInputStream
readMethods inherited from class InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes
-
Field Details
-
DefaultSize
private static final int DefaultSize- See Also:
-
capped
private final boolean capped -
maxSize
private final int maxSize -
startTime
private long startTime -
timeout
private long timeout -
remaining
private int remaining
-
-
Constructor Details
-
ConstrainableInputStream
-
-
Method Details
-
wrap
If this InputStream is not already a ConstrainableInputStream, 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 constrainable input stream
-
read
- Overrides:
readin classBufferedInputStream- 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:
resetin classBufferedInputStream- Throws:
IOException
-
timeout
-
expired
private boolean expired()
-