E
- class of the element objectpublic abstract class ObjectArraySerializer<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 |
---|
ObjectArraySerializer(byte type,
int dataSize,
E sample,
String dataClassName)
Construct a new ObjectArraySerializer.
|
Modifier and Type | Method and Description |
---|---|
E[] |
deSerialize(byte[] buffer,
Pointer pointer,
EndianUtil endianUtil)
Deserialize an object of type T.
|
void |
serialize(E[] array,
byte[] buffer,
Pointer pointer,
EndianUtil endianUtil)
Serialize an object of type T; not including the prefix byte(s).
|
void |
serializeWithPrefix(E[] array,
byte[] buffer,
Pointer pointer,
EndianUtil endianUtil)
Serialize an object of type T including the prefix byte(s).
|
int |
size(E[] array)
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[] 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).
|
deSerializeElement, getElementSize, getNumberOfDimensions, serializeElement
dataClassName, fieldType, toString
public ObjectArraySerializer(byte type, int dataSize, E sample, String dataClassName)
type
- byte; the field type (returned by the fieldType
method)dataSize
- int; the number of bytes needed to encode one additional array elementsample
- T[]; sample object (can be zero length array).dataClassName
- String; returned by the dataClassName methodpublic final int size(E[] array)
Serializer
array
- Object; Instance of the object (should be of type T)public final int sizeWithPrefix(E[] array)
Serializer
array
- Instance of the object (should be instance of T)public final void serializeWithPrefix(E[] array, byte[] buffer, Pointer pointer, EndianUtil endianUtil) throws SerializationException
Serializer
array
- 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[] array, byte[] buffer, Pointer pointer, EndianUtil endianUtil)
Serializer
array
- 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 encodingpublic 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.