1
2
3
4 package org.orekit.gnss.metric.ntrip;
5
6 import org.orekit.gnss.metric.messages.ParsedMessage;
7
8 import java.util.Collections;
9 import java.util.HashMap;
10 import java.util.Map;
11
12
13
14
15
16 public class LoggingObserver implements MessageObserver {
17
18
19 private final Map<Integer, Integer> typesCounts;
20
21
22 private final Map<String, Integer> mountPointsCounts;
23
24
25
26 public LoggingObserver() {
27 typesCounts = new HashMap<>();
28 mountPointsCounts = new HashMap<>();
29 }
30
31
32 @Override
33 public void messageAvailable(final String mountPoint, final ParsedMessage message) {
34
35
36 final Integer tc = typesCounts.get(message.getTypeCode());
37 if (tc == null) {
38 typesCounts.put(message.getTypeCode(), 1);
39 } else {
40 typesCounts.put(message.getTypeCode(), tc + 1);
41 }
42
43
44 final Integer mpc = mountPointsCounts.get(mountPoint);
45 if (mpc == null) {
46 mountPointsCounts.put(mountPoint, 1);
47 } else {
48 mountPointsCounts.put(mountPoint, mpc + 1);
49 }
50
51 }
52
53
54
55
56 public Map<Integer, Integer> getCountByMessageType() {
57 return Collections.unmodifiableMap(typesCounts);
58 }
59
60
61
62
63 public Map<String, Integer> getCountByMountPoint() {
64 return Collections.unmodifiableMap(mountPointsCounts);
65 }
66
67 }