Class CopyingStreamWindow

java.lang.Object
com.couchbase.client.core.json.stream.CopyingStreamWindow
All Implemented Interfaces:
StreamWindow, Closeable, AutoCloseable

public class CopyingStreamWindow extends Object implements StreamWindow
A stream window implementation that copies input data into a single accumulator buffer.
  • Constructor Summary

    Constructors
    Constructor
    Description
    CopyingStreamWindow(com.couchbase.client.core.deps.io.netty.buffer.ByteBufAllocator allocator)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(com.couchbase.client.core.deps.io.netty.buffer.ByteBuf buf)
    Appends the given buffer to the end of the stream.
    void
    Releases all buffers owned by the window.
    byte[]
    getBytes(long startStreamOffset, long endStreamOffset)
    Returns a region of the stream as a byte array.
    void
    releaseBefore(long releaseStreamOffset)
    Forgets any bytes with stream offsets lower then the given offset.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • CopyingStreamWindow

      public CopyingStreamWindow(com.couchbase.client.core.deps.io.netty.buffer.ByteBufAllocator allocator)
  • Method Details

    • add

      public void add(com.couchbase.client.core.deps.io.netty.buffer.ByteBuf buf)
      Description copied from interface: StreamWindow
      Appends the given buffer to the end of the stream. The window takes ownership of the buffer (and may even release it immediately).
      Specified by:
      add in interface StreamWindow
    • releaseBefore

      public void releaseBefore(long releaseStreamOffset)
      Description copied from interface: StreamWindow
      Forgets any bytes with stream offsets lower then the given offset.
      Specified by:
      releaseBefore in interface StreamWindow
      Parameters:
      releaseStreamOffset - offset relative to the start of the stream.
    • getBytes

      public byte[] getBytes(long startStreamOffset, long endStreamOffset)
      Description copied from interface: StreamWindow
      Returns a region of the stream as a byte array.
      Specified by:
      getBytes in interface StreamWindow
      Parameters:
      startStreamOffset - region start offset relative to beginning of stream.
      endStreamOffset - region end offset relative to beginning of stream.
    • close

      public void close()
      Description copied from interface: StreamWindow
      Releases all buffers owned by the window.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface StreamWindow
    • toString

      public String toString()
      Overrides:
      toString in class Object