org.djutils.serialization.serializers.FixedSizeObjectSerializer Maven / Gradle / Ivy
Show all versions of djutils-serialization Show documentation
package org.djutils.serialization.serializers;
/**
* Serializer for simple, fixed size, classes.
*
* Copyright (c) 2019-2023 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
* BSD-style license. See DJUTILS License.
*
* @version $Revision$, $LastChangedDate$, by $Author$,
* @author Alexander Verbraeck
* @author Peter Knoppers
* @param class
*/
public abstract class FixedSizeObjectSerializer extends ObjectSerializer
{
/** Size of the encoded data. */
private final int dataSize;
/**
* Construct the FixedSizeSerializer.
* @param fieldType byte; the field type (returned by the fieldType
method)
* @param serializedDataSize int; number of bytes required for serialized T
* @param dataClassName String; returned by the dataClassName method
*/
public FixedSizeObjectSerializer(final byte fieldType, final int serializedDataSize, final String dataClassName)
{
super(fieldType, dataClassName);
this.dataSize = serializedDataSize;
}
@Override
public final int size(final Object object)
{
return this.dataSize;
}
}