Class IntegerSerializer

java.lang.Object
org.djutils.data.serialization.IntegerSerializer
All Implemented Interfaces:
SpecificTextSerializer<Integer>, TextSerializer<Integer>

public class IntegerSerializer extends Object implements SpecificTextSerializer<Integer>
IntegerSerializer (de)serializes Integer objects.

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

    • IntegerSerializer

      public IntegerSerializer()
  • Method Details

    • serialize

      public String serialize(Integer value, String unit)
      Description copied from interface: TextSerializer
      Serialize a value to text in such a way that it can be deserialized with the corresponding deserializer. Note that null values for value are allowed. A null values stands for an empty column value in a CVS-file, a missing tag in an XML-file, etc.
      Specified by:
      serialize in interface TextSerializer<Integer>
      Parameters:
      value - T; the value to serialize, may be null
      unit - 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, or nullto denote a missing value
    • deserialize

      public Integer deserialize(Class<Integer> type, String text, String unit)
      Description copied from interface: TextSerializer
      Deserialize a value from text that has been created with the corresponding serializer. Note that null values for text are allowed. A null values stands for an empty column value in a CVS-file, a missing tag in an XML-file, etc. In this way, we can explicitly show values that were not specified in the file. Also, the type may be null; this is, for instance, the case for any TextSerializer implementing SpecificTextSerializer, where no class needs to be provided (although it can).
      Specified by:
      deserialize in interface TextSerializer<Integer>
      Parameters:
      type - Class<T>; class of the value type, may be null
      text - String; the string to deserialize, may be null or blank
      unit - String; unit with the value, may be null or blank
      Returns:
      T; an instance of the object created with the corresponding serializer, may be null when a value was not specified in the source from which the deserializer was called