Class LegacyTranscoder
- java.lang.Object
-
- com.couchbase.client.java.transcoder.AbstractTranscoder<LegacyDocument,Object>
-
- com.couchbase.client.java.transcoder.LegacyTranscoder
-
- All Implemented Interfaces:
Transcoder<LegacyDocument,Object>
public class LegacyTranscoder extends AbstractTranscoder<LegacyDocument,Object>
ATranscoder
which mimics the behavior of the Java SDK 1.* series for compatibility.- Since:
- 2.0
- Author:
- Michael Nitschinger
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_COMPRESSION_THRESHOLD
-
Constructor Summary
Constructors Constructor Description LegacyTranscoder()
LegacyTranscoder(int compressionThreshold)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected byte[]
compress(byte[] in)
static long
decodeLong(byte[] b)
protected byte[]
decompress(byte[] in)
protected Object
deserialize(byte[] in)
Class<LegacyDocument>
documentType()
protected LegacyDocument
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(LegacyDocument document)
Perform the encoding of the request document.static byte[]
encodeNum(long l, int maxBytes)
LegacyDocument
newDocument(String id, int expiry, Object content, long cas)
Creates a new Document with the passed in information.LegacyDocument
newDocument(String id, int expiry, Object content, long cas, MutationToken mutationToken)
Default implementation for backwards compatibility.-
Methods inherited from class com.couchbase.client.java.transcoder.AbstractTranscoder
decode, encode, shouldAutoReleaseOnDecode, shouldAutoReleaseOnError
-
-
-
-
Field Detail
-
DEFAULT_COMPRESSION_THRESHOLD
public static final int DEFAULT_COMPRESSION_THRESHOLD
- See Also:
- Constant Field Values
-
-
Method Detail
-
documentType
public Class<LegacyDocument> documentType()
-
doDecode
protected LegacyDocument 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:AbstractTranscoder
Perform the decoding of the received response.- Specified by:
doDecode
in classAbstractTranscoder<LegacyDocument,Object>
- 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 LegacyDocument newDocument(String id, int expiry, Object content, long cas)
Description copied from interface: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)
).- 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 LegacyDocument newDocument(String id, int expiry, Object content, long cas, MutationToken mutationToken)
Description copied from class:AbstractTranscoder
Default implementation for backwards compatibility.- Specified by:
newDocument
in interfaceTranscoder<LegacyDocument,Object>
- Overrides:
newDocument
in classAbstractTranscoder<LegacyDocument,Object>
- 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.
-
doEncode
protected Tuple2<com.couchbase.client.deps.io.netty.buffer.ByteBuf,Integer> doEncode(LegacyDocument document) throws Exception
Description copied from class:AbstractTranscoder
Perform the encoding of the request document.- Specified by:
doEncode
in classAbstractTranscoder<LegacyDocument,Object>
- 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.
-
encodeNum
public static byte[] encodeNum(long l, int maxBytes)
-
decodeLong
public static long decodeLong(byte[] b)
-
deserialize
protected Object deserialize(byte[] in)
-
compress
protected byte[] compress(byte[] in)
-
decompress
protected byte[] decompress(byte[] in)
-
-