Class JsonCryptoTranscoder
- java.lang.Object
-
- com.couchbase.client.java.transcoder.AbstractTranscoder<JsonDocument,JsonObject>
-
- com.couchbase.client.java.transcoder.crypto.JsonCryptoTranscoder
-
- All Implemented Interfaces:
Transcoder<JsonDocument,JsonObject>
@Committed public class JsonCryptoTranscoder extends AbstractTranscoder<JsonDocument,JsonObject>
A transcoder to encode and decode with encryption/decryption support forJsonDocuments.- Since:
- 2.6.0
- Author:
- Michael Nitchinger, Subhashni Balakrishnan
-
-
Constructor Summary
Constructors Constructor Description JsonCryptoTranscoder(CryptoManager cryptoManager)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectbyteBufJsonValueToObject(com.couchbase.client.deps.io.netty.buffer.ByteBuf input)Converts aByteBufrepresenting a valid JSON entity to a genericObject, without releasing the buffer.JsonObjectbyteBufToJsonObject(com.couchbase.client.deps.io.netty.buffer.ByteBuf input)Converts aByteBufto aJsonObject, without releasing the bufferClass<JsonDocument>documentType()protected JsonDocumentdoDecode(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.StringjsonObjectToString(JsonObject input)JsonDocumentnewDocument(String id, int expiry, JsonObject content, long cas)Creates a new Document with the passed in information.JsonDocumentnewDocument(String id, int expiry, JsonObject content, long cas, MutationToken mutationToken)Default implementation for backwards compatibility.JsonObjectstringToJsonObject(String input)-
Methods inherited from class com.couchbase.client.java.transcoder.AbstractTranscoder
decode, encode, shouldAutoReleaseOnDecode, shouldAutoReleaseOnError
-
-
-
-
Constructor Detail
-
JsonCryptoTranscoder
public JsonCryptoTranscoder(CryptoManager cryptoManager)
-
-
Method Detail
-
documentType
public Class<JsonDocument> documentType()
-
doEncode
protected Tuple2<com.couchbase.client.deps.io.netty.buffer.ByteBuf,Integer> doEncode(JsonDocument document) throws Exception
Description copied from class:AbstractTranscoderPerform the encoding of the request document.- Specified by:
doEncodein classAbstractTranscoder<JsonDocument,JsonObject>- Parameters:
document- the document to encode.- Returns:
- A tuple consisting of the encoded content and the flags to set.
- Throws:
Exception- if something goes wrong during the encode process.
-
doDecode
protected JsonDocument doDecode(String id, com.couchbase.client.deps.io.netty.buffer.ByteBuf content, long cas, int expiry, int flags, ResponseStatus status) throws Exception
Description copied from class:AbstractTranscoderPerform the decoding of the received response.- Specified by:
doDecodein classAbstractTranscoder<JsonDocument,JsonObject>- Parameters:
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.- Returns:
- the decoded document.
- Throws:
Exception- if something goes wrong during the decode process.
-
newDocument
public JsonDocument newDocument(String id, int expiry, JsonObject content, long cas)
Description copied from interface:TranscoderCreates a new Document with the passed in information. Use the one with the mutation token instead (Transcoder.newDocument(String, int, Object, long, MutationToken)).- Parameters:
id- the id of the document.expiry- the document expiration.content- the document content.cas- the documents cas value.- Returns:
- the created document.
-
newDocument
public JsonDocument newDocument(String id, int expiry, JsonObject content, long cas, MutationToken mutationToken)
Description copied from class:AbstractTranscoderDefault implementation for backwards compatibility.- Specified by:
newDocumentin interfaceTranscoder<JsonDocument,JsonObject>- Overrides:
newDocumentin classAbstractTranscoder<JsonDocument,JsonObject>- Parameters:
id- the id of the document.expiry- the document expiration.content- the document content.cas- the documents cas value.mutationToken- the documents mutation token.- Returns:
- the created document.
-
jsonObjectToString
public String jsonObjectToString(JsonObject input) throws Exception
- Throws:
Exception
-
stringToJsonObject
public JsonObject stringToJsonObject(String input) throws Exception
- Throws:
Exception
-
byteBufToJsonObject
public JsonObject byteBufToJsonObject(com.couchbase.client.deps.io.netty.buffer.ByteBuf input) throws Exception
Converts aByteBufto aJsonObject, without releasing the buffer- Parameters:
input- the buffer to convert. It won't be cleared (contrary toclassical decode)- Returns:
- a JsonObject decoded from the buffer
- Throws:
Exception
-
byteBufJsonValueToObject
public Object byteBufJsonValueToObject(com.couchbase.client.deps.io.netty.buffer.ByteBuf input) throws Exception
Converts aByteBufrepresenting a valid JSON entity to a genericObject, 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 toJsonObjectorJsonArray(with a warning logged).- Parameters:
input- the buffer to convert. It won't be cleared (contrary toclassical decode)- Returns:
- a Object decoded from the buffer
- Throws:
Exception
-
-