Class BasicPrimitiveArrayOrMatrixSerializer<T>
java.lang.Object
org.djutils.serialization.serializers.BasicSerializer<T>
org.djutils.serialization.serializers.BasicPrimitiveArrayOrMatrixSerializer<T>
- Type Parameters:
- T- array type, e.g. int[]
- All Implemented Interfaces:
- Serializer<T>
Serializer for primitive data 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 SummaryConstructorsConstructorDescriptionBasicPrimitiveArrayOrMatrixSerializer(byte type, int elementSize, String dataClassName, int numberOfDimensions) Construct a new BasicPrimitiveArrayOrMatrixSerializer.
- 
Method SummaryModifier and TypeMethodDescriptionfinal intRetrieve the number of bytes needed to encode one additional array element.final intReturn the number of dimensions of the stored data.final voidserializeWithPrefix(T object, byte[] buffer, Pointer pointer, Endianness endianness) Serialize an object of type T including the prefix byte(s).final intsizeWithPrefix(T object) 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.BasicSerializerdataClassName, fieldType, toStringMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.djutils.serialization.serializers.SerializerdeSerialize, hasUnit, serialize, size
- 
Constructor Details- 
BasicPrimitiveArrayOrMatrixSerializerpublic BasicPrimitiveArrayOrMatrixSerializer(byte type, int elementSize, String dataClassName, int numberOfDimensions) Construct a new BasicPrimitiveArrayOrMatrixSerializer.- Parameters:
- type- the field type (returned by the- fieldTypemethod)
- elementSize- the number of bytes needed to encode one additional array element
- dataClassName- returned by the dataClassName method
- numberOfDimensions- number of dimensions (1 for array, 2 for matrix)
 
 
- 
- 
Method Details- 
sizeWithPrefixDescription 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:
- object- Instance of the object
- Returns:
- the number of bytes needed to serialize an object of type T
- Throws:
- SerializationException- when the- objectcannot be serialized
 
- 
serializeWithPrefixpublic final void serializeWithPrefix(T object, byte[] buffer, Pointer pointer, Endianness endianness) throws SerializationException Description copied from interface:SerializerSerialize an object of type T including the prefix byte(s).- Parameters:
- object- the object to serialize
- buffer- buffer for the serialized T
- pointer- position in buffer where the first byte of the serialized T will be stored
- endianness- selects bigEndian or littleEndian encoding
- Throws:
- SerializationException- when a matrix has size zero or is jagged
 
- 
getElementSizepublic final int getElementSize()Retrieve the number of bytes needed to encode one additional array element.- Returns:
- the number of bytes needed to encode one additional array element
 
- 
getNumberOfDimensionspublic final int getNumberOfDimensions()Description copied from interface:SerializerReturn the number of dimensions of the stored data.- Returns:
- 0 for plain data, 1 for array, 2 for matrix
 
 
-