Class BaseSerializingTranscoder
- java.lang.Object
-
- net.rubyeye.xmemcached.transcoders.BaseSerializingTranscoder
-
- Direct Known Subclasses:
PrimitiveTypeTranscoder
,SerializingTranscoder
,WhalinTranscoder
,WhalinV1Transcoder
public abstract class BaseSerializingTranscoder extends java.lang.Object
Base class for any transcoders that may want to work with serialized or compressed data.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
BaseSerializingTranscoder.XmcObjectInputStream
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
charset
(package private) static int
COMPRESS_RATIO
protected int
compressionThreshold
protected CompressionMode
compressMode
static java.lang.String
DEFAULT_CHARSET
static int
DEFAULT_COMPRESSION_THRESHOLD
Default compression threshold value.protected static org.slf4j.Logger
log
-
Constructor Summary
Constructors Constructor Description BaseSerializingTranscoder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
compress(byte[] in)
Compress the given array of bytes.protected java.lang.String
decodeString(byte[] data)
Decode the string with the current character set.protected byte[]
decompress(byte[] in)
Decompress the given array of bytes.protected java.lang.Object
deserialize(byte[] in)
Get the object represented by the given serialized bytes.protected byte[]
encodeString(java.lang.String in)
Encode a string into the current character set.CompressionMode
getCompressMode()
private static byte[]
gzipCompress(byte[] in)
private byte[]
gzipDecompress(byte[] in)
protected byte[]
serialize(java.lang.Object o)
Get the bytes representing the given serialized object.void
setCharset(java.lang.String to)
Set the character set for string value transcoding (defaults to UTF-8).void
setCompressionMode(CompressionMode compressMode)
void
setCompressionThreshold(int to)
Set the compression threshold to the given number of bytes.private byte[]
zipCompress(byte[] in)
private byte[]
zipDecompress(byte[] in)
-
-
-
Field Detail
-
DEFAULT_COMPRESSION_THRESHOLD
public static final int DEFAULT_COMPRESSION_THRESHOLD
Default compression threshold value.- See Also:
- Constant Field Values
-
DEFAULT_CHARSET
public static final java.lang.String DEFAULT_CHARSET
- See Also:
- Constant Field Values
-
compressionThreshold
protected int compressionThreshold
-
charset
protected java.lang.String charset
-
compressMode
protected CompressionMode compressMode
-
log
protected static final org.slf4j.Logger log
-
COMPRESS_RATIO
static int COMPRESS_RATIO
-
-
Method Detail
-
setCompressionThreshold
public void setCompressionThreshold(int to)
Set the compression threshold to the given number of bytes. This transcoder will attempt to compress any data being stored that's larger than this.- Parameters:
to
- the number of bytes
-
getCompressMode
public CompressionMode getCompressMode()
-
setCompressionMode
public void setCompressionMode(CompressionMode compressMode)
-
setCharset
public void setCharset(java.lang.String to)
Set the character set for string value transcoding (defaults to UTF-8).
-
serialize
protected byte[] serialize(java.lang.Object o)
Get the bytes representing the given serialized object.
-
deserialize
protected java.lang.Object deserialize(byte[] in)
Get the object represented by the given serialized bytes.
-
compress
public final byte[] compress(byte[] in)
Compress the given array of bytes.
-
zipCompress
private byte[] zipCompress(byte[] in)
-
gzipCompress
private static byte[] gzipCompress(byte[] in)
-
decompress
protected byte[] decompress(byte[] in)
Decompress the given array of bytes.- Returns:
- null if the bytes cannot be decompressed
-
zipDecompress
private byte[] zipDecompress(byte[] in)
-
gzipDecompress
private byte[] gzipDecompress(byte[] in)
-
decodeString
protected java.lang.String decodeString(byte[] data)
Decode the string with the current character set.
-
encodeString
protected byte[] encodeString(java.lang.String in)
Encode a string into the current character set.
-
-