org.apache.derby.iapi.services.io
Class LimitReader

java.lang.Object
  extended byjava.io.Reader
      extended byorg.apache.derby.iapi.services.io.LimitReader
All Implemented Interfaces:
Limit

public class LimitReader
extends java.io.Reader
implements Limit

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


Field Summary
protected  boolean limitInPlace
           
private  java.io.Reader reader
           
protected  int remainingBytes
           
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
LimitReader(java.io.Reader reader)
          Construct a LimitReader and call the clearLimit() method.
 
Method Summary
 int clearLimit()
          Clear any limit set by setLimit.
 void close()
           
 int read()
           
 int read(char[] c, int off, int len)
           
 void setLimit(int length)
          Set the limit of the stream that can be read.
 long skip(long count)
           
 
Methods inherited from class java.io.Reader
mark, markSupported, read, ready, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

remainingBytes

protected int remainingBytes

limitInPlace

protected boolean limitInPlace

reader

private java.io.Reader reader
Constructor Detail

LimitReader

public LimitReader(java.io.Reader reader)
Construct a LimitReader and call the clearLimit() method.

Method Detail

read

public int read()
         throws java.io.IOException
Throws:
java.io.IOException

read

public int read(char[] c,
                int off,
                int len)
         throws java.io.IOException
Throws:
java.io.IOException

skip

public long skip(long count)
          throws java.io.IOException
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Throws:
java.io.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

Specified by:
setLimit in interface Limit
Returns:
The value of length.
Throws:
java.io.IOException - IOException from some underlying stream
EOFException - The set limit would exceed the available data in 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:
clearLimit in interface Limit
Returns:
the number of bytes within the limit that have not been read. -1 if not limit was set.


Apache Derby V10.0 Engine Documentation - Copyright © 1997,2004 The Apache Software Foundation or its licensors, as applicable.