1 package cz.cuni.amis.pogamut.usar2004.communication.messages.usarinfomessages;
2
3 import java.util.*;
4 import cz.cuni.amis.pogamut.base.communication.worldview.event.*;
5 import cz.cuni.amis.pogamut.base.communication.worldview.object.*;
6 import cz.cuni.amis.pogamut.base.communication.translator.event.*;
7 import cz.cuni.amis.pogamut.usar2004.communication.messages.*;
8 import cz.cuni.amis.pogamut.usar2004.communication.messages.datatypes.CustomTypes.*;
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 public class ResponseMessage extends GBEvent implements IWorldEvent, IWorldChangeEvent
31 {
32 public ResponseMessage(double Time, String Type, String Config, String Status)
33 {
34 this.Type = Type;
35 this.Time = Time;
36 this.Config = Config;
37 if(Status != null)
38 {
39 this.Statuses.add(Status);
40 }
41 }
42
43
44
45 public static final String PROTOTYPE = "RES {Time 0} {Type text} {Config text}";
46
47
48 protected double Time = 0;
49
50
51
52
53
54
55 public double getTime()
56 {
57 return Time;
58 }
59 protected String Type = null;
60
61
62
63
64
65
66
67 public String getType()
68 {
69 return Type;
70 }
71
72 protected String Config = null;
73
74
75
76
77
78
79
80 public String getConfig()
81 {
82 return Config;
83 }
84
85 protected List<String> Statuses = new ArrayList<String>();
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102 public List<String> getStatuses()
103 {
104 return Statuses;
105 }
106 protected List<String> Viewports = new ArrayList<String>();
107
108
109
110
111
112
113
114
115
116 public List<String> getViewports()
117 {
118 return Viewports;
119 }
120
121 protected List<String> Names = new ArrayList<String>();
122
123
124
125
126
127
128
129
130
131
132 public List<String> getNames()
133 {
134 return Names;
135 }
136 protected List<String> FOVs = new ArrayList<String>();
137
138
139
140
141
142
143
144
145 public List<String> getFOVs()
146 {
147 return FOVs;
148 }
149
150
151
152
153
154 public ResponseMessage(ResponseMessage original)
155 {
156 this.Type = original.Type;
157 this.Time = original.Time;
158 this.Config = original.Config;
159 this.FOVs.addAll(original.FOVs);
160 this.Names.addAll(original.Names);
161 this.Statuses.addAll(original.Statuses);
162 this.Viewports.addAll(original.Viewports);
163 }
164
165
166
167
168
169 public ResponseMessage()
170 {
171 }
172
173
174
175 private IWorldObject orig = null;
176
177 @Override
178 public String toString()
179 {
180 StringBuilder buf = new StringBuilder();
181
182 buf.append(super.toString() + " | "
183 + "Type = "
184 + String.valueOf(Type) + " | "
185 + "Time = "
186 + String.valueOf(Time) + " | "
187 + "Config = "
188 + String.valueOf(Config) + " | ");
189
190 if(!Statuses.isEmpty())
191 {
192 for(String i : Statuses)
193 {
194 buf.append("Status = ").append(i).append(" ");
195 }
196 buf.append(" | ");
197 }
198
199 if(!Viewports.isEmpty())
200 {
201 for(int i = 0; i < Viewports.size(); i++)
202 {
203 buf.append("Viewport").append(i).append(" = ").append(Viewports.get(i)).append(" ");
204 }
205 buf.append(" | ");
206 }
207
208 if(!Names.isEmpty())
209 {
210 for(String i : Names)
211 {
212 buf.append("Names = ").append(i).append(" ");
213 }
214 buf.append(" | ");
215 }
216
217 if(!FOVs.isEmpty())
218 {
219 for(String i : FOVs)
220 {
221 buf.append("FOV = ").append(i).append(" ");
222 }
223 buf.append(" | ");
224 }
225
226
227 return buf.toString();
228
229
230
231
232
233
234 }
235
236
237
238
239
240
241 public String toHtmlString()
242 {
243 StringBuilder buf = new StringBuilder();
244
245 buf.append(super.toString()
246 + "<b>Type</b> : "
247 + String.valueOf(Type)
248 + " <br/> "
249 + "<b>Time</b> : "
250 + String.valueOf(Time)
251 + " <br/> "
252 + "<b>Config</b> : "
253 + String.valueOf(Config)
254 + " <br/> ");
255
256 if(!Statuses.isEmpty())
257 {
258 for(String i : Statuses)
259 {
260 buf.append("<b>Status</b> : ").append(i).append(" <br/> ");
261 }
262 }
263 if(!Viewports.isEmpty())
264 {
265 for(int i = 0; i < Viewports.size(); i++)
266 {
267 buf.append("<b>Viewport").append(i).append("</b> : ").append(Viewports.get(i)).append(" <br/> ");
268 }
269 }
270 if(!Names.isEmpty())
271 {
272 for(String i : Names)
273 {
274 buf.append("<b>Names</b> : ").append(i).append(" <br/> ");
275 }
276 }
277 if(!FOVs.isEmpty())
278 {
279 for(String i : FOVs)
280 {
281 buf.append("<b>FOV</b> : ").append(i).append(" <br/> ");
282 }
283 }
284
285 return buf.toString();
286 }
287 }