Class AbstractSubdocRequest

All Implemented Interfaces:
CouchbaseMessage, CouchbaseRequest, BinaryRequest, BinarySubdocRequest
Direct Known Subclasses:
AbstractSubdocMutationRequest, SubExistRequest, SubGetCountRequest, SubGetRequest

@Committed
@Public
public abstract class AbstractSubdocRequest
extends AbstractKeyValueRequest
implements BinarySubdocRequest
Base class for all BinarySubdocRequest.
Since:
1.2
Author:
Simon Baslé
  • Field Details

  • Constructor Details

    • AbstractSubdocRequest

      public AbstractSubdocRequest​(String key, String path, String bucket, ByteBuf... restOfContent)
      Creates a new AbstractSubdocRequest.
      Parameters:
      key - the key of the document.
      path - the subdocument path to consider inside the document.
      bucket - the bucket of the document.
      restOfContent - the optional remainder of the content() of the final protocol message, or null if not applicable
      Throws:
      NullPointerException - if the path is null (see EXCEPTION_NULL_PATH)
    • AbstractSubdocRequest

      public AbstractSubdocRequest​(String key, String path, String bucket, rx.subjects.Subject<CouchbaseResponse,​CouchbaseResponse> observable, ByteBuf... restOfContent)
      Creates a new AbstractSubdocRequest.
      Parameters:
      key - the key of the document.
      path - the subdocument path to consider inside the document.
      bucket - the bucket of the document.
      observable - the observable which receives responses.
      restOfContent - the optional remainder of the content() of the final protocol message, or null if not applicable
      Throws:
      NullPointerException - if the path is null (see EXCEPTION_NULL_PATH)
  • Method Details

    • cleanUpAndThrow

      protected void cleanUpAndThrow​(RuntimeException e)
      Utility method to ensure good cleanup when throwing an exception from a constructor. Cleans the content composite buffer by releasing it before throwing the exception.
    • createContent

      protected ByteBuf createContent​(ByteBuf pathByteBuf, ByteBuf... restOfContent)
    • path

      public String path()
      Description copied from interface: BinarySubdocRequest
      Returns the **path** inside a JSON document where values will be obtained/mutated. Some sub-document operations authorize the use of an empty path while other don't.
      Specified by:
      path in interface BinarySubdocRequest
      Returns:
      the path to work from inside the JSON document.
    • pathLength

      public int pathLength()
      Specified by:
      pathLength in interface BinarySubdocRequest
      Returns:
      the length of the path as encoded in the BinarySubdocRequest.content() (can serve as an offset from 0 to find the path in the content).
    • content

      public ByteBuf content()
      Description copied from interface: BinarySubdocRequest
      The ByteBuf bearing the full content for this request. The content is at a minimum comprised of the BinarySubdocRequest.path() as UTF8 bytes, and can also have any other relevant payload appended (eg. a JSON fragment for mutative operations, see BinarySubdocMutationRequest.fragment()). This buffer is to be automatically released once the message has been written on the wire.
      Specified by:
      content in interface BinarySubdocRequest
      Returns:
      the ByteBuf to serve as a memcached protocol message body.