Class ObjectWithUnitSerializer<U extends org.djunits.unit.Unit<U>,T>

Type Parameters:
U - the unit type
T - the object type
All Implemented Interfaces:
Serializer<T>
Direct Known Subclasses:
DoubleScalarSerializer, DoubleVectorArraySerializer, FloatScalarSerializer, FloatVectorArraySerializer

public abstract class ObjectWithUnitSerializer<U extends org.djunits.unit.Unit<U>,T> extends ObjectSerializer<T>
Abstract class to (de)serializes a DJUNITS value.

Copyright (c) 2019-2025 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 Details

    • ObjectWithUnitSerializer

      public ObjectWithUnitSerializer(byte type, String dataClassName)
      Construct a new ObjectWithUnitSerializer.
      Parameters:
      type - the field type (returned by the fieldType method)
      dataClassName - returned by the dataClassName method
  • Method Details

    • encodeUnit

      protected void encodeUnit(U unit, byte[] message, Pointer pointer, EndianUtil endianUtil)
      Code a unit.
      Parameters:
      unit - the unit to code in the byte array
      message - the byte array
      pointer - the start pointer in the byte array
      endianUtil - encoder to use for multi-byte values
    • getUnit

      protected U getUnit(byte[] buffer, Pointer pointer, EndianUtil endianUtil)
      Retrieve and decode a DJUNITS unit.
      Parameters:
      buffer - the encoded data
      pointer - position in the encoded data where the unit is to be decoded from
      endianUtil - decoder for multi-byte values
      Returns:
      Unit
    • hasUnit

      public boolean hasUnit()
      Description copied from interface: Serializer
      Return whether the serializer uses a single unit type or not.
      Returns:
      whether the serializer uses a single unit type or not