1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.indi.objects;
20
21 import java.text.SimpleDateFormat;
22 import java.util.Date;
23 import java.util.LinkedList;
24 import java.util.SimpleTimeZone;
25
26
27
28
29
30
31
32 public class Message extends Object<Object> {
33
34
35
36 private static final long serialVersionUID = 1L;
37
38
39
40 private final String device;
41
42
43
44 private final SimpleDateFormat dateformat;
45
46
47
48
49
50
51
52 public Message(String device) {
53 super(new LinkedList<Object>());
54 this.device = device;
55 this.dateformat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
56 this.dateformat.setTimeZone(new SimpleTimeZone(0, "GMT"));
57 }
58
59
60
61
62
63 public String getDevice() {
64 return this.device;
65 }
66
67 @Override
68 public String getXML(TransferType type, String message) {
69 return "<message" + " device=\"" + this.device + "\" message=\""
70 + message + "\" timestamp=\""
71 + this.dateformat.format(new Date()) + "\"/>";
72 }
73
74 @Override
75 public boolean oEquals(Object o) {
76 if (o instanceof Message) {
77 return ((Message) o).device.equals(this.device);
78 } else {
79 return false;
80 }
81 }
82
83 @Override
84 public int hashCode() {
85 return this.device.hashCode();
86 };
87 }