Class MessageOutputStream

    • Field Detail

      • oos

        protected ObjectOutputStream oos
        The internal ObjectOutputStream needed to serialize the notification.
      • buf

        protected byte[] buf
        The internal buffer where data is stored.
      • count

        protected int count
        The number of valid bytes in the buffer.
      • compressedFlows

        protected boolean compressedFlows
    • Constructor Detail

      • MessageOutputStream

        public MessageOutputStream()
                            throws IOException
        Creates a new output stream to write data to an unspecified underlying output stream through a buffer with default size.
        Throws:
        IOException - an error occurs.
      • MessageOutputStream

        public MessageOutputStream​(int size)
                            throws IOException
        Creates a new output stream to write data to an unspecified underlying output stream through a buffer with specified size.
        Parameters:
        size - the buffer size.
        Throws:
        IllegalArgumentException - if size is less than 0.
        IOException - if the internal ObjectOutputStream cannot be correctly initialized.
    • Method Detail

      • write

        public abstract void write​(int b)
                            throws IOException
        Writes the specified byte to this output stream.
        Specified by:
        write in class OutputStream
        Parameters:
        b - the byte to be written.
        Throws:
        IOException - if an I/O error occurs.
      • write

        public final void write​(byte[] b)
                         throws IOException
        Writes b.length bytes to this output stream.

        This method calls its write method of three arguments with the arguments b, 0, and b.length.

        Overrides:
        write in class OutputStream
        Parameters:
        b - the data to be written.
        Throws:
        IOException - if an I/O error occurs.
        See Also:
        OutputStream.write(byte[], int, int)
      • write

        public abstract void write​(byte[] b,
                                   int off,
                                   int len)
                            throws IOException
        Writes len bytes from the specified byte array starting at offset off to this output stream.
        Overrides:
        write in class OutputStream
        Parameters:
        b - the data.
        off - the start offset in the data.
        len - the number of bytes to write.
        Throws:
        IOException - if an I/O error occurs.
      • writeShort

        protected final void writeShort​(short s)
        Writes a short directly to the buffer. Be careful, the buffer must be large enough to contain the short.
        Parameters:
        s - the data.
      • writeInt

        protected final void writeInt​(int i)
        Writes an int directly to the buffer. Be careful, the buffer must be large enough to contain the int.
        Parameters:
        i - the data.
      • writeHeader

        protected abstract void writeHeader()
                                     throws IOException
        Writes the protocol header to this output stream. This method must be overloaded in subclass.
        Throws:
        IOException - if an I/O error occurs.
      • writeMessageHeader

        protected final void writeMessageHeader​(Message msg)
        Writes the message header data to the buffer.
        Parameters:
        msg - The message to write out.
      • writeMessage

        protected final void writeMessage​(Message msg,
                                          long time)
                                   throws IOException
        Writes a message to this output stream. This method can be overloaded in subclass.
        Parameters:
        msg - The message to write out.
        time - The current time in milliseconds, this parameter is used to the handling of notification expiration.
        Throws:
        IOException - if an I/O error occurs.