T - Type of the object to serialize.public abstract class VersionedSerializer<T>
extends java.lang.Object
ByteArraySegment serialize(T object) if you want the VersionedSerializer to do this for you.
Be mindful that this will create a new buffer for the serialization, which might affect performance.
Data Formats
* RevisionDataOutput and RevisionDataInput extend Java's DataOutput(Stream) and DataInput(Stream) and they use those
classes' implementations for encoding primitive data types.
* On top of that, they provide APIs for serializing commonly used structures:
** UUIDs
** Collections
** Maps
** Compact Numbers (Integers which serialize to 1, 2 or 4 bytes and Longs that serialize to 1, 2, 4 or 8 bytes).
* Refer to RevisionDataOutput and RevisionDataInput Javadoc for more details.| Modifier and Type | Class and Description |
|---|---|
static class |
VersionedSerializer.Direct<TargetType>
A Single-Type VersionedDeserializer that serializes and deserializes into the same object.
|
protected static class |
VersionedSerializer.FormatVersion<TargetType,ReaderType>
Represents a Version of a Format.
|
static class |
VersionedSerializer.MultiType<BaseType>
A VersionedDeserializer that serializes deserializes objects instantiating different types that inherit from a single
base type.
|
protected static interface |
VersionedSerializer.StreamReader<ReaderType>
Defines a Function that deserializes data from a RevisionDataInput into a target Object.
|
protected static interface |
VersionedSerializer.StreamWriter<TargetType>
Defines a Function that serializes an Object to a RevisionDataOutput.
|
static class |
VersionedSerializer.WithBuilder<TargetType,ReaderType extends ObjectBuilder<TargetType>>
A Single-Type VersionedDeserializer that deserializes into a "Builder" object.
|
| Constructor and Description |
|---|
VersionedSerializer() |
| Modifier and Type | Method and Description |
|---|---|
abstract void |
serialize(java.io.OutputStream stream,
T object)
Serializes the given object to the given OutputStream.
|
void |
serialize(RevisionDataOutput dataOutput,
T object)
Serializes the given object to the given RevisionDataOutput.
|
ByteArraySegment |
serialize(T object)
Serializes the given object to an in-memory buffer (RandomAccessOutputStream) and returns a view of it.
|
public void serialize(RevisionDataOutput dataOutput, T object) throws java.io.IOException
dataOutput - The RevisionDataOutput to serialize to.object - The object to serialize.java.io.IOException - If an IO Exception occurred.public ByteArraySegment serialize(T object) throws java.io.IOException
object - The object to serialize.java.io.IOException - If an IO Exception occurred.public abstract void serialize(java.io.OutputStream stream,
T object)
throws java.io.IOException
stream - The OutputStream to serialize to.object - The object to serialize.java.io.IOException - If an IO Exception occurred.