org.apache.commons.io.input

## Class ObservableInputStream.Observer

- java.lang.Object
- - org.apache.commons.io.input.ObservableInputStream.Observer

- Direct Known Subclasses:
    MessageDigestCalculatingInputStream.MessageDigestMaintainingObserver
  Enclosing class:
    ObservableInputStream

      public abstract static class ObservableInputStream.Observer
      extends Object

  Abstracts observer callback for `ObservableInputStream`s.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Observer()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `closed()` Called to indicate, that the `ObservableInputStream` has been closed.
    `void` | `data(byte[] pBuffer, int pOffset, int pLength)` Called to indicate, that `InputStream.read(byte[])`, or `InputStream.read(byte[], int, int)` have been called, and are about to invoke data.
    `void` | `data(int pByte)` Called to indicate, that `InputStream.read()` has been invoked on the `ObservableInputStream`, and will return a value.
    `void` | `error(IOException pException)` Called to indicate, that an error occurred on the underlying stream.
    `void` | `finished()` Called to indicate, that EOF has been seen on the underlying stream.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Observer

          public Observer()

  - ### Method Detail

    - #### data

          public void data(int pByte)
                    throws IOException

      Called to indicate, that `InputStream.read()` has been invoked on the `ObservableInputStream`, and will return a value.
      Parameters:
        `pByte` - The value, which is being returned. This will never be -1 (EOF), because, in that case, `finished()` will be invoked instead.
      Throws:
        `IOException` - if an i/o-error occurs

    - #### data

          public void data(byte[] pBuffer,
                           int pOffset,
                           int pLength)
                    throws IOException

      Called to indicate, that `InputStream.read(byte[])`, or `InputStream.read(byte[], int, int)` have been called, and are about to invoke data.
      Parameters:
        `pBuffer` - The byte array, which has been passed to the read call, and where data has been stored.
        `pOffset` - The offset within the byte array, where data has been stored.
        `pLength` - The number of bytes, which have been stored in the byte array.
      Throws:
        `IOException` - if an i/o-error occurs

    - #### finished

          public void finished()
                        throws IOException

      Called to indicate, that EOF has been seen on the underlying stream. This method may be called multiple times, if the reader keeps invoking either of the read methods, and they will consequently keep returning EOF.
      Throws:
        `IOException` - if an i/o-error occurs

    - #### closed

          public void closed()
                      throws IOException

      Called to indicate, that the `ObservableInputStream` has been closed.
      Throws:
        `IOException` - if an i/o-error occurs

    - #### error

          public void error(IOException pException)
                     throws IOException

      Called to indicate, that an error occurred on the underlying stream.
      Parameters:
        `pException` - the exception to throw
      Throws:
        `IOException` - if an i/o-error occurs

Copyright © 2002–2020 The Apache Software Foundation. All rights reserved.