Class AbstractBinarySerializer<T>
- java.lang.Object
-
- org.atlanmod.commons.io.serializer.AbstractBinarySerializer<T>
-
- Type Parameters:
T- the type of (de)serialized objects
- All Implemented Interfaces:
Serializable,Function<T,byte[]>,Converter<T,byte[]>,BinarySerializer<T>,Serializer<T,byte[]>
@ParametersAreNonnullByDefault public abstract class AbstractBinarySerializer<T> extends Object implements BinarySerializer<T>
An abstractBinarySerializerfor objects of typeT.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description AbstractBinarySerializer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Tdeserialize(byte[] data)Reads and assembles an object of typeTfrom the givendata.Tdeserialize(InputStream is)Reads and assembles an object of typeTfrom the givenis.byte[]serialize(T t)Write an object of typeTinto its basic representation.voidserialize(T t, OutputStream os)Write an object of typeTto the givenos.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.atlanmod.commons.io.serializer.BinarySerializer
deserialize, serialize
-
Methods inherited from interface org.atlanmod.commons.io.serializer.Serializer
convert, revert
-
-
-
-
Method Detail
-
serialize
@Nonnull public byte[] serialize(T t) throws IOException
Description copied from interface:SerializerWrite an object of typeTinto its basic representation.- Specified by:
serializein interfaceSerializer<T,byte[]>- Parameters:
t- the object to serialize- Returns:
- the serialized object
- Throws:
IOException- if an I/O error occurs during the serialization
-
deserialize
@Nonnull public T deserialize(byte[] data) throws IOException
Description copied from interface:SerializerReads and assembles an object of typeTfrom the givendata.- Specified by:
deserializein interfaceSerializer<T,byte[]>- Parameters:
data- the basic representation of the object- Returns:
- the deserialized object
- Throws:
IOException- if an I/O error occurs during the deserialization
-
serialize
public void serialize(T t, @WillNotClose OutputStream os) throws IOException
Description copied from interface:BinarySerializerWrite an object of typeTto the givenos.If the
osalso implementsDataOutput, prefer usingBinarySerializer.serialize(Object, DataOutput). This method will create a adapter onosbefore calling it.- Specified by:
serializein interfaceBinarySerializer<T>- Parameters:
t- the object to serializeos- the output stream- Throws:
IOException- if an I/O error occurs during the serialization
-
deserialize
@Nonnull public T deserialize(@WillNotClose InputStream is) throws IOException
Description copied from interface:BinarySerializerReads and assembles an object of typeTfrom the givenis.If the
isalso implementsDataInput, prefer usingBinarySerializer.deserialize(DataInput). This method will create a adapter onisbefore calling it.- Specified by:
deserializein interfaceBinarySerializer<T>- Parameters:
is- the input stream- Returns:
- the deserialized object
- Throws:
IOException- if an I/O error occurs during the deserialization
-
-