Class DefaultCoder
java.lang.Object
org.nustaq.serialization.simpleapi.DefaultCoder
- All Implemented Interfaces:
FSTCoder
- Direct Known Subclasses:
MinBinCoder
public class DefaultCoder extends java.lang.Object implements FSTCoder
Created by ruedi on 09.11.14.
Encodes Objects to byte arrays and vice versa using slight value compression and a platform neutral data
layout (no diff regarding big/little endian). Implementation is conservative (no unsafe)
As this makes use of the stream oriented API, operation is not zero copy. However this is not too significant
compared to cost of serialization.
KEEP and reuse instances, creation is expensive.
This class cannot be used concurrently.
Works similar to the unsafe coders, but does not use Unsafe. Note that reading and writing
coder must match each other in type and configuration.
-
Field Summary
Fields Modifier and Type Field Description protected FSTConfigurationconf -
Constructor Summary
Constructors Constructor Description DefaultCoder()DefaultCoder(boolean shared, java.lang.Class... toPreRegister)DefaultCoder(java.lang.Class... preregister) -
Method Summary
Modifier and Type Method Description FSTConfigurationgetConf()byte[]toByteArray(java.lang.Object o)inttoByteArray(java.lang.Object obj, byte[] result, int resultOffset, int avaiableSize)will throw an FSTBufferTooSmallException if buffer is too small.java.lang.ObjecttoObject(byte[] arr)java.lang.ObjecttoObject(byte[] arr, int off, int len)
-
Field Details
-
Constructor Details
-
DefaultCoder
public DefaultCoder(boolean shared, java.lang.Class... toPreRegister) -
DefaultCoder
public DefaultCoder(java.lang.Class... preregister) -
DefaultCoder
public DefaultCoder()
-
-
Method Details
-
toByteArray
public int toByteArray(java.lang.Object obj, byte[] result, int resultOffset, int avaiableSize)will throw an FSTBufferTooSmallException if buffer is too small.- Specified by:
toByteArrayin interfaceFSTCoder
-
toByteArray
public byte[] toByteArray(java.lang.Object o)- Specified by:
toByteArrayin interfaceFSTCoder
-
getConf
-
toObject
public java.lang.Object toObject(byte[] arr, int off, int len) -
toObject
public java.lang.Object toObject(byte[] arr)
-