Package org.agrona.io

Class ExpandableDirectBufferOutputStream

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

    public class ExpandableDirectBufferOutputStream
    extends java.io.OutputStream
    OutputStream that wraps an underlying expandable version of a MutableDirectBuffer.
    • Field Detail

      • offset

        private int offset
      • position

        private int position
    • Constructor Detail

      • ExpandableDirectBufferOutputStream

        public ExpandableDirectBufferOutputStream()
        Default constructor.
      • ExpandableDirectBufferOutputStream

        public ExpandableDirectBufferOutputStream​(MutableDirectBuffer buffer,
                                                  int offset)
        Wrap given MutableDirectBuffer at a given offset.
        Parameters:
        buffer - to wrap.
        offset - at which the puts will occur.
    • Method Detail

      • wrap

        public void wrap​(MutableDirectBuffer buffer)
        Wrap a given buffer beginning with an offset of 0.
        Parameters:
        buffer - to wrap
      • wrap

        public void wrap​(MutableDirectBuffer buffer,
                         int offset)
        Wrap a given buffer beginning at an offset.
        Parameters:
        buffer - to wrap
        offset - at which the puts will occur.
      • position

        public int position()
        The position in the buffer from the offset up to which has been written.
        Returns:
        the position in the buffer from the offset up to which has been written.
      • offset

        public int offset()
        The offset within the underlying buffer at which to start.
        Returns:
        offset within the underlying buffer at which to start.
      • buffer

        public MutableDirectBuffer buffer()
        The underlying buffer being wrapped.
        Returns:
        the underlying buffer being wrapped.
      • write

        public void write​(int b)
        Write a byte to buffer.
        Specified by:
        write in class java.io.OutputStream
        Parameters:
        b - to be written.
      • write

        public void write​(byte[] srcBytes,
                          int srcOffset,
                          int length)
        Write a byte[] to the buffer.
        Overrides:
        write in class java.io.OutputStream
        Parameters:
        srcBytes - to write
        srcOffset - at which to begin reading bytes from the srcBytes.
        length - of the srcBytes to read.
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.OutputStream