public class TranscoderUtils extends Object
Helper methods and flags for the shipped Transcoder
s.
Modifier and Type | Class and Description |
---|---|
static class |
TranscoderUtils.CommonFlags
The common flags enum.
|
Modifier and Type | Field and Description |
---|---|
static int |
BINARY_COMMON_FLAGS |
static int |
BINARY_COMPAT_FLAGS |
static int |
BINARY_LEGACY_FLAGS |
static int |
BOOLEAN_COMPAT_FLAGS |
static int |
BOOLEAN_LEGACY_FLAGS |
static int |
COMMON_FORMAT_MASK
32bit flag is composed of: - 3 compression bits - 1 bit reserved for future use - 4 format flags bits.
|
static int |
DOUBLE_COMPAT_FLAGS |
static int |
DOUBLE_LEGACY_FLAGS |
static int |
JSON_COMMON_FLAGS |
static int |
JSON_COMPAT_FLAGS |
static int |
JSON_LEGACY_FLAGS |
static int |
LONG_COMPAT_FLAGS |
static int |
LONG_LEGACY_FLAGS |
static int |
PRIVATE_COMMON_FLAGS |
static int |
SERIALIZED_COMPAT_FLAGS |
static int |
SERIALIZED_LEGACY_FLAGS |
static int |
STRING_COMMON_FLAGS |
static int |
STRING_COMPAT_FLAGS |
static int |
STRING_LEGACY_FLAGS |
Constructor and Description |
---|
TranscoderUtils() |
Modifier and Type | Method and Description |
---|---|
static int |
createCommonFlags(int flags)
Takes a integer representation of flags and moves them to the common flags MSBs.
|
static Serializable |
deserialize(com.couchbase.client.deps.io.netty.buffer.ByteBuf content)
Takes the input content and deserializes it.
|
static int |
extractCommonFlags(int flags)
Returns only the common flags from the full flags.
|
static boolean |
hasBinaryFlags(int flags)
Checks if the flags identify a binary document.
|
static boolean |
hasCommonFlags(int flags)
Checks whether the upper 8 bits are set, indicating common flags presence.
|
static boolean |
hasCommonFormat(int flags,
int expectedCommonFlag)
Checks that flags has common flags bits set and that they correspond to expected common flags format.
|
static boolean |
hasCompressionFlags(int flags)
Checks whether the upper 3 bits are set, indicating compression presence.
|
static boolean |
hasJsonFlags(int flags)
Checks if the flags identify a JSON document.
|
static boolean |
hasSerializableFlags(int flags)
Checks if the flags identify a serialized document.
|
static boolean |
hasStringFlags(int flags)
Checks if the flags identify a String document.
|
static com.couchbase.client.deps.io.netty.buffer.ByteBuf |
serialize(Serializable serializable)
Serializes the input into a ByteBuf.
|
public static final int COMMON_FORMAT_MASK
32bit flag is composed of: - 3 compression bits - 1 bit reserved for future use - 4 format flags bits. those 8 upper bits make up the common flags - 8 bits reserved for future use - 16 bits for legacy flags
This mask allows to compare a 32 bits flags with the 4 common flag format bits (“00001111 00000000 00000000 00000000”).
public static final int PRIVATE_COMMON_FLAGS
public static final int JSON_COMMON_FLAGS
public static final int BINARY_COMMON_FLAGS
public static final int STRING_COMMON_FLAGS
public static final int SERIALIZED_LEGACY_FLAGS
public static final int BINARY_LEGACY_FLAGS
public static final int STRING_LEGACY_FLAGS
public static final int JSON_LEGACY_FLAGS
public static final int BOOLEAN_LEGACY_FLAGS
public static final int LONG_LEGACY_FLAGS
public static final int DOUBLE_LEGACY_FLAGS
public static final int SERIALIZED_COMPAT_FLAGS
public static final int JSON_COMPAT_FLAGS
public static final int BINARY_COMPAT_FLAGS
public static final int BOOLEAN_COMPAT_FLAGS
public static final int LONG_COMPAT_FLAGS
public static final int DOUBLE_COMPAT_FLAGS
public static final int STRING_COMPAT_FLAGS
public static boolean hasCommonFlags(int flags)
Checks whether the upper 8 bits are set, indicating common flags presence.
It does this by shifting bits to the right until only the most significant bits are remaining and then checks if one of them is set.
flags
- the flags to check.public static boolean hasCompressionFlags(int flags)
Checks whether the upper 3 bits are set, indicating compression presence.
It does this by shifting bits to the right until only the most significant bits are remaining and then checks if one of them is set.
flags
- the flags to check.public static boolean hasCommonFormat(int flags, int expectedCommonFlag)
Checks that flags has common flags bits set and that they correspond to expected common flags format.
flags
- the 32 bits flags to checkexpectedCommonFlag
- the expected common flags format bitspublic static int extractCommonFlags(int flags)
Returns only the common flags from the full flags.
flags
- the flags to check.public static int createCommonFlags(int flags)
Takes a integer representation of flags and moves them to the common flags MSBs.
flags
- the flags to shift.public static boolean hasJsonFlags(int flags)
Checks if the flags identify a JSON document.
This method is strict if it finds common flags set, and if not falls back to a check of legacy JSON string (identified by 0 flags and no compression).
flags
- the flags to check.public static boolean hasStringFlags(int flags)
Checks if the flags identify a String document.
This method is strict if it finds common flags set, and if not falls back to a check of legacy String (identified by 0 flags and no compression).
flags
- the flags to check.public static boolean hasSerializableFlags(int flags)
Checks if the flags identify a serialized document.
flags
- the flags to check.public static boolean hasBinaryFlags(int flags)
Checks if the flags identify a binary document.
flags
- the flags to check.public static Serializable deserialize(com.couchbase.client.deps.io.netty.buffer.ByteBuf content) throws Exception
Takes the input content and deserializes it.
content
- the content to deserialize.Exception
- if something goes wrong during deserialization.public static com.couchbase.client.deps.io.netty.buffer.ByteBuf serialize(Serializable serializable) throws Exception
Serializes the input into a ByteBuf.
serializable
- the object to serialize.Exception
- if something goes wrong during serialization.Copyright © 2014 Couchbase, Inc.