blob: 69c9c6a1ae2996584ff69299e5b92754d432daca (
plain) (
blame)
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
|
package NET.worlds.scape;
public class Event implements Cloneable {
public static final Class eventSuperclass = new Object().getClass();
public int time;
public Object source;
public WObject target;
public WObject receiver;
public Event(int time, Object source, WObject target) {
this.time = time;
this.source = source;
this.target = target;
}
@Override
public Object clone() {
try {
return super.clone();
} catch (CloneNotSupportedException var2) {
System.out.println("Clone of Object not supported!");
return null;
}
}
public boolean isA(Class c) {
for (Class t = this.getClass(); t != eventSuperclass; t = t.getSuperclass()) {
if (t == c) {
return true;
}
}
return false;
}
public boolean deliver(Object o) {
return o instanceof Handler && ((Handler)o).handle(this);
}
@Override
public String toString() {
String result = "Event at " + this.time;
String sname = null;
if (this.source instanceof SuperRoot) {
sname = ((SuperRoot)this.source).getName();
} else if (this.source != null) {
sname = this.source.toString();
}
if (sname != null) {
result = result + " from " + sname;
}
String tname = null;
if (this.target != null) {
this.target.getName();
}
if (tname != null) {
result = result + " to " + tname;
}
String rname = null;
if (this.receiver != null) {
this.receiver.getName();
}
if (rname != null) {
result = result + " handled by " + rname;
}
return result;
}
}
|