@InterfaceStability.Uncommitted @InterfaceAudience.Private public class JacksonFragmentTranscoder extends AbstractFragmentTranscoder
A Jackson-based implementation of a FragmentTranscoder
, based on AbstractFragmentTranscoder
.
Care should be taken to not use Jackson specific annotations if you want to be able to easily swap this for another SubdocumentTranscoder implementation at a later time.
Constructor and Description |
---|
JacksonFragmentTranscoder(com.couchbase.client.deps.com.fasterxml.jackson.databind.ObjectMapper mapper) |
Modifier and Type | Method and Description |
---|---|
<T> T |
decodeWithMessage(com.couchbase.client.deps.io.netty.buffer.ByteBuf encoded,
Class<? extends T> clazz,
String transcodingErrorMessage)
Decode content in a
ByteBuf without releasing it. |
protected com.couchbase.client.deps.io.netty.buffer.ByteBuf |
doEncodeMulti(MultiValue<?> multiValue,
String transcodingErrorMessage)
Encode a
special mutation value that denotes multiple values being processed in bulk, to a ByteBuf suitable for use in the sub-document protocol. |
protected <T> com.couchbase.client.deps.io.netty.buffer.ByteBuf |
doEncodeSingle(T value,
String transcodingErrorMessage)
Encode a single mutation value to a
ByteBuf suitable for use in the sub-document protocol. |
decode, encode, encodeWithMessage
public JacksonFragmentTranscoder(com.couchbase.client.deps.com.fasterxml.jackson.databind.ObjectMapper mapper)
public <T> T decodeWithMessage(com.couchbase.client.deps.io.netty.buffer.ByteBuf encoded, Class<? extends T> clazz, String transcodingErrorMessage) throws TranscodingException
FragmentTranscoder
Decode content in a ByteBuf
without releasing it. Suitable for populating a DocumentFragment
’s content.
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
.transcodingErrorMessage
- the error message to be used in the thrown TranscodingException
if the decoding couldn’t happen.TranscodingException
- if the decoding couldn’t happen.protected <T> com.couchbase.client.deps.io.netty.buffer.ByteBuf doEncodeSingle(T value, String transcodingErrorMessage) throws TranscodingException
AbstractFragmentTranscoder
Encode a single mutation value to a ByteBuf
suitable for use in the sub-document protocol.
doEncodeSingle
in class AbstractFragmentTranscoder
value
- the value to encode.transcodingErrorMessage
- the error message to be used in the thrown TranscodingException
if the encoding couldn’t happen.ByteBuf
representation of the fragment value.TranscodingException
- if the encoding couldn’t happen.protected com.couchbase.client.deps.io.netty.buffer.ByteBuf doEncodeMulti(MultiValue<?> multiValue, String transcodingErrorMessage) throws TranscodingException
AbstractFragmentTranscoder
Encode a special mutation value
that denotes multiple values being processed in bulk, to a ByteBuf
suitable for use in the sub-document protocol.
doEncodeMulti
in class AbstractFragmentTranscoder
multiValue
- the multivalue to encode.transcodingErrorMessage
- the error message to be used in the thrown TranscodingException
if the encoding couldn’t happen.ByteBuf
representation of the fragment multivalue.TranscodingException
- if the encoding couldn’t happen.Copyright © 2015 Couchbase, Inc.