1 package org.djutils.serialization.serializers;
2
3 import org.djutils.serialization.EndianUtil;
4 import org.djutils.serialization.SerializationException;
5
6
7
8
9
10
11
12
13
14
15
16 public abstract class ObjectSerializer<T extends Object> extends BasicSerializer<T>
17 {
18
19
20
21
22
23 public ObjectSerializer(final byte type, final String dataClassName)
24 {
25 super(type, dataClassName);
26 }
27
28 @Override
29 public final int sizeWithPrefix(final T object) throws SerializationException
30 {
31 return 1 + size(object);
32 }
33
34 @Override
35 public final void serializeWithPrefix(final T object, final byte[] buffer, final Pointer pointer,
36 final EndianUtil endianUtil) throws SerializationException
37 {
38 buffer[pointer.getAndIncrement(1)] = fieldType();
39 serialize(object, buffer, pointer, endianUtil);
40 }
41
42 @Override
43 public final int getNumberOfDimensions()
44 {
45 return 0;
46 }
47
48 }