|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.io.InputStream | +--oracle.ifs.beans.parsers.ParserInputStream
A ParserInputStream is an InputStream that supports buffering of input such that the buffer can be reset to the beginning, allowing bytes to be re-read.
As such, a ParserInputStream can be used whenever the input data needs to be re-read. For example, it is used for pre-parsing a file to determine the nature of its content, before passing it to the appropriate parser for actual parsing.
It can operate in buffering or non-buffering mode. When in buffering mode, it buffers the input, extending the size of the buffer as required.
The ParserInputStream can be reset to allow re-reading of the input data. When reset and put in non-buffering mode, it consumes the bytes in the buffer to service read requests, until it reaches the end of the buffered data, at which point it will start reading from the underlying InputStream. When reset and operating in buffering mode, it consumes the bytes in the buffer to service read requests, until it reaches the end of the buffered data, at which point it will read more data into the buffer and services read requests from the contents of the buffer.
A ParserInputStream can only be reset if already in buffering mode.
Constructor Summary | |
ParserInputStream(java.io.InputStream is)
Constructs a ParserInputStream from an InputStream. |
Method Summary | |
boolean |
getBufferingMode()
Gets the buffering mode indicating whether the stream is currently in buffering mode or non-buffering mode. |
int |
read()
Reads the next byte of data from this input stream. |
int |
read(byte[] b)
Reads up to b.length bytes of data from this input stream into an array of bytes. |
int |
read(byte[] b,
int offset,
int len)
Reads up to len bytes of data from this input stream into an array of bytes at the position specified by offset. |
void |
resetStream(boolean bufferingMode)
Resets the stream such that it can be re-read. |
void |
setBufferingMode(boolean mode)
Set the stream into the desired mode. |
Constructor Detail |
public ParserInputStream(java.io.InputStream is)
is
- the InputStreamMethod Detail |
public int read() throws java.io.IOException
The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned.
read
in class java.io.InputStream
java.io.IOException
- if an I/O error occurspublic int read(byte[] b) throws java.io.IOException
read
in class java.io.InputStream
b
- the buffer into which the data is readjava.io.IOException
- if an I/O error occurspublic int read(byte[] b, int offset, int len) throws java.io.IOException
read
in class java.io.InputStream
b
- the buffer into which the data is readoffset
- the start offset of the datalen
- the maximum number of bytes readjava.io.IOException
- if an I/O error occurspublic void setBufferingMode(boolean mode)
If true is passed in, the stream is put into buffering mode, so that it can be reset subsequently to re-read the stream. If false is passed in, the stream is put into non-buffering mode, and it cannot be subsequently reset.
mode
- can be true or false, indicating whether the stream should
be put into buffering mode or non-buffering mode
modepublic boolean getBufferingMode()
public void resetStream(boolean bufferingMode) throws IfsException
The stream can continue to operate in buffering mode after the reset, or it can be set to non-buffering mode following reset. The buffering mode should be set according to whether the stream will need to be re-read. A stream that is not in buffering mode cannot be reset.
bufferingMode
- determines whether the stream should continue
in buffering mode after being resetIfsException
- if attempting to reset a stream that is not in
buffering mode
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |