Class StringArraySerializer
java.lang.Object
org.djutils.serialization.serializers.BasicSerializer<String[]>
org.djutils.serialization.serializers.StringArraySerializer
- All Implemented Interfaces:
Serializer<String[]>
StringArraySerializercontains the basic methods to (de)serialize a String array.
Copyright (c) 2023-2025 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
-
Constructor Summary
ConstructorsConstructorDescriptionStringArraySerializer
(byte type, String dataClassName) Construct the StringArraySerializer. -
Method Summary
Modifier and TypeMethodDescriptionfinal int
Return the number of dimensions of the stored data.final void
serializeWithPrefix
(String[] object, byte[] buffer, Pointer pointer, EndianUtil endianUtil) Serialize an object of type T including the prefix byte(s).final int
sizeWithPrefix
(String[] 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).Methods inherited from class org.djutils.serialization.serializers.BasicSerializer
dataClassName, fieldType, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.djutils.serialization.serializers.Serializer
deSerialize, hasUnit, serialize, size
-
Constructor Details
-
StringArraySerializer
Construct the StringArraySerializer.- Parameters:
type
- the field type (returned by thefieldType
method)dataClassName
- returned by the dataClassName method
-
-
Method Details
-
sizeWithPrefix
Description copied from interface:Serializer
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
- Instance of the object- Returns:
- the number of bytes needed to serialize an object of type T
- Throws:
SerializationException
- when theobject
cannot be serialized
-
serializeWithPrefix
public final void serializeWithPrefix(String[] object, byte[] buffer, Pointer pointer, EndianUtil endianUtil) throws SerializationException Description copied from interface:Serializer
Serialize an object of type T including the prefix byte(s).- Parameters:
object
- the object to serializebuffer
- buffer for the serialized Tpointer
- position in buffer where the first byte of the serialized T will be storedendianUtil
- selects bigEndian or littleEndian encoding- Throws:
SerializationException
- when a matrix has size zero or is jagged
-
getNumberOfDimensions
public final int getNumberOfDimensions()Description copied from interface:Serializer
Return the number of dimensions of the stored data.- Returns:
- 0 for plain data, 1 for array, 2 for matrix
-