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 java.io.FilterInputStream
in
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct a LimitInputStream and call the clearLimit() method. -
Method Summary
Modifier and TypeMethodDescriptionint
int
Clear any limit set by setLimit.boolean
This stream doesn't support mark/reset, independent of whether the underlying stream does so or not.int
read()
int
read
(byte[] b, int off, int len) void
setInput
(InputStream in) void
setLimit
(int length) Set the limit of the stream that can be read.long
skip
(long count) Methods inherited from class java.io.FilterInputStream
close, mark, read, reset
Methods inherited from class java.io.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:
read
in classFilterInputStream
- Throws:
IOException
-
read
- Overrides:
read
in classFilterInputStream
- Throws:
IOException
-
skip
- Overrides:
skip
in classFilterInputStream
- Throws:
IOException
-
available
- Overrides:
available
in classFilterInputStream
- Throws:
IOException
-
setLimit
public void setLimit(int length) Set the limit of the stream that can be read. After this call up to and including length bytes can be read from or skipped in the stream. Any attempt to read more than length bytes will result in an EOFException -
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:
clearLimit
in 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:
markSupported
in classFilterInputStream
- Returns:
false
-