1 package org.opentrafficsim.sim0mq.publisher;
2
3 import org.djutils.event.Event;
4 import org.djutils.event.EventType;
5 import org.djutils.exceptions.Throw;
6 import org.djutils.metadata.MetaData;
7 import org.djutils.serialization.EndianUtil;
8 import org.djutils.serialization.SerializationException;
9 import org.djutils.serialization.serializers.Pointer;
10 import org.djutils.serialization.serializers.Serializer;
11
12
13
14
15
16
17
18
19
20
21
22
23 public class EventSerializer<E extends Event> implements Serializer<Event>
24 {
25
26 private final EventType eventType;
27
28
29
30
31
32 EventSerializer(final EventType eventType)
33 {
34 this.eventType = eventType;
35 }
36
37
38 @Override
39 public int size(final Event event) throws SerializationException
40 {
41 EventType et = event.getType();
42 Throw.when(et.equals(this.eventType), ClassCastException.class,
43 "EventSerializer for " + this.eventType.getName() + " cannot handle event " + event);
44 int result = et.getName().length();
45 MetaData metaData = this.eventType.getMetaData();
46 for (int index = 0; index < metaData.size(); index++)
47 {
48
49 }
50 return result;
51 }
52
53
54 @Override
55 public int sizeWithPrefix(final Event event) throws SerializationException
56 {
57 return 1 + size(event);
58 }
59
60
61 @Override
62 public byte fieldType()
63 {
64 return 33;
65 }
66
67
68 @Override
69 public void serialize(final Event object, final byte[] buffer, final Pointer pointer, final EndianUtil endianUtil)
70 throws SerializationException
71 {
72
73
74 }
75
76
77 @Override
78 public void serializeWithPrefix(final Event object, final byte[] buffer, final Pointer pointer, final EndianUtil endianUtil)
79 throws SerializationException
80 {
81
82
83 }
84
85
86 @Override
87 public Event deSerialize(final byte[] buffer, final Pointer pointer, final EndianUtil endianUtil)
88 throws SerializationException
89 {
90
91 return null;
92 }
93
94
95 @Override
96 public String dataClassName()
97 {
98
99 return null;
100 }
101
102
103 @Override
104 public final int getNumberOfDimensions()
105 {
106 return 0;
107 }
108
109 }