Package org.djutils.data.serialization
Interface TextSerializer<T>
-
- Type Parameters:
T
- the value type
- All Known Implementing Classes:
BooleanSerializer
,ByteSerializer
,CharacterSerializer
,DoubleScalarSerializer
,DoubleSerializer
,FloatScalarSerializer
,FloatSerializer
,IntegerSerializer
,LongSerializer
,PrimitiveSerializer.Boolean
,PrimitiveSerializer.Byte
,PrimitiveSerializer.Char
,PrimitiveSerializer.Double
,PrimitiveSerializer.Float
,PrimitiveSerializer.Int
,PrimitiveSerializer.Long
,PrimitiveSerializer.Short
,ShortSerializer
,StringSerializer
public interface TextSerializer<T>
TextSerializer defines the serialize and deserialize methods.
Copyright (c) 2020-2021 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://djutils.org. The DJUTILS project is distributed under a three-clause BSD-style license, which can be found at https://djutils.org/docs/license.html.- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description Object
deserialize(String text)
Deserialize a value from text that has been created with the corresponding serializer.static TextSerializer<?>
resolve(Class<?> valueClass)
Resolve the correct (de)serializer for the given class, and return an instance of the (de)serializer.String
serialize(Object value)
Serialize a value to text in such a way that it can be deserialized with the corresponding deserializer.
-
-
-
Method Detail
-
serialize
String serialize(Object value)
Serialize a value to text in such a way that it can be deserialized with the corresponding deserializer.- Parameters:
value
- Object; the value to serialize- Returns:
- String; a string representation of the value that can later be deserialized
-
deserialize
Object deserialize(String text)
Deserialize a value from text that has been created with the corresponding serializer.- Parameters:
text
- String; the string to deserialize- Returns:
- T; an instance of the object created with the corresponding serializer
-
resolve
static TextSerializer<?> resolve(Class<?> valueClass) throws TextSerializationException
Resolve the correct (de)serializer for the given class, and return an instance of the (de)serializer.- Parameters:
valueClass
- Class<?>; the class to resolve the (de)serializer for- Returns:
- an instance of the correct (de)serializer
- Throws:
TextSerializationException
- when there is no corresponding (de)serializer for the class
-
-