Top Description Fields Constructors Methods
org.apache.derby.iapi.services.io

public final Class LimitReader

extends Reader
implements Limit
Class Inheritance
All Implemented Interfaces
org.apache.derby.iapi.services.io.Limit
Imports
java.io.Reader, .IOException

A Reader that provides methods to limit the range that can be read from the reader.

Field Summary

Modifier and TypeField and Description
private boolean
private Reader
private int
Inherited from java.io.Reader:
lock

Constructor Summary

AccessConstructor and Description
public
LimitReader(Reader
Reader to wrap
reader
)

Construct a LimitReader and call the clearLimit() method.

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

the number of bytes within the limit that have not been read. -1 if not limit was set.
clearLimit
()

Implements org.apache.derby.iapi.services.io.Limit.clearLimit.

Clear any limit set by setLimit.

public void
close()

Implements abstract java.io.Reader.close.

Implements java.io.Closeable.close.

Closes the stream and releases any system resources associated with it.

public final int

Returns:

the remaining characters left to be read from the stream
getLimit
()

return limit of the stream that can be read without throwing EOFException

public int
read()

Overrides java.io.Reader.read.

Reads a single character.

public int
read(char[]
Destination buffer
c
,
int
Offset at which to start storing characters
off
,
int
Maximum number of characters to read
len
)

Implements abstract java.io.Reader.read.

Reads characters into a portion of an array.

public void
setLimit(int
The length to set
length
)

Implements org.apache.derby.iapi.services.io.Limit.setLimit.

Set the limit of the stream that can be read.

public long
skip(long
The number of characters to skip
count
)

Overrides java.io.Reader.skip.

Skips characters.

Inherited from java.io.Reader:
markmarkSupportednullReaderreadreadreadyresettransferTo

Field Detail

limitInPlaceback to summary
private boolean limitInPlace
readerback to summary
private Reader reader
remainingCharactersback to summary
private int remainingCharacters

Constructor Detail

LimitReaderback to summary
public LimitReader(Reader reader)

Construct a LimitReader and call the clearLimit() method.

Parameters
reader:Reader

Reader to wrap

Method Detail

clearLimitback to summary
public int clearLimit()

Implements org.apache.derby.iapi.services.io.Limit.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.

Returns:int

the number of bytes within the limit that have not been read. -1 if not limit was set.

closeback to summary
public void close() throws IOException

Implements abstract java.io.Reader.close.

Implements java.io.Closeable.close.

Doc from java.io.Reader.close.

Closes the stream and releases any system resources associated with it. Once the stream has been closed, further read(), ready(), mark(), reset(), or skip() invocations will throw an IOException. Closing a previously closed stream has no effect.

Exceptions
IOException:
If an I/O error occurs
getLimitback to summary
public final int getLimit()

return limit of the stream that can be read without throwing EOFException

Returns:int

the remaining characters left to be read from the stream

readback to summary
public int read() throws IOException

Overrides java.io.Reader.read.

Doc from java.io.Reader.read.

Reads a single character. This method will block until a character is available, an I/O error occurs, or the end of the stream is reached.

Subclasses that intend to support efficient single-character input should override this method.

Returns:int

The character read, as an integer in the range 0 to 65535 (0x00-0xffff), or -1 if the end of the stream has been reached

Exceptions
IOException:
If an I/O error occurs
readback to summary
public int read(char[] c, int off, int len) throws IOException

Implements abstract java.io.Reader.read.

Doc from java.io.Reader.read.

Reads characters into a portion of an array. This method will block until some input is available, an I/O error occurs, or the end of the stream is reached.

If len is zero, then no characters are read and 0 is returned; otherwise, there is an attempt to read at least one character. If no character is available because the stream is at its end, the value -1 is returned; otherwise, at least one character is read and stored into cbuf.

Parameters
c:char[]

Destination buffer

off:int

Offset at which to start storing characters

len:int

Maximum number of characters to read

Returns:int

The number of characters read, or -1 if the end of the stream has been reached

Exceptions
IOException:
If an I/O error occurs
setLimitback to summary
public void setLimit(int length)

Implements org.apache.derby.iapi.services.io.Limit.setLimit.

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

Parameters
length:int

Doc from org.apache.derby.iapi.services.io.Limit.setLimit.

The length to set

skipback to summary
public long skip(long count) throws IOException

Overrides java.io.Reader.skip.

Doc from java.io.Reader.skip.

Skips characters. This method will block until some characters are available, an I/O error occurs, or the end of the stream is reached. If the stream is already at its end before this method is invoked, then no characters are skipped and zero is returned.

Parameters
count:long

The number of characters to skip

Returns:long

The number of characters actually skipped

Exceptions
IOException:
If an I/O error occurs