public class JsonTranscoder extends AbstractTranscoder<JsonDocument,JsonObject>
A transcoder to encode and decode JsonDocument
s.
Constructor and Description |
---|
JsonTranscoder() |
Modifier and Type | Method and Description |
---|---|
JsonObject |
byteBufToJsonObject(com.couchbase.client.deps.io.netty.buffer.ByteBuf input)
Converts a
ByteBuf to a JsonObject , without releasing the buffer |
Class<JsonDocument> |
documentType() |
protected JsonDocument |
doDecode(String id,
com.couchbase.client.deps.io.netty.buffer.ByteBuf content,
long cas,
int expiry,
int flags,
com.couchbase.client.core.message.ResponseStatus status)
Perform the decoding of the received response.
|
protected com.couchbase.client.core.lang.Tuple2<com.couchbase.client.deps.io.netty.buffer.ByteBuf,Integer> |
doEncode(JsonDocument document)
Perform the encoding of the request document.
|
String |
jsonObjectToString(JsonObject input) |
JsonDocument |
newDocument(String id,
int expiry,
JsonObject content,
long cas) |
JsonObject |
stringToJsonObject(String input) |
decode, encode, shouldAutoReleaseOnDecode, shouldAutoReleaseOnError
public Class<JsonDocument> documentType()
protected com.couchbase.client.core.lang.Tuple2<com.couchbase.client.deps.io.netty.buffer.ByteBuf,Integer> doEncode(JsonDocument document) throws Exception
AbstractTranscoder
Perform the encoding of the request document.
doEncode
in class AbstractTranscoder<JsonDocument,JsonObject>
document
- the document to encode.Exception
- if something goes wrong during the encode process.protected JsonDocument doDecode(String id, com.couchbase.client.deps.io.netty.buffer.ByteBuf content, long cas, int expiry, int flags, com.couchbase.client.core.message.ResponseStatus status) throws Exception
AbstractTranscoder
Perform the decoding of the received response.
doDecode
in class AbstractTranscoder<JsonDocument,JsonObject>
id
- the id of the document.content
- the encoded content of the document.cas
- the cas value of the document.expiry
- the expiration time of the document.flags
- the flags set on the document.status
- the response status.Exception
- if something goes wrong during the decode process.public JsonDocument newDocument(String id, int expiry, JsonObject content, long cas)
public String jsonObjectToString(JsonObject input) throws Exception
Exception
public JsonObject stringToJsonObject(String input) throws Exception
Exception
public JsonObject byteBufToJsonObject(com.couchbase.client.deps.io.netty.buffer.ByteBuf input) throws Exception
Converts a ByteBuf
to a JsonObject
, without releasing the buffer
input
- the buffer to convert. It won’t be cleared (contrary to classical decode
)Exception
Copyright © 2014 Couchbase, Inc.