Class LimitReader
java.lang.Object
java.io.Reader
org.apache.derby.iapi.services.io.LimitReader
- All Implemented Interfaces:
Closeable,AutoCloseable,Readable,Limit
A Reader that provides methods to limit the range that
can be read from the reader.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionLimitReader(Reader reader) Construct a LimitReader and call the clearLimit() method. -
Method Summary
Modifier and TypeMethodDescriptionintClear any limit set by setLimit.voidclose()final intgetLimit()return limit of the stream that can be read without throwing EOFExceptionintread()intread(char[] c, int off, int len) voidsetLimit(int length) Set the limit of the stream that can be read.longskip(long count) Methods inherited from class java.io.Reader
mark, markSupported, nullReader, read, read, ready, reset, transferTo
-
Field Details
-
remainingCharacters
private int remainingCharacters -
limitInPlace
private boolean limitInPlace -
reader
-
-
Constructor Details
-
LimitReader
Construct a LimitReader and call the clearLimit() method.
-
-
Method Details
-
read
- Overrides:
readin classReader- Throws:
IOException
-
read
- Specified by:
readin classReader- Throws:
IOException
-
skip
- Overrides:
skipin classReader- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classReader- 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 characters can be read from or skipped in the stream. Any attempt to read more than length characters will result in an EOFException -
getLimit
public final int getLimit()return limit of the stream that can be read without throwing EOFException- Returns:
- the remaining characters left to be read from the stream
-
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 not limit was set.
-