Class AbstractTranscoder<D extends Document<T>,​T>

    • Constructor Detail

      • AbstractTranscoder

        public AbstractTranscoder()
    • Method Detail

      • doDecode

        protected abstract D doDecode​(String id,
                                      com.couchbase.client.deps.io.netty.buffer.ByteBuf content,
                                      long cas,
                                      int expiry,
                                      int flags,
                                      ResponseStatus status)
                               throws Exception
        Perform the decoding of the received response.
        Parameters:
        id - the id of the document.
        content - the encoded content of the document.
        cas - the cas value of the document.
        expiry - the expiration time of the document.
        flags - the flags set on the document.
        status - the response status.
        Returns:
        the decoded document.
        Throws:
        Exception - if something goes wrong during the decode process.
      • doEncode

        protected abstract Tuple2<com.couchbase.client.deps.io.netty.buffer.ByteBuf,​Integer> doEncode​(D document)
                                                                                                     throws Exception
        Perform the encoding of the request document.
        Parameters:
        document - the document to encode.
        Returns:
        A tuple consisting of the encoded content and the flags to set.
        Throws:
        Exception - if something goes wrong during the encode process.
      • shouldAutoReleaseOnDecode

        protected boolean shouldAutoReleaseOnDecode()
        Flag method to auto release decoded buffers. Override to change default behaviour (true).
        Returns:
        true if the ByteBuf passed to decode method is to be released automatically on success (default behaviour)
      • shouldAutoReleaseOnError

        protected boolean shouldAutoReleaseOnError()
        Flag method to auto release buffers on decoding error. Override to change default behaviour (true).
        Returns:
        true if the ByteBuf passed to decode method is to be released automatically in case of error (default behaviour)
      • newDocument

        public D newDocument​(String id,
                             int expiry,
                             T content,
                             long cas,
                             MutationToken mutationToken)
        Default implementation for backwards compatibility.
        Specified by:
        newDocument in interface Transcoder<D extends Document<T>,​T>
        Parameters:
        id - the id of the document.
        expiry - the document expiration.
        content - the document content.
        cas - the documents cas value.
        mutationToken - the documents mutation token.
        Returns:
        the created document.