Class ObservableInputStream

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  ObservableInputStream.Observer
      Abstracts observer callback for ObservableInputStreams.
    • Constructor Summary

      Constructors 
      Constructor Description
      ObservableInputStream​(java.io.InputStream pProxy)
      Creates a new ObservableInputStream for the given InputStream.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(ObservableInputStream.Observer pObserver)
      Adds an Observer.
      void close()
      Invokes the delegate's close() method.
      void consume()
      Reads all data from the underlying InputStream, while notifying the observers.
      int read()
      Invokes the delegate's read() method.
      int read​(byte[] pBuffer)
      Invokes the delegate's read(byte[]) method.
      int read​(byte[] pBuffer, int pOffset, int pLength)
      Invokes the delegate's read(byte[], int, int) method.
      void remove​(ObservableInputStream.Observer pObserver)
      Removes an Observer.
      void removeAllObservers()
      Removes all Observers.
      • Methods inherited from class java.io.InputStream

        nullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ObservableInputStream

        public ObservableInputStream​(java.io.InputStream pProxy)
        Creates a new ObservableInputStream for the given InputStream.
        Parameters:
        pProxy - the input stream to proxy
    • Method Detail

      • removeAllObservers

        public void removeAllObservers()
        Removes all Observers.
      • read

        public int read()
                 throws java.io.IOException
        Description copied from class: ProxyInputStream
        Invokes the delegate's read() method.
        Overrides:
        read in class ProxyInputStream
        Returns:
        the byte read or -1 if the end of stream
        Throws:
        java.io.IOException - if an I/O error occurs
      • read

        public int read​(byte[] pBuffer)
                 throws java.io.IOException
        Description copied from class: ProxyInputStream
        Invokes the delegate's read(byte[]) method.
        Overrides:
        read in class ProxyInputStream
        Parameters:
        pBuffer - the buffer to read the bytes into
        Returns:
        the number of bytes read or EOF if the end of stream
        Throws:
        java.io.IOException - if an I/O error occurs
      • read

        public int read​(byte[] pBuffer,
                        int pOffset,
                        int pLength)
                 throws java.io.IOException
        Description copied from class: ProxyInputStream
        Invokes the delegate's read(byte[], int, int) method.
        Overrides:
        read in class ProxyInputStream
        Parameters:
        pBuffer - the buffer to read the bytes into
        pOffset - The start offset
        pLength - The number of bytes to read
        Returns:
        the number of bytes read or -1 if the end of stream
        Throws:
        java.io.IOException - if an I/O error occurs
      • close

        public void close()
                   throws java.io.IOException
        Description copied from class: ProxyInputStream
        Invokes the delegate's close() method.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class ProxyInputStream
        Throws:
        java.io.IOException - if an I/O error occurs
      • consume

        public void consume()
                     throws java.io.IOException
        Reads all data from the underlying InputStream, while notifying the observers.
        Throws:
        java.io.IOException - The underlying InputStream, or either of the observers has thrown an exception.