Interface FragmentTranscoder
-
- All Known Implementing Classes:
AbstractByteArrayFragmentTranscoder,AbstractFragmentTranscoder,JacksonFragmentTranscoder
@Committed @Public public interface FragmentTranscoder
An interface for transcoding sub-document fragments (as read and written by the subdocument API, eg. inMutateInBuilderorLookupInBuilder). This is used internally by the bucket to encode fragments (for mutations) or decode fragments returned by the server in order to instantiate aDocumentFragment.- Since:
- 2.2
- Author:
- Simon Baslé
-
-
Method Summary
All Methods Instance Methods Abstract 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**.<T> TdecodeWithMessage(com.couchbase.client.deps.io.netty.buffer.ByteBuf encoded, Class<? extends T> clazz, String transcodingErrorMessage)Decode content in aByteBuf**without releasing it**.<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.
-
-
-
Method Detail
-
decode
<T> T decode(com.couchbase.client.deps.io.netty.buffer.ByteBuf encoded, Class<? extends T> clazz) throws TranscodingExceptionDecode content in aByteBuf**without releasing it**. Suitable for populating aDocumentFragment's content.- 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.
-
decodeWithMessage
<T> T decodeWithMessage(com.couchbase.client.deps.io.netty.buffer.ByteBuf encoded, Class<? extends T> clazz, String transcodingErrorMessage) throws TranscodingExceptionDecode content in aByteBuf**without releasing it**. Suitable for populating aDocumentFragment's content.- 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.transcodingErrorMessage- the error message to be used in the thrownTranscodingExceptionif the decoding couldn't happen.- Returns:
- a decoded fragment.
- Throws:
TranscodingException- if the decoding couldn't happen.
-
encode
<T> com.couchbase.client.deps.io.netty.buffer.ByteBuf encode(T value) throws TranscodingExceptionEncode a 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.- Returns:
- a
ByteBufrepresentation of the fragment value. - Throws:
TranscodingException- if the encoding couldn't happen.
-
encodeWithMessage
<T> com.couchbase.client.deps.io.netty.buffer.ByteBuf encodeWithMessage(T value, String transcodingErrorMessage) throws TranscodingExceptionEncode a 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.
-
-