Class AbstractFragmentTranscoder

    • Constructor Detail

      • AbstractFragmentTranscoder

        public AbstractFragmentTranscoder()
    • Method Detail

      • decode

        public <T> T decode​(com.couchbase.client.deps.io.netty.buffer.ByteBuf encoded,
                            Class<? extends T> clazz)
                     throws TranscodingException
        Description copied from interface: FragmentTranscoder
        Decode content in a ByteBuf **without releasing it**. Suitable for populating a DocumentFragment's content.
        Specified by:
        decode in interface FragmentTranscoder
        Type Parameters:
        T - the type of the decoded fragment.
        Parameters:
        encoded - the encoded fragment value (will not be released).
        clazz - the target class for decoded value. Using Object.class implies a generic decode, where dictionaries are represented by JsonObject and arrays by JsonArray.
        Returns:
        a decoded fragment.
        Throws:
        TranscodingException - if the decoding couldn't happen.
      • encode

        public <T> com.couchbase.client.deps.io.netty.buffer.ByteBuf encode​(T value)
                                                                     throws TranscodingException
        Description copied from interface: FragmentTranscoder
        Encode a value to a ByteBuf suitable for use in the sub-document protocol.
        Specified by:
        encode in interface FragmentTranscoder
        Type Parameters:
        T - the type of the fragment being encoded.
        Parameters:
        value - the value to encode.
        Returns:
        a ByteBuf representation of the fragment value.
        Throws:
        TranscodingException - if the encoding couldn't happen.
      • encodeWithMessage

        public <T> com.couchbase.client.deps.io.netty.buffer.ByteBuf encodeWithMessage​(T value,
                                                                                       String transcodingErrorMessage)
                                                                                throws TranscodingException
        Description copied from interface: FragmentTranscoder
        Encode a value to a ByteBuf suitable for use in the sub-document protocol.
        Specified by:
        encodeWithMessage in interface FragmentTranscoder
        Type Parameters:
        T - the type of the fragment being encoded.
        Parameters:
        value - the value to encode.
        transcodingErrorMessage - the error message to be used in the thrown TranscodingException if the encoding couldn't happen.
        Returns:
        a ByteBuf representation of the fragment value.
        Throws:
        TranscodingException - if the encoding couldn't happen.
      • doEncodeSingle

        protected abstract <T> com.couchbase.client.deps.io.netty.buffer.ByteBuf doEncodeSingle​(T value,
                                                                                                String transcodingErrorMessage)
                                                                                         throws TranscodingException
        Encode a single mutation value to a ByteBuf suitable for use in the sub-document protocol.
        Type Parameters:
        T - the type of the fragment being encoded.
        Parameters:
        value - the value to encode.
        transcodingErrorMessage - the error message to be used in the thrown TranscodingException if the encoding couldn't happen.
        Returns:
        a ByteBuf representation of the fragment value.
        Throws:
        TranscodingException - if the encoding couldn't happen.
      • doEncodeMulti

        protected abstract com.couchbase.client.deps.io.netty.buffer.ByteBuf doEncodeMulti​(MultiValue<?> multiValue,
                                                                                           String transcodingErrorMessage)
                                                                                    throws TranscodingException
        Encode a special mutation value that denotes multiple values being processed in bulk, to a ByteBuf suitable for use in the sub-document protocol.
        Parameters:
        multiValue - the multivalue to encode.
        transcodingErrorMessage - the error message to be used in the thrown TranscodingException if the encoding couldn't happen.
        Returns:
        a ByteBuf representation of the fragment multivalue.
        Throws:
        TranscodingException - if the encoding couldn't happen.