E
- class of the single (not matrix or vector) typepublic abstract class ObjectMatrixSerializer<E> extends ArrayOrMatrixSerializer<E[][],E>
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 |
---|
ObjectMatrixSerializer(byte type,
int dataSize,
Class<E> dataClass,
String dataClassName)
Construct a new ObjectMatrixSerializer.
|
Modifier and Type | Method and Description |
---|---|
E[][] |
deSerialize(byte[] buffer,
Pointer pointer,
EndianUtil endianUtil)
Deserialize an object of type T.
|
void |
serialize(E[][] matrix,
byte[] buffer,
Pointer pointer,
EndianUtil endianUtil)
Serialize an object of type T; not including the prefix byte(s).
|
void |
serializeWithPrefix(E[][] matrix,
byte[] buffer,
Pointer pointer,
EndianUtil endianUtil)
Serialize an object of type T including the prefix byte(s).
|
int |
size(E[][] matrix)
Compute 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).
|
int |
sizeWithPrefix(E[][] matrix)
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).
|
deSerializeElement, getElementSize, getNumberOfDimensions, serializeElement
dataClassName, fieldType, toString
public ObjectMatrixSerializer(byte type, int dataSize, Class<E> dataClass, String dataClassName)
type
- byte; the field type (returned by the fieldType
method)dataSize
- int; the number of bytes needed to encode one additional array elementdataClass
- Class<T>; class of the single object that needs to be serializeddataClassName
- String; returned by the dataClassName methodpublic final int size(E[][] matrix) throws SerializationException
Serializer
matrix
- Object; Instance of the object (should be of type T)SerializationException
- when the object
cannot be serializedpublic final int sizeWithPrefix(E[][] matrix) throws SerializationException
Serializer
matrix
- Instance of the object (should be instance of T)SerializationException
- when the object
cannot be serializedpublic final void serializeWithPrefix(E[][] matrix, byte[] buffer, Pointer pointer, EndianUtil endianUtil) throws SerializationException
Serializer
matrix
- 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 void serialize(E[][] matrix, byte[] buffer, Pointer pointer, EndianUtil endianUtil) throws SerializationException
Serializer
matrix
- 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 E[][] deSerialize(byte[] buffer, Pointer pointer, EndianUtil endianUtil)
Serializer
pointer
should be on the first byte of the object; i.e. just after the
prefix byte.buffer
- byte[]; the bytes with serialized data that must be reconstructed into a Tpointer
- Pointer; position in the buffer where the first byte of the serialized T is locatedendianUtil
- EndianUtil; selects bigEndian or littleEndian encodingCopyright © 2018–2019 Delft University of Technology. All rights reserved.