Class FloatMatrixSerializer<U extends org.djunits.unit.Unit<U>,​S extends org.djunits.value.vfloat.scalar.base.FloatScalarInterface<U,​S>,​V extends org.djunits.value.vfloat.vector.base.FloatVectorInterface<U,​S,​V>,​M extends org.djunits.value.vfloat.matrix.base.FloatMatrixInterface<U,​S,​V,​M>>

  • Type Parameters:
    U - the unit type
    S - the scalar type
    V - the vector type
    M - the matrix type
    All Implemented Interfaces:
    Serializer<M>

    public class FloatMatrixSerializer<U extends org.djunits.unit.Unit<U>,​S extends org.djunits.value.vfloat.scalar.base.FloatScalarInterface<U,​S>,​V extends org.djunits.value.vfloat.vector.base.FloatVectorInterface<U,​S,​V>,​M extends org.djunits.value.vfloat.matrix.base.FloatMatrixInterface<U,​S,​V,​M>>
    extends ArrayOrMatrixWithUnitSerializer<U,​M>
    (De)serializes a DJUNITS FloatMatrix.

    Copyright (c) 2019-2021 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
    BSD-style license. See DJUNITS License.

    Author:
    Alexander Verbraeck
    • Constructor Detail

      • FloatMatrixSerializer

        public FloatMatrixSerializer()
    • Method Detail

      • size

        public int size​(M afm)
                 throws SerializationException
        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).
        Parameters:
        afm - T; Instance of the object
        Returns:
        int; the number of bytes needed to serialize an object of type T
        Throws:
        SerializationException - when the object cannot be serialized
      • serialize

        public void serialize​(M afm,
                              byte[] buffer,
                              Pointer pointer,
                              EndianUtil endianUtil)
                       throws SerializationException
        Serialize an object of type T; not including the prefix byte(s).
        Parameters:
        afm - T; the object to serialize
        buffer - byte[]; buffer for the serialized T
        pointer - Pointer; position in buffer where the first byte of the serialized T will be stored
        endianUtil - EndianUtil; selects bigEndian or littleEndian encoding
        Throws:
        SerializationException - when a matrix has size zero or is jagged
      • deSerialize

        public M deSerialize​(byte[] buffer,
                             Pointer pointer,
                             EndianUtil endianUtil)
                      throws SerializationException
        Deserialize an object of type T. The pointer should be on the first byte of the object; i.e. just after the prefix byte.
        Parameters:
        buffer - byte[]; the bytes with serialized data that must be reconstructed into a T
        pointer - Pointer; position in the buffer where the first byte of the serialized T is located
        endianUtil - EndianUtil; selects bigEndian or littleEndian encoding
        Returns:
        T; a T object constructed from the data in the buffer
        Throws:
        SerializationException - when the input data cannot be deserialized