|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.InputStream
org.apache.cocoon.util.PostInputStream
public class PostInputStream
The class PostInputStream is a wrapper for InputStream associated with POST message. It allows to control read operation, restricting the number of bytes read to the value returned by getContentLen() method.
Field Summary | |
---|---|
static String |
CLASS
Class name |
protected int |
m_bytesRead
The number of bytes read |
Constructor Summary | |
---|---|
PostInputStream()
Creates a PostInputStream |
|
PostInputStream(InputStream input,
int len)
Creates a PostInputStream based on a real InputStream object with the specified
post message body length. |
Method Summary | |
---|---|
int |
available()
Returns the number of bytes available from this input stream that can be read without the stream blocking. |
protected void |
checkOpen()
Checks to see if this stream is closed; if it is, an IOException is thrown. |
void |
close()
Closes this input stream by closing the underlying stream and marking this one as closed. |
int |
getContentLen()
Returns the post message body length. |
InputStream |
getInputStream()
Returns the underlying input stream. |
protected void |
init(InputStream input,
int len)
Sets the underlying input stream and contentLen value . |
boolean |
markSupported()
Tests if this input stream supports the mark
and reset methods. |
int |
read()
Reads the next byte from the input stream. |
int |
read(byte[] buffer)
|
int |
read(byte[] buffer,
int offset,
int len)
Reads bytes from this byte-input stream into the specified byte array, starting at the given offset. |
void |
setInputStream(InputStream input,
int len)
Sets the underlying input stream and contentLen value . |
long |
skip(long n)
See the general contract of the skip
method of InputStream . |
String |
toString()
Returns a String representation of this. |
Methods inherited from class java.io.InputStream |
---|
mark, reset |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String CLASS
protected int m_bytesRead
Constructor Detail |
---|
public PostInputStream()
public PostInputStream(InputStream input, int len) throws IllegalArgumentException
PostInputStream
based on a real InputStream object with the specified
post message body length. Saves its argument, the input stream
m_inputStream
, for later use.
input
- the underlying input stream.len
- the post message body length.
IllegalArgumentException
- len <= 0.Method Detail |
---|
protected void init(InputStream input, int len) throws IllegalArgumentException
input
- the input stream; can not be null.len
- the post message body length.
IllegalArgumentException
public void setInputStream(InputStream input, int len) throws IOException
input
- the input stream; can not be null.len
- the post message body length.
IOException
public InputStream getInputStream()
public int getContentLen()
public int read() throws IOException
read
in class InputStream
IOException
public int read(byte[] buffer, int offset, int len) throws IOException
This method implements the general contract of the corresponding
method of
the read
class.
This method delegetes the read operation to the underlying InputStream implementation class but it
controlls the number of bytes read from the stream. In the remote situation the underlying InputStream has no knowledge of
the length of the stream and the notion of the "end" is undefined. This wrapper class has a knowledge of the
length of data send by the requestor by the means of contentLength. This method returns the number of bytes read and
accumulates the total number of bytes read in m_bytesRead. When the m_bytesRead is equal to the specified contentLength
value the method returns returns -1 to signal the end of data.
InputStream
read
in class InputStream
buffer
- the byte array to read into; can not be null.offset
- the starting offset in the byte array.len
- the maximum number of bytes to read.
-1
if the end of
the stream has been reached.
IOException
- if an I/O error occurs.public int read(byte[] buffer) throws IOException
read
in class InputStream
IOException
protected void checkOpen() throws IOException
IOException
public long skip(long n) throws IOException
skip
method of InputStream
.
Delegates execution to the underlying InputStream implementation class.
Checks to see if this stream is closed; if it is, an IOException is thrown.
skip
in class InputStream
n
- the number of bytes to be skipped.
IOException
- if an I/O error occurs.public int available() throws IOException
available
in class InputStream
IOException
public boolean markSupported()
mark
and reset
methods. The markSupported
method of BufferedInputStream
returns
false
.
markSupported
in class InputStream
boolean
indicating if this stream type supports
the mark
and reset
methods.InputStream.mark(int)
,
InputStream.reset()
public void close() throws IOException
close
in interface Closeable
close
in class InputStream
IOException
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |