ByteSerializerStrategy

ByteSerializerStrategy is an implementation of the SerializerStrategy interface that uses byte streams for serialization and deserialization.

It provides methods to serialize and deserialize various data types, including primitive types, collections, and maps.

This strategy is used by default in the SerializerStrategy interface.

The serializing is defined as follows:

  1. The first 4 bytes are the size of the data.

  2. For each entry in the data:

    1. The key is written as a UTF string.

    2. The type of the value is written as a UTF string.

    3. The value is written using the appropriate method based on its type.

      • For collections, the size is written first, followed by the type of the elements. Then for each element is starts by 1.1

      • For maps, the size is written first, followed by the type of the keys and values. Then for each entry is starts by 1.1

      • For other types, the value is written directly. With the corresponding DataOutput methode.

For deserialization, the process is like the for writing, instead of writing the data, it is read.

Author

Fantamomo

Since

1.0-SNAPSHOT

Functions

Link copied to clipboard
open override fun deserialize(input: InputStream): SerializerData

Deserializes data from the provided input stream into a SerializerData object.

Link copied to clipboard
fun <V : Any> read(input: DataInputStream, type: KClass<V>): V
Link copied to clipboard
open override fun serialize(output: OutputStream, data: SerializerData)

Serializes the given data into the provided output stream.

Link copied to clipboard
fun write(out: DataOutputStream, value: Any)