@InterfaceStability.Experimental @InterfaceAudience.Private public class JacksonFragmentTranscoder extends Object implements FragmentTranscoder
A Jackson-based implementation of a FragmentTranscoder
.
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 |
decode(com.couchbase.client.deps.io.netty.buffer.ByteBuf encoded,
Class<? extends T> clazz)
Decode content in a
ByteBuf without releasing it. |
<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. |
<T> com.couchbase.client.deps.io.netty.buffer.ByteBuf |
encode(T value)
Encode a value (usually from a
DocumentFragment ) to a ByteBuf 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 (usually from a
DocumentFragment ) to a ByteBuf suitable for use in the sub-document protocol. |
public JacksonFragmentTranscoder(com.couchbase.client.deps.com.fasterxml.jackson.databind.ObjectMapper mapper)
public <T> T decode(com.couchbase.client.deps.io.netty.buffer.ByteBuf encoded, Class<? extends T> clazz) throws TranscodingException
FragmentTranscoder
Decode content in a ByteBuf
without releasing it. Suitable for populating a DocumentFragment
’s content.
decode
in interface FragmentTranscoder
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
.TranscodingException
- if the decoding couldn’t happen.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.
decodeWithMessage
in interface FragmentTranscoder
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.public <T> com.couchbase.client.deps.io.netty.buffer.ByteBuf encode(T value) throws TranscodingException
FragmentTranscoder
Encode a value (usually from a DocumentFragment
) to a ByteBuf
suitable for use in the sub-document protocol.
encode
in interface FragmentTranscoder
value
- the value to encode.ByteBuf
representation of the fragment value.TranscodingException
- if the encoding couldn’t happen.public <T> com.couchbase.client.deps.io.netty.buffer.ByteBuf encodeWithMessage(T value, String transcodingErrorMessage) throws TranscodingException
FragmentTranscoder
Encode a value (usually from a DocumentFragment
) to a ByteBuf
suitable for use in the sub-document protocol.
encodeWithMessage
in interface FragmentTranscoder
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.Copyright © 2015 Couchbase, Inc.