T
- array type, e.g. int[]public abstract class BasicPrimitiveArrayOrMatrixSerializer<T> extends BasicSerializer<T>
Copyright (c) 2019-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
Constructor and Description |
---|
BasicPrimitiveArrayOrMatrixSerializer(byte type,
int elementSize,
String dataClassName,
int numberOfDimensions)
Construct a new BasicPrimitiveArrayOrMatrixSerializer.
|
Modifier and Type | Method and Description |
---|---|
int |
getElementSize()
Retrieve the number of bytes needed to encode one additional array element.
|
int |
getNumberOfDimensions()
Return the number of dimensions of the stored data.
|
void |
serializeWithPrefix(T object,
byte[] buffer,
Pointer pointer,
EndianUtil endianUtil)
Serialize an object of type T including the prefix byte(s).
|
int |
sizeWithPrefix(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).
|
dataClassName, fieldType, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
deSerialize, serialize, size
public BasicPrimitiveArrayOrMatrixSerializer(byte type, int elementSize, String dataClassName, int numberOfDimensions)
type
- byte; the field type (returned by the fieldType
method)elementSize
- int; the number of bytes needed to encode one additional array elementdataClassName
- String; returned by the dataClassName methodnumberOfDimensions
- int; number of dimensions (1 for array, 2 for matrix)public final int sizeWithPrefix(T object) throws SerializationException
Serializer
object
- Instance of the object (should be instance of T)SerializationException
- when the object
cannot be serializedpublic final void serializeWithPrefix(T object, byte[] buffer, Pointer pointer, EndianUtil endianUtil) throws SerializationException
Serializer
object
- Object; the object to serialize (should be of type T)buffer
- byte[]; buffer for the serialized Tpointer
- Pointer; position in buffer where the first byte of the serialized T will be storedendianUtil
- EndianUtil; selects bigEndian or littleEndian encodingSerializationException
- when a matrix has size zero or is jaggedpublic final int getElementSize()
public final int getNumberOfDimensions()
Serializer
Copyright © 2018–2019 Delft University of Technology. All rights reserved.