1 package cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages;
2
3
4 import java.util.*;import javax.vecmath.*;import cz.cuni.amis.pogamut.base.communication.messages.*;import cz.cuni.amis.pogamut.base.communication.worldview.*;import cz.cuni.amis.pogamut.base.communication.worldview.event.*;import cz.cuni.amis.pogamut.base.communication.worldview.object.*;import cz.cuni.amis.pogamut.multi.communication.worldview.object.*;import cz.cuni.amis.pogamut.base.communication.translator.event.*;import cz.cuni.amis.pogamut.multi.communication.translator.event.*;import cz.cuni.amis.pogamut.base3d.worldview.object.*;import cz.cuni.amis.pogamut.base3d.worldview.object.event.*;import cz.cuni.amis.pogamut.ut2004.communication.messages.*;import cz.cuni.amis.pogamut.ut2004.communication.worldview.objects.*;import cz.cuni.amis.pogamut.ut2004multi.communication.worldview.objects.*;import cz.cuni.amis.pogamut.ut2004.communication.translator.itemdescriptor.*;import cz.cuni.amis.pogamut.ut2004.communication.messages.ItemType.Category;import cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId;import cz.cuni.amis.utils.exception.*;import cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result;import cz.cuni.amis.utils.SafeEquals;import cz.cuni.amis.pogamut.base.agent.*;import cz.cuni.amis.pogamut.multi.agent.*;import cz.cuni.amis.pogamut.multi.communication.worldview.property.*;import cz.cuni.amis.pogamut.ut2004multi.communication.worldview.property.*;import cz.cuni.amis.utils.token.*;import cz.cuni.amis.utils.*;
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 public class SelfStaticImpl
28 extends
29 SelfStatic
30 {
31
32
33
34
35
36
37 public SelfStaticImpl()
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116 public SelfStaticImpl(
117 UnrealId Id
118 ) {
119
120 this.Id = Id;
121
122 }
123
124
125
126
127
128
129 public SelfStaticImpl(Self original) {
130
131 this.Id = original.getId()
132 ;
133
134 this.SimTime = original.getSimTime();
135 }
136
137
138
139
140
141
142 public SelfStaticImpl(SelfStaticImpl original) {
143
144 this.Id = original.getId()
145 ;
146
147 this.SimTime = original.getSimTime();
148 }
149
150
151
152
153
154
155 public SelfStaticImpl(SelfStatic original) {
156
157 this.Id = original.getId()
158 ;
159
160 }
161
162
163 @Override
164 public void setSimTime(long SimTime) {
165 super.setSimTime(SimTime);
166 }
167
168 @Override
169 public
170 SelfStaticImpl clone() {
171 return new
172 SelfStaticImpl(this);
173 }
174
175
176
177
178
179
180 protected
181 UnrealId Id =
182 null;
183
184
185
186
187 public UnrealId getId()
188 {
189 return Id;
190 }
191
192
193
194 public static class SelfStaticUpdate
195 implements IStaticWorldObjectUpdatedEvent
196 {
197
198 private SelfStatic data;
199 private long time;
200
201 public SelfStaticUpdate
202 (SelfStatic source, long time)
203 {
204 this.data = source;
205 this.time = time;
206 }
207
208
209
210
211 @Override
212 public long getSimTime() {
213 return time;
214 }
215
216 @Override
217 public WorldObjectId getId() {
218 return data.getId();
219 }
220
221 @Override
222 public IWorldObjectUpdateResult<IStaticWorldObject> update(
223 IStaticWorldObject object) {
224 if ( object == null)
225 {
226 data = new SelfStaticImpl(data);
227 return new IWorldObjectUpdateResult.WorldObjectUpdateResult<IStaticWorldObject>(IWorldObjectUpdateResult.Result.CREATED, data);
228 }
229
230 if ( object instanceof SelfStaticImpl)
231 {
232 SelfStaticImpl orig = (SelfStaticImpl)object;
233
234 if ( data.isDifferentFrom(orig) )
235 {
236
237
238 System.out.println("!!!!!ERROR!!!!!! in static object modification. Object class : SelfStaticImpl to see which property was different see !!!!PROPERTY UPDATE ERROR!!!!");
239 }
240 return new IWorldObjectUpdateResult.WorldObjectUpdateResult<IStaticWorldObject>(IWorldObjectUpdateResult.Result.SAME, data);
241 }
242 throw new PogamutException("Unexpected object type for update, SelfStaticImpl expected not class " + object.getClass().getSimpleName() + ".", this);
243 }
244 }
245
246
247
248 @Override
249 public boolean isDifferentFrom(IStaticWorldObject other)
250 {
251 if (other == null)
252 {
253 return true;
254 }
255 else if (other == this)
256 {
257 return false;
258 }
259 else
260 {
261 SelfStatic obj = (SelfStatic) other;
262
263
264 if ( !(
265 AdvancedEquals.equalsOrNull(this.getId()
266 , obj.getId()
267 )
268 ) )
269 {
270 System.out.println("!!!!!PROPERTY UPDATE ERROR!!!! on property Id on object class SelfStatic");
271 return true;
272 }
273
274 }
275 return false;
276 }
277
278
279 public String toString() {
280 return
281 super.toString() + "[" +
282
283 "Id = " + String.valueOf(getId()
284 ) + " | " +
285
286 "]";
287 }
288
289
290 public String toHtmlString() {
291 return super.toString() + "[<br/>" +
292
293 "<b>Id</b> = " + String.valueOf(getId()
294 ) + " <br/> " +
295
296 "<br/>]";
297 }
298
299
300
301
302
303
304
305
306
307
308 }
309