blob: 127f314783cc301ed1be041f68faa37230cb2f1b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
package core;
import core.time.*;
import events.*;
import prefs.VSPrefs;
import protocols.*;
public class VSMessage extends VSPrefs {
private String protocolClassname;
private VSPrefs prefs;
private VSProcess sendingProcess;
private VSVectorTime vectorTime;
private long lamportTime;
private long messageID;
private static long messageCounter;
public VSMessage(String protocolClassname) {
this.protocolClassname = protocolClassname;
this.messageID = ++messageCounter;
}
public void init(VSProcess process) {
this.sendingProcess = process;
this.prefs = process.getPrefs();
lamportTime = sendingProcess.getLamportTime();
vectorTime = sendingProcess.getVectorTime().getCopy();
}
public String getName() {
return VSRegisteredEvents.getName(getProtocolClassname());
}
public String getProtocolClassname() {
return protocolClassname;
}
public long getMessageID() {
return messageID;
}
public VSProcess getSendingProcess() {
return sendingProcess;
}
public long getLamportTime() {
return lamportTime;
}
public VSVectorTime getVectorTime() {
return vectorTime;
}
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append("ID: ");
buffer.append(messageID);
buffer.append("; ");
buffer.append(prefs.getString("lang.protocol"));
buffer.append(": ");
buffer.append(VSRegisteredEvents.getShortname(getProtocolClassname()));
return buffer.toString();
}
public String toStringFull() {
return toString() + "; " + super.toString();
}
public boolean equals(VSMessage message) {
return messageID == message.getMessageID();
}
public void logg(String message) { }
}
|