Class DoubleScalarSerializer<U extends org.djunits.unit.Unit<U>,S extends org.djunits.value.vdouble.scalar.base.DoubleScalar<U,S>>

java.lang.Object
org.djutils.data.serialization.DoubleScalarSerializer<U,S>
Type Parameters:
U - the unit type
S - the scalar type
All Implemented Interfaces:
TextSerializer<S>

public class DoubleScalarSerializer<U extends org.djunits.unit.Unit<U>,S extends org.djunits.value.vdouble.scalar.base.DoubleScalar<U,S>> extends Object implements TextSerializer<S>
DoubleScalarSerializer (de)serializes DJUNITS double scalars.

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

Author:
Alexander Verbraeck, Peter Knoppers, Wouter Schakel
  • Constructor Details

    • DoubleScalarSerializer

      public DoubleScalarSerializer()
  • Method Details

    • serialize

      public String serialize(S value, String unitString)
      Serialize an Scalar value to text in such a way that it can be deserialized with the corresponding deserializer.
      Specified by:
      serialize in interface TextSerializer<U extends org.djunits.unit.Unit<U>>
      Parameters:
      value - Object; the scalar to serialize
      unitString - String; the unit used to convert the data to and store, so all valus in a column may have the same unit. The value may be null or blank
      Returns:
      String; a string representation of the value that can later be deserialized
    • deserialize

      public S deserialize(Class<S> type, String text, String unit)
      Deserialize a String to the correct Scalar value. The method caches the valueOf(String) method for repeated use.
      Specified by:
      deserialize in interface TextSerializer<U extends org.djunits.unit.Unit<U>>
      Parameters:
      text - String; the text to deserialize
      type - Class<T>; class of the value type, may be null
      unit - String; unit with the value, may be null or blank
      Returns:
      S; the reconstructed scalar