Class ObjectArraySerializer<E>
java.lang.Object
org.djutils.serialization.serializers.BasicSerializer<T>
org.djutils.serialization.serializers.ArrayOrMatrixSerializer<E[],E>
org.djutils.serialization.serializers.ObjectArraySerializer<E>
- Type Parameters:
E- class of the element object
- All Implemented Interfaces:
Serializer<E[]>
Serializer for Object array classes.
Copyright (c) 2019-2025 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See DJUTILS License.
- Author:
- Alexander Verbraeck, Peter Knoppers
-
Constructor Summary
ConstructorsConstructorDescriptionObjectArraySerializer(byte type, int dataSize, E sample, String dataClassName) Construct a new ObjectArraySerializer. -
Method Summary
Modifier and TypeMethodDescriptionfinal E[]deSerialize(byte[] buffer, Pointer pointer, Endianness endianness) Deserialize an object of type T.final voidserialize(E[] array, byte[] buffer, Pointer pointer, Endianness endianness) Serialize an object of type T; not including the prefix byte(s).final voidserializeWithPrefix(E[] array, byte[] buffer, Pointer pointer, Endianness endianness) Serialize an object of type T including the prefix byte(s).final intCompute the number of bytes needed to serialize an object of type T (excluding the byte(s) that indicate that an object of type T is next in the data stream).final intsizeWithPrefix(E[] array) Compute the number of bytes needed to serialize an object of type T (including the byte(s) that indicate that an object of type T is next in the data stream).Methods inherited from class org.djutils.serialization.serializers.ArrayOrMatrixSerializer
deSerializeElement, getElementSize, getNumberOfDimensions, serializeElementMethods inherited from class org.djutils.serialization.serializers.BasicSerializer
dataClassName, fieldType, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.djutils.serialization.serializers.Serializer
hasUnit
-
Constructor Details
-
ObjectArraySerializer
Construct a new ObjectArraySerializer.- Parameters:
type- the field type (returned by thefieldTypemethod)dataSize- the number of bytes needed to encode one additional array elementsample- sample object (can be zero length array).dataClassName- returned by the dataClassName method
-
-
Method Details
-
size
Description copied from interface:SerializerCompute the number of bytes needed to serialize an object of type T (excluding the byte(s) that indicate that an object of type T is next in the data stream).- Parameters:
array- Instance of the object- Returns:
- the number of bytes needed to serialize an object of type T
-
sizeWithPrefix
Description copied from interface:SerializerCompute the number of bytes needed to serialize an object of type T (including the byte(s) that indicate that an object of type T is next in the data stream).- Parameters:
array- Instance of the object- Returns:
- the number of bytes needed to serialize an object of type T
-
serializeWithPrefix
public final void serializeWithPrefix(E[] array, byte[] buffer, Pointer pointer, Endianness endianness) throws SerializationException Description copied from interface:SerializerSerialize an object of type T including the prefix byte(s).- Parameters:
array- the object to serializebuffer- buffer for the serialized Tpointer- position in buffer where the first byte of the serialized T will be storedendianness- selects bigEndian or littleEndian encoding- Throws:
SerializationException- when a matrix has size zero or is jagged
-
serialize
Description copied from interface:SerializerSerialize an object of type T; not including the prefix byte(s).- Parameters:
array- the object to serializebuffer- buffer for the serialized Tpointer- position in buffer where the first byte of the serialized T will be storedendianness- selects bigEndian or littleEndian encoding
-
deSerialize
Description copied from interface:SerializerDeserialize an object of type T. Thepointershould be on the first byte of the object; i.e. just after the prefix byte.- Parameters:
buffer- the bytes with serialized data that must be reconstructed into a Tpointer- position in the buffer where the first byte of the serialized T is locatedendianness- selects bigEndian or littleEndian encoding- Returns:
- a T object constructed from the data in the buffer
-