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 the
FragmentTranscoder
interface for transcoding sub-document fragments.
It recognizes MultiValue
as a special encoding case to be treated separately.- Since:
- 2.2
- Author:
- Simon Baslé
-
Constructor Summary
Constructors Constructor Description AbstractFragmentTranscoder()
-
Method Summary
Modifier and Type Method Description <T> T
decode(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.ByteBuf
doEncodeMulti(MultiValue<?> multiValue, String transcodingErrorMessage)
Encode aspecial mutation value
that denotes multiple values being processed in bulk, to aByteBuf
suitable for use in the sub-document protocol.protected abstract <T> com.couchbase.client.deps.io.netty.buffer.ByteBuf
doEncodeSingle(T value, String transcodingErrorMessage)
Encode a single mutation value to aByteBuf
suitable for use in the sub-document protocol.<T> com.couchbase.client.deps.io.netty.buffer.ByteBuf
encode(T value)
Encode a value to aByteBuf
suitable for use in the sub-document protocol.<T> com.couchbase.client.deps.io.netty.buffer.ByteBuf
encodeWithMessage(T value, String transcodingErrorMessage)
Encode a value to aByteBuf
suitable 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
-
Constructor Details
-
AbstractFragmentTranscoder
public AbstractFragmentTranscoder()
-
-
Method Details
-
decode
public <T> T decode(com.couchbase.client.deps.io.netty.buffer.ByteBuf encoded, Class<? extends T> clazz) throws TranscodingExceptionDescription copied from interface:FragmentTranscoder
Decode content in aByteBuf
**without releasing it**. Suitable for populating aDocumentFragment
's content.- Specified by:
decode
in 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.class
implies a generic decode, where dictionaries are represented byJsonObject
and 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:FragmentTranscoder
Encode a value to aByteBuf
suitable for use in the sub-document protocol.- Specified by:
encode
in interfaceFragmentTranscoder
- 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 TranscodingExceptionDescription copied from interface:FragmentTranscoder
Encode a value to aByteBuf
suitable for use in the sub-document protocol.- Specified by:
encodeWithMessage
in 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 thrownTranscodingException
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 TranscodingExceptionEncode a single mutation value to aByteBuf
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 thrownTranscodingException
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 TranscodingExceptionEncode aspecial mutation value
that denotes multiple values being processed in bulk, to aByteBuf
suitable for use in the sub-document protocol.- Parameters:
multiValue
- the multivalue to encode.transcodingErrorMessage
- the error message to be used in the thrownTranscodingException
if the encoding couldn't happen.- Returns:
- a
ByteBuf
representation of the fragment multivalue. - Throws:
TranscodingException
- if the encoding couldn't happen.
-