Class AbstractFragmentTranscoder
- java.lang.Object
-
- com.couchbase.client.java.transcoder.subdoc.AbstractFragmentTranscoder
-
- All Implemented Interfaces:
FragmentTranscoder
- Direct Known Subclasses:
AbstractByteArrayFragmentTranscoder
@Committed @Public public abstract class AbstractFragmentTranscoder extends Object implements FragmentTranscoder
A common implementation base of theFragmentTranscoderinterface for transcoding sub-document fragments. It recognizesMultiValueas a special encoding case to be treated separately.- Since:
- 2.2
- Author:
- Simon Baslé
-
-
Constructor Summary
Constructors Constructor Description AbstractFragmentTranscoder()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description <T> Tdecode(com.couchbase.client.deps.io.netty.buffer.ByteBuf encoded, Class<? extends T> clazz)Decode content in aByteBuf**without releasing it**.protected abstract com.couchbase.client.deps.io.netty.buffer.ByteBufdoEncodeMulti(MultiValue<?> multiValue, String transcodingErrorMessage)Encode aspecial mutation valuethat denotes multiple values being processed in bulk, to aByteBufsuitable for use in the sub-document protocol.protected abstract <T> com.couchbase.client.deps.io.netty.buffer.ByteBufdoEncodeSingle(T value, String transcodingErrorMessage)Encode a single mutation value to aByteBufsuitable for use in the sub-document protocol.<T> com.couchbase.client.deps.io.netty.buffer.ByteBufencode(T value)Encode a value to aByteBufsuitable for use in the sub-document protocol.<T> com.couchbase.client.deps.io.netty.buffer.ByteBufencodeWithMessage(T value, String transcodingErrorMessage)Encode a value to aByteBufsuitable for use in the sub-document protocol.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.couchbase.client.java.transcoder.subdoc.FragmentTranscoder
decodeWithMessage
-
-
-
-
Method Detail
-
decode
public <T> T decode(com.couchbase.client.deps.io.netty.buffer.ByteBuf encoded, Class<? extends T> clazz) throws TranscodingExceptionDescription copied from interface:FragmentTranscoderDecode content in aByteBuf**without releasing it**. Suitable for populating aDocumentFragment's content.- Specified by:
decodein interfaceFragmentTranscoder- 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. UsingObject.classimplies a generic decode, where dictionaries are represented byJsonObjectand arrays byJsonArray.- 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 TranscodingExceptionDescription copied from interface:FragmentTranscoderEncode a value to aByteBufsuitable for use in the sub-document protocol.- Specified by:
encodein interfaceFragmentTranscoder- Type Parameters:
T- the type of the fragment being encoded.- Parameters:
value- the value to encode.- Returns:
- a
ByteBufrepresentation 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 TranscodingExceptionDescription copied from interface:FragmentTranscoderEncode a value to aByteBufsuitable for use in the sub-document protocol.- Specified by:
encodeWithMessagein interfaceFragmentTranscoder- 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 thrownTranscodingExceptionif the encoding couldn't happen.- Returns:
- a
ByteBufrepresentation 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 TranscodingExceptionEncode a single mutation value to aByteBufsuitable 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 thrownTranscodingExceptionif the encoding couldn't happen.- Returns:
- a
ByteBufrepresentation 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 aspecial mutation valuethat denotes multiple values being processed in bulk, to aByteBufsuitable for use in the sub-document protocol.- Parameters:
multiValue- the multivalue to encode.transcodingErrorMessage- the error message to be used in the thrownTranscodingExceptionif the encoding couldn't happen.- Returns:
- a
ByteBufrepresentation of the fragment multivalue. - Throws:
TranscodingException- if the encoding couldn't happen.
-
-