org.w3c.www.http
Class ContentLengthInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.w3c.www.http.ContentLengthInputStream
All Implemented Interfaces:
java.io.Closeable

public class ContentLengthInputStream
extends java.io.InputStream

The content length input stream is used internally to return entity bodies.


Field Summary
protected  java.io.InputStream in
          The original input stream.
protected  int length
          The number of bytes readable from the above stream.
protected  int marklength
          The place of a single pending mark.
protected  HttpStreamObserver observer
          The stream observer, if any.
 
Constructor Summary
ContentLengthInputStream(HttpStreamObserver observer, java.io.InputStream in, int length)
           
ContentLengthInputStream(java.io.InputStream in, int length)
          Builds a new content-length input stream.
 
Method Summary
 int available()
           
 void close()
           
 void finalize()
          Make sure the stream is ultimately closed !
 void mark(int readlimit)
           
 boolean markSupported()
          do we support mark() ? it depends on the underlying InputStream
 int read()
           
 int read(byte[] b, int off, int len)
           
 void reset()
           
 long skip(long n)
           
 
Methods inherited from class java.io.InputStream
read
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

in

protected java.io.InputStream in
The original input stream.


observer

protected HttpStreamObserver observer
The stream observer, if any.


length

protected int length
The number of bytes readable from the above stream.


marklength

protected int marklength
The place of a single pending mark.

Constructor Detail

ContentLengthInputStream

public ContentLengthInputStream(java.io.InputStream in,
                                int length)
Builds a new content-length input stream. This stream acts as a normal stream except that it will return an end of file, after count bytes have been delivered.


ContentLengthInputStream

public ContentLengthInputStream(HttpStreamObserver observer,
                                java.io.InputStream in,
                                int length)
Method Detail

mark

public void mark(int readlimit)
Overrides:
mark in class java.io.InputStream

reset

public void reset()
           throws java.io.IOException
Overrides:
reset in class java.io.InputStream
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.InputStream
Throws:
java.io.IOException

read

public int read()
         throws java.io.IOException
Specified by:
read in class java.io.InputStream
Throws:
java.io.IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Overrides:
read in class java.io.InputStream
Throws:
java.io.IOException

skip

public long skip(long n)
          throws java.io.IOException
Overrides:
skip in class java.io.InputStream
Throws:
java.io.IOException

available

public int available()
              throws java.io.IOException
Overrides:
available in class java.io.InputStream
Throws:
java.io.IOException

finalize

public void finalize()
Make sure the stream is ultimately closed !

Overrides:
finalize in class java.lang.Object

markSupported

public boolean markSupported()
do we support mark() ? it depends on the underlying InputStream

Overrides:
markSupported in class java.io.InputStream
Returns:
a boolean, true if mark is supported