Package 

Interface MessageBufferOutput

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

    
    public interface MessageBufferOutput
     implements Closeable, Flushable
                        

    Provides a buffered output stream that writes sequence of MessageBuffer instances.

    A MessageBufferOutput implementation has total control of the buffer memory so that it can reuse buffer memory, use buffer pools, or use memory-mapped files.

    • Method Summary

      Modifier and Type Method Description
      abstract MessageBuffer next(int minimumSize) Allocates the next buffer to write.
      abstract void writeBuffer(int length) Writes the previously allocated buffer.
      abstract void write(Array<byte> buffer, int offset, int length) Writes an external payload data.This method should follow semantics of OutputStream.
      abstract void add(Array<byte> buffer, int offset, int length) Writes an external payload data.
      • Methods inherited from class java.io.Closeable

        close
      • Methods inherited from class java.io.Flushable

        flush
      • Methods inherited from class java.lang.Object

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

      • next

         abstract MessageBuffer next(int minimumSize)

        Allocates the next buffer to write.

        This method should return a MessageBuffer instance that has specified size of capacity at least.

        When this method is called twice, the previously returned buffer is no longer used. This method may be calledtwice without call of writeBuffer in between. In this case, the buffer should bediscarded without flushing it to the output.

        Parameters:
        minimumSize - the mimium required buffer size to allocate
      • writeBuffer

         abstract void writeBuffer(int length)

        Writes the previously allocated buffer.

        This method should write the buffer previously returned from next method until specified number ofbytes. Once the buffer is written, the buffer is no longer used.

        This method is not always called for each next call. In this case, the buffer should be discardedwithout flushing it to the output when the next next is called.

        Parameters:
        length - the number of bytes to write
      • write

         abstract void write(Array<byte> buffer, int offset, int length)

        Writes an external payload data.This method should follow semantics of OutputStream.

        Parameters:
        buffer - the data to write
        offset - the start offset in the data
        length - the number of bytes to write
      • add

         abstract void add(Array<byte> buffer, int offset, int length)

        Writes an external payload data.

        Unlike write method, the buffer is given - this MessageBufferOutput implementationgets ownership of the buffer and may modify contents of the buffer. Contents of this buffer won't be modifiedby the caller.

        Parameters:
        buffer - the data to add
        offset - the start offset in the data
        length - the number of bytes to add