Interface StreamWindow

All Superinterfaces:
AutoCloseable, Closeable
All Known Implementing Classes:
CopyingStreamWindow

public interface StreamWindow extends Closeable
A sliding window over the contents of a byte stream.

Implementations may use different buffering strategies for remembering recent stream data.

  • Method Summary

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

    • add

      void add(com.couchbase.client.core.deps.io.netty.buffer.ByteBuf buffer)
      Appends the given buffer to the end of the stream. The window takes ownership of the buffer (and may even release it immediately).
    • releaseBefore

      void releaseBefore(long offset)
      Forgets any bytes with stream offsets lower then the given offset.
      Parameters:
      offset - offset relative to the start of the stream.
      Throws:
      IndexOutOfBoundsException - if the given offset is positive and outside the window
    • getBytes

      byte[] getBytes(long startOffset, long endOffset)
      Returns a region of the stream as a byte array.
      Parameters:
      startOffset - region start offset relative to beginning of stream.
      endOffset - region end offset relative to beginning of stream.
      Throws:
      IndexOutOfBoundsException - if the window does not contain all of the requested region
    • close

      void close()
      Releases all buffers owned by the window.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable