Class ArrayOrMatrixSerializer<T,E>
- java.lang.Object
-
- org.djutils.serialization.serializers.BasicSerializer<T>
-
- org.djutils.serialization.serializers.ArrayOrMatrixSerializer<T,E>
-
- Type Parameters:
T
- type; with [] or [][]E
- type without [] or [][]
- All Implemented Interfaces:
Serializer<T>
- Direct Known Subclasses:
ObjectArraySerializer
,ObjectMatrixSerializer
public abstract class ArrayOrMatrixSerializer<T,E> extends BasicSerializer<T>
Serializer for arrays or matrices.
-
-
Constructor Summary
Constructors Constructor Description ArrayOrMatrixSerializer(byte type, int elementSize, String dataClassName, int numberOfDimensions)
Construct a new ArrayOrMatrixSerializere.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract E
deSerializeElement(byte[] buffer, int offset, EndianUtil endianUtil)
Deserializer for one array or matrix element (without type prefix) must be implemented in implementing sub classes.int
getElementSize()
Return the number of bytes needed to encode one additional element.int
getNumberOfDimensions()
Return the number of dimensions of the stored data.abstract void
serializeElement(E object, byte[] buffer, int offset, EndianUtil endianUtil)
Serializer for one array or matrix element (without type prefix) must be implemented in implementing sub classes.-
Methods inherited from class org.djutils.serialization.serializers.BasicSerializer
dataClassName, fieldType, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.djutils.serialization.serializers.Serializer
deSerialize, serialize, serializeWithPrefix, size, sizeWithPrefix
-
-
-
-
Constructor Detail
-
ArrayOrMatrixSerializer
ArrayOrMatrixSerializer(byte type, int elementSize, String dataClassName, int numberOfDimensions)
Construct a new ArrayOrMatrixSerializere.- Parameters:
type
- byte; the field type (returned by thefieldType
method)elementSize
- int; the number of bytes needed to encode one additional array, or matrix elementdataClassName
- String; returned by the dataClassName methodnumberOfDimensions
- int; should be 1 for array serializer and 2 for matrix serializer
-
-
Method Detail
-
getElementSize
public final int getElementSize()
Return the number of bytes needed to encode one additional element.- Returns:
- int; the number of bytes needed to encode one additional element
-
getNumberOfDimensions
public final int getNumberOfDimensions()
Return the number of dimensions of the stored data.- Returns:
- int; 1 for array, 2 for matrix
-
serializeElement
public abstract void serializeElement(E object, byte[] buffer, int offset, EndianUtil endianUtil)
Serializer for one array or matrix element (without type prefix) must be implemented in implementing sub classes.- Parameters:
object
- E; the object to serializebuffer
- byte[]; the byte buffer for the serialized objectoffset
- int; index in byte buffer where first serialized byte must be storedendianUtil
- EndianUtil; selects bigEndian or littleEndian encoding
-
deSerializeElement
public abstract E deSerializeElement(byte[] buffer, int offset, EndianUtil endianUtil)
Deserializer for one array or matrix element (without type prefix) must be implemented in implementing sub classes.- Parameters:
buffer
- byte[]; the byte buffer from which the object is to be deserializedoffset
- int; index in byte buffer where first byte of the object is storedendianUtil
- EndianUtil; selects bigEndian or littleEndian encoding- Returns:
- E; the deserialized object
-
-