Class ArrayOrMatrixSerializer<T,​E>

    • Constructor Detail

      • ArrayOrMatrixSerializer

        ArrayOrMatrixSerializer​(byte type,
                                int elementSize,
                                String dataClassName,
                                int numberOfDimensions)
        Construct a new ArrayOrMatrixSerializere.
        Parameters:
        type - byte; the field type (returned by the fieldType method)
        elementSize - int; the number of bytes needed to encode one additional array, or matrix element
        dataClassName - String; returned by the dataClassName method
        numberOfDimensions - int; should be 1 for array serializer and 2 for matrix serializer
    • Method Detail

      • getElementSize

        public final int getElementSize()
        Return the number of bytes needed to encode one additional element.
        Returns:
        int; the number of bytes needed to encode one additional element
      • getNumberOfDimensions

        public final int getNumberOfDimensions()
        Return the number of dimensions of the stored data.
        Returns:
        int; 1 for array, 2 for matrix
      • serializeElement

        public abstract void serializeElement​(E object,
                                              byte[] buffer,
                                              int offset,
                                              EndianUtil endianUtil)
        Serializer for one array or matrix element (without type prefix) must be implemented in implementing sub classes.
        Parameters:
        object - E; the object to serialize
        buffer - byte[]; the byte buffer for the serialized object
        offset - int; index in byte buffer where first serialized byte must be stored
        endianUtil - EndianUtil; selects bigEndian or littleEndian encoding
      • deSerializeElement

        public abstract E deSerializeElement​(byte[] buffer,
                                             int offset,
                                             EndianUtil endianUtil)
        Deserializer for one array or matrix element (without type prefix) must be implemented in implementing sub classes.
        Parameters:
        buffer - byte[]; the byte buffer from which the object is to be deserialized
        offset - int; index in byte buffer where first byte of the object is stored
        endianUtil - EndianUtil; selects bigEndian or littleEndian encoding
        Returns:
        E; the deserialized object