Package org.agrona.io

Class ExpandableDirectBufferOutputStream

java.lang.Object
java.io.OutputStream
org.agrona.io.ExpandableDirectBufferOutputStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

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

    • buffer

      private MutableDirectBuffer buffer
    • offset

      private int offset
    • position

      private int position
  • Constructor Details

    • ExpandableDirectBufferOutputStream

      public ExpandableDirectBufferOutputStream()
      Default constructor.
    • ExpandableDirectBufferOutputStream

      public ExpandableDirectBufferOutputStream(MutableDirectBuffer buffer)
      Parameters:
      buffer - to wrap.
    • 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 Details

    • 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 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 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 AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class OutputStream