Package jadex.commons

Class MultiStream

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable

    public class MultiStream
    extends java.io.OutputStream
    Dispatch the write calls to a number of specified output streams.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.Set disabled
      The disabled streams.
      protected java.io.OutputStream[] outs
      The output streams.
    • Constructor Summary

      Constructors 
      Constructor Description
      MultiStream​(java.io.OutputStream[] outs)
      Create a new multi stream.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Close the streams.
      void flush()
      Flush the streams.
      java.io.OutputStream[] getOutputStreams()
      Get the output streams.
      void setEnabled​(java.io.OutputStream out, boolean enabled)
      Set the enabled state of a stream.
      void setOutputStreams​(java.io.OutputStream[] outs)
      Set the output streams.
      void write​(byte[] b, int off, int len)
      Write a byte array to the streams.
      void write​(int b)
      Write a byte to the streams.
      • Methods inherited from class java.io.OutputStream

        nullOutputStream, write
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • outs

        protected java.io.OutputStream[] outs
        The output streams.
      • disabled

        protected java.util.Set disabled
        The disabled streams.
    • Constructor Detail

      • MultiStream

        public MultiStream​(java.io.OutputStream[] outs)
        Create a new multi stream.
        Parameters:
        outs - The output streams.
    • Method Detail

      • write

        public void write​(int b)
                   throws java.io.IOException
        Write a byte to the streams.
        Specified by:
        write in class java.io.OutputStream
        Parameters:
        b - The byte.
        Throws:
        java.io.IOException
      • write

        public void write​(byte[] b,
                          int off,
                          int len)
                   throws java.io.IOException
        Write a byte array to the streams.
        Overrides:
        write in class java.io.OutputStream
        Parameters:
        b - The byte.
        off - The start offset.
        len - The length.
        Throws:
        java.io.IOException
      • close

        public void close()
                   throws java.io.IOException
        Close the streams.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.OutputStream
        Throws:
        java.io.IOException
      • flush

        public void flush()
                   throws java.io.IOException
        Flush the streams.
        Specified by:
        flush in interface java.io.Flushable
        Overrides:
        flush in class java.io.OutputStream
        Throws:
        java.io.IOException
      • getOutputStreams

        public java.io.OutputStream[] getOutputStreams()
        Get the output streams.
        Returns:
        The output streams.
      • setOutputStreams

        public void setOutputStreams​(java.io.OutputStream[] outs)
        Set the output streams.
        Parameters:
        outs - The output streams.
      • setEnabled

        public void setEnabled​(java.io.OutputStream out,
                               boolean enabled)
        Set the enabled state of a stream.
        Parameters:
        out - The output stream.
        enabled - The enabled state.