@InterfaceStability.Committed public class JsonCryptoTranscoder extends AbstractTranscoder<JsonDocument,JsonObject>
A transcoder to encode and decode with encryption/decryption support for JsonDocument
s.
Constructor and Description |
---|
JsonCryptoTranscoder(com.couchbase.client.encryption.CryptoManager cryptoManager) |
Modifier and Type | Method and Description |
---|---|
Object |
byteBufJsonValueToObject(com.couchbase.client.deps.io.netty.buffer.ByteBuf input)
Converts a
ByteBuf representing a valid JSON entity to a generic Object , without releasing the buffer. |
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,
ResponseStatus status)
Perform the decoding of the received response.
|
protected 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)
Creates a new Document with the passed in information.
|
JsonDocument |
newDocument(String id,
int expiry,
JsonObject content,
long cas,
MutationToken mutationToken)
Default implementation for backwards compatibility.
|
JsonObject |
stringToJsonObject(String input) |
decode, encode, shouldAutoReleaseOnDecode, shouldAutoReleaseOnError
public JsonCryptoTranscoder(com.couchbase.client.encryption.CryptoManager cryptoManager)
public Class<JsonDocument> documentType()
protected 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, 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)
Transcoder
Creates a new Document with the passed in information.
Use the one with the mutation token instead (Transcoder.newDocument(String, int, Object, long, MutationToken)
).
id
- the id of the document.expiry
- the document expiration.content
- the document content.cas
- the documents cas value.public JsonDocument newDocument(String id, int expiry, JsonObject content, long cas, MutationToken mutationToken)
AbstractTranscoder
Default implementation for backwards compatibility.
newDocument
in interface Transcoder<JsonDocument,JsonObject>
newDocument
in class AbstractTranscoder<JsonDocument,JsonObject>
id
- the id of the document.expiry
- the document expiration.content
- the document content.cas
- the documents cas value.mutationToken
- the documents mutation token.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
public Object byteBufJsonValueToObject(com.couchbase.client.deps.io.netty.buffer.ByteBuf input) throws Exception
Converts a ByteBuf
representing a valid JSON entity to a generic Object
, without releasing the buffer. The entity can either be a JSON object, array or scalar value, potentially with leading whitespace (which gets ignored).
Detection of JSON objects and arrays is attempted in order not to incur an additional conversion step (JSON to Map to JsonObject for example), but if a Map or List is produced, it will be transformed to JsonObject
or JsonArray
(with a warning logged).
input
- the buffer to convert. It won’t be cleared (contrary to classical decode
)Exception
Copyright © 2015 Couchbase, Inc.