voldemort.serialization.json
Class JsonTypeSerializer
java.lang.Object
voldemort.serialization.json.JsonTypeSerializer
- All Implemented Interfaces:
- Serializer<java.lang.Object>
public class JsonTypeSerializer
- extends java.lang.Object
- implements Serializer<java.lang.Object>
A serializer that goes from a simple JSON like object definition + an object
instance to serialized bytes and back again.
Official motto of this class: "I fought the static type system, and the type
system won."
Method Summary |
byte[] |
toBytes(java.lang.Object object)
Construct an array of bytes from the given object |
void |
toBytes(java.lang.Object object,
java.io.DataOutputStream output)
|
java.lang.Object |
toObject(byte[] bytes)
Create an object from an array of bytes |
java.lang.Object |
toObject(java.io.DataInputStream input)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
JsonTypeSerializer
public JsonTypeSerializer(java.lang.String typeDef)
JsonTypeSerializer
public JsonTypeSerializer(java.lang.String typeDef,
boolean hasVersion)
JsonTypeSerializer
public JsonTypeSerializer(JsonTypeDefinition typeDef)
JsonTypeSerializer
public JsonTypeSerializer(JsonTypeDefinition typeDef,
boolean hasVersion)
JsonTypeSerializer
public JsonTypeSerializer(java.util.Map<java.lang.Integer,JsonTypeDefinition> typeDefVersions)
toBytes
public byte[] toBytes(java.lang.Object object)
- Description copied from interface:
Serializer
- Construct an array of bytes from the given object
- Specified by:
toBytes
in interface Serializer<java.lang.Object>
- Parameters:
object
- The object
- Returns:
- The bytes taken from the object
toBytes
public void toBytes(java.lang.Object object,
java.io.DataOutputStream output)
throws java.io.IOException
- Throws:
java.io.IOException
toObject
public java.lang.Object toObject(byte[] bytes)
- Description copied from interface:
Serializer
- Create an object from an array of bytes
- Specified by:
toObject
in interface Serializer<java.lang.Object>
- Parameters:
bytes
- An array of bytes with the objects data
- Returns:
- A java object serialzed from the bytes
toObject
public java.lang.Object toObject(java.io.DataInputStream input)
throws java.io.IOException
- Throws:
java.io.IOException
Jay Kreps, Roshan Sumbaly, Alex Feinberg, Bhupesh Bansal, Lei Gao, Chinmay Soman, Vinoth Chandar, Zhongjie Wu