Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## oracle.ifs.beans.parsers
Class ParserInputStream

    java.lang.Object

      |

      +--java.io.InputStream

            |

            +--oracle.ifs.beans.parsers.ParserInputStream

public class ParserInputStream
extends java.io.InputStream

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

### ParserInputStream

    public ParserInputStream(java.io.InputStream is)

  Constructs a ParserInputStream from an InputStream.
  Parameters:
    `is` - the InputStream

Method Detail

### read

    public int read()
             throws java.io.IOException

  Reads the next byte of data from this input stream.

  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.

  Overrides:
    `read` in class `java.io.InputStream`
  Returns:
    the int, or -1 when the end of the stream has been reached
  Throws:
    `java.io.IOException` - if an I/O error occurs

### read

    public int read(byte[] b)
             throws java.io.IOException

  Reads up to b.length bytes of data from this input stream into an array of bytes.

  Overrides:
    `read` in class `java.io.InputStream`
  Parameters:
    `b` - the buffer into which the data is read
  Returns:
    the total number of bytes read into the buffer, or -1 when the end of the stream has been reached
  Throws:
    `java.io.IOException` - if an I/O error occurs

### read

    public int read(byte[] b,
                    int offset,
                    int len)
             throws java.io.IOException

  Reads up to len bytes of data from this input stream into an array of bytes at the position specified by offset.
  Overrides:
    `read` in class `java.io.InputStream`
  Parameters:
    `b` - the buffer into which the data is read
    `offset` - the start offset of the data
    `len` - the maximum number of bytes read
  Returns:
    the total number of bytes read into the buffer, or -1 when the end of the stream has been reached
  Throws:
    `java.io.IOException` - if an I/O error occurs

### setBufferingMode

    public void setBufferingMode(boolean mode)

  Set the stream into the desired 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.

  Parameters:
    `mode` - can be true or false, indicating whether the stream should be put into buffering mode or non-buffering mode mode

### getBufferingMode

    public boolean getBufferingMode()

  Gets the buffering mode indicating whether the stream is currently in buffering mode or non-buffering mode.
  Returns:
    true or false, indicating whether the stream is currently in buffering or non-buffering mode

### resetStream

    public void resetStream(boolean bufferingMode)
                     throws IfsException

  Resets the stream such that it can be re-read.

  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.

  Parameters:
    `bufferingMode` - determines whether the stream should continue in buffering mode after being reset
  Throws:
    `IfsException` - if attempting to reset a stream that is not in buffering mode

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD