Class LimitInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
org.apache.derby.iapi.services.io.LimitInputStream
- All Implemented Interfaces:
Closeable, AutoCloseable, Limit
- Direct Known Subclasses:
RawToBinaryFormatStream
An abstract InputStream that provides abstract methods to limit the range that
can be read from the stream.
-
Field Summary
FieldsFields inherited from class FilterInputStream
in -
Constructor Summary
ConstructorsConstructorDescriptionConstruct a LimitInputStream and call the clearLimit() method. -
Method Summary
Modifier and TypeMethodDescriptionintintClear any limit set by setLimit.booleanThis stream doesn't support mark/reset, independent of whether the underlying stream does so or not.intread()intread(byte[] b, int off, int len) voidsetInput(InputStream in) voidsetLimit(int length) Set the limit of the stream that can be read.longskip(long count) Methods inherited from class FilterInputStream
close, mark, read, resetMethods inherited from class InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Field Details
-
remainingBytes
protected int remainingBytes -
limitInPlace
protected boolean limitInPlace
-
-
Constructor Details
-
LimitInputStream
Construct a LimitInputStream and call the clearLimit() method.
-
-
Method Details
-
read
- Overrides:
readin classFilterInputStream- Throws:
IOException
-
read
- Overrides:
readin classFilterInputStream- Throws:
IOException
-
skip
- Overrides:
skipin classFilterInputStream- Throws:
IOException
-
available
- Overrides:
availablein classFilterInputStream- Throws:
IOException
-
setLimit
-
clearLimit
public int clearLimit()Clear any limit set by setLimit. After this call no limit checking will be made on any read until a setLimit()) call is made.- Specified by:
clearLimitin interfaceLimit- Returns:
- the number of bytes within the limit that have not been read. -1 if no limit was set.
-
setInput
-
markSupported
public boolean markSupported()This stream doesn't support mark/reset, independent of whether the underlying stream does so or not.The reason for not supporting mark/reset, is that it is hard to combine with the limit functionality without always keeping track of the number of bytes read.
- Overrides:
markSupportedin classFilterInputStream- Returns:
false
-