Interface Serializer<T>

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      String dataClassName()
      Return a description of the type of data that this serializer handles.
      T deSerialize​(byte[] buffer, Pointer pointer, EndianUtil endianUtil)
      Deserialize an object of type T.
      byte fieldType()
      Return the byte representation of the field type.
      int getNumberOfDimensions()
      Return the number of dimensions of the stored data.
      void serialize​(T object, byte[] buffer, Pointer pointer, EndianUtil endianUtil)
      Serialize an object of type T; not including the prefix byte(s).
      void serializeWithPrefix​(T object, byte[] buffer, Pointer pointer, EndianUtil endianUtil)
      Serialize an object of type T including the prefix byte(s).
      int size​(T object)
      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​(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).
    • Method Detail

      • size

        int size​(T object)
          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:
        object - 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
      • sizeWithPrefix

        int sizeWithPrefix​(T object)
                    throws SerializationException
        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).
        Parameters:
        object - 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
      • fieldType

        byte fieldType()
        Return the byte representation of the field type.
        Returns:
        byte
      • serialize

        void serialize​(T object,
                       byte[] buffer,
                       Pointer pointer,
                       EndianUtil endianUtil)
                throws SerializationException
        Serialize an object of type T; not including the prefix byte(s).
        Parameters:
        object - 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
      • serializeWithPrefix

        void serializeWithPrefix​(T object,
                                 byte[] buffer,
                                 Pointer pointer,
                                 EndianUtil endianUtil)
                          throws SerializationException
        Serialize an object of type T including the prefix byte(s).
        Parameters:
        object - 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

        T 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
      • dataClassName

        String dataClassName()
        Return a description of the type of data that this serializer handles. The result of this method should not be subject to localization because it is used in the SerialDataDecoder to identify the type of a serializer.
        Returns:
        String; description of the type of data that this serializer handles
      • getNumberOfDimensions

        int getNumberOfDimensions()
        Return the number of dimensions of the stored data.
        Returns:
        int; 0 for plain data, 1 for array, 2 for matrix