org.apache.jackrabbit.server.io
Class BoundedInputStream

java.lang.Object
  extended byjava.io.InputStream
      extended byorg.apache.jackrabbit.server.io.BoundedInputStream

public class BoundedInputStream
extends InputStream

This is a stream that will only supply bytes up to a certain length - if its position goes above that, it will stop.

This is useful to wrap ServletInputStreams. The ServletInputStream will block if you try to read content from it that isn't there, because it doesn't know whether the content hasn't arrived yet or whether the content has finished. So, one of these, initialized with the Content-length sent in the ServletInputStream's header, will stop it blocking, providing it's been sent with a correct content length.

Author:
InigoSurguy

Constructor Summary
BoundedInputStream(InputStream in)
           
BoundedInputStream(InputStream in, long size)
          Creates a new BoundedInputStream that wraps the given input stream and limits it to a certain size.
 
Method Summary
 int available()
          
 void close()
          
 boolean isPropagateClose()
           
 void mark(int readlimit)
          
 boolean markSupported()
          
 int read()
          
 int read(byte[] b)
          
 int read(byte[] b, int off, int len)
          
 void reset()
          
 void setPropagateClose(boolean propagateClose)
           
 long skip(long n)
          
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BoundedInputStream

public BoundedInputStream(InputStream in,
                          long size)
Creates a new BoundedInputStream that wraps the given input stream and limits it to a certain size.

Parameters:
in - The wrapped input stream
size - The maximum number of bytes to return

BoundedInputStream

public BoundedInputStream(InputStream in)
Method Detail

read

public int read()
         throws IOException

Throws:
IOException

read

public int read(byte[] b)
         throws IOException

Throws:
IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws IOException

Throws:
IOException

skip

public long skip(long n)
          throws IOException

Throws:
IOException

available

public int available()
              throws IOException

Throws:
IOException

toString

public String toString()


close

public void close()
           throws IOException

Throws:
IOException

reset

public void reset()
           throws IOException

Throws:
IOException

mark

public void mark(int readlimit)


markSupported

public boolean markSupported()


isPropagateClose

public boolean isPropagateClose()

setPropagateClose

public void setPropagateClose(boolean propagateClose)


Copyright © 2005-2006 . All Rights Reserved.