1
2 package hoplugins.teamAnalyzer.vo;
3
4 import hoplugins.Commons;
5
6 import hoplugins.commons.utils.DateUtil;
7 import hoplugins.commons.utils.HTCalendar;
8 import hoplugins.commons.utils.HTCalendarFactory;
9
10 import plugins.IMatchKurzInfo;
11 import plugins.IMatchLineup;
12 import plugins.IPaarung;
13
14 import java.util.Date;
15
16
17 /***
18 * Match Value object that holds relevant information about the game
19 *
20 * @author <a href=mailto:draghetto@users.sourceforge.net>Massimiliano Amato</a>
21 */
22 public class Match {
23
24
25 /*** The match playing date */
26 private Date matchDate;
27
28 /*** The away team name */
29 private String awayTeam;
30
31 /*** The home team name */
32 private String homeTeam;
33
34 /*** Goals scored by the home team */
35 private int awayGoals;
36
37 /*** The away team id */
38 private int awayId;
39
40 /*** Goals scored by the home team */
41 private int homeGoals;
42
43 /*** The home team id */
44 private int homeId;
45
46 /*** The match id */
47 private int matchId;
48
49 /*** The match type */
50 private int matchType;
51
52 /*** HT Season of the game */
53 private int season;
54
55 /*** HT Week of the game */
56 private int week;
57
58
59
60 /***
61 * Creates a new Match object.
62 *
63 * @param matchInfo IMatckKurtzInfo from which a match object has to be created
64 */
65 public Match(IMatchKurzInfo matchInfo) {
66 homeId = matchInfo.getHeimID();
67 awayId = matchInfo.getGastID();
68 matchId = matchInfo.getMatchID();
69 homeTeam = matchInfo.getHeimName();
70 awayTeam = matchInfo.getGastName();
71 homeGoals = matchInfo.getHeimTore();
72 awayGoals = matchInfo.getGastTore();
73 matchType = matchInfo.getMatchTyp();
74 matchDate = matchInfo.getMatchDateAsTimestamp();
75
76 Date matchDate = DateUtil.resetDay(matchInfo.getMatchDateAsTimestamp());
77
78 HTCalendar matchCal = HTCalendarFactory.createEconomyCalendar(Commons.getModel(), matchDate);
79
80 week = matchCal.getHTWeek();
81 season = matchCal.getHTSeason();
82 }
83
84 /***
85 * Creates a new Match object.
86 *
87 * @param matchInfo IPaarung from which a match object has to be created
88 */
89 public Match(IPaarung matchInfo) {
90 homeId = matchInfo.getHeimId();
91 awayId = matchInfo.getGastId();
92 matchId = matchInfo.getMatchId();
93 homeTeam = matchInfo.getHeimName();
94 awayTeam = matchInfo.getGastName();
95 homeGoals = matchInfo.getToreHeim();
96 awayGoals = matchInfo.getToreGast();
97 season = matchInfo.getSaison();
98 week = matchInfo.getSpieltag();
99 matchType = IMatchLineup.LIGASPIEL;
100 matchDate = matchInfo.getDatum();
101 }
102
103 /***
104 * Creates a new empty Match object.
105 */
106 public Match() {
107 }
108
109
110
111 /***
112 * Document Me!
113 *
114 * @param i
115 */
116 public void setAwayGoals(int i) {
117 awayGoals = i;
118 }
119
120 /***
121 * Document Me!
122 *
123 * @return
124 */
125 public int getAwayGoals() {
126 return awayGoals;
127 }
128
129 /***
130 * Document Me!
131 *
132 * @param i
133 */
134 public void setAwayId(int i) {
135 awayId = i;
136 }
137
138 /***
139 * Document Me!
140 *
141 * @return
142 */
143 public int getAwayId() {
144 return awayId;
145 }
146
147 /***
148 * Document Me!
149 *
150 * @param string
151 */
152 public void setAwayTeam(String string) {
153 awayTeam = string;
154 }
155
156 /***
157 * Document Me!
158 *
159 * @return
160 */
161 public String getAwayTeam() {
162 return awayTeam;
163 }
164
165 /***
166 * Document Me!
167 *
168 * @param i
169 */
170 public void setHomeGoals(int i) {
171 homeGoals = i;
172 }
173
174 /***
175 * Document Me!
176 *
177 * @return
178 */
179 public int getHomeGoals() {
180 return homeGoals;
181 }
182
183 /***
184 * Document Me!
185 *
186 * @param i
187 */
188 public void setHomeId(int i) {
189 homeId = i;
190 }
191
192 /***
193 * Document Me!
194 *
195 * @return
196 */
197 public int getHomeId() {
198 return homeId;
199 }
200
201 /***
202 * Document Me!
203 *
204 * @param string
205 */
206 public void setHomeTeam(String string) {
207 homeTeam = string;
208 }
209
210 /***
211 * Document Me!
212 *
213 * @return
214 */
215 public String getHomeTeam() {
216 return homeTeam;
217 }
218
219 /***
220 * Document Me!
221 *
222 * @param date
223 */
224 public void setMatchDate(Date date) {
225 matchDate = date;
226 }
227
228 /***
229 * Document Me!
230 *
231 * @return
232 */
233 public Date getMatchDate() {
234 return matchDate;
235 }
236
237 /***
238 * Document Me!
239 *
240 * @param i
241 */
242 public void setMatchId(int i) {
243 matchId = i;
244 }
245
246 /***
247 * Document Me!
248 *
249 * @return
250 */
251 public int getMatchId() {
252 return matchId;
253 }
254
255 /***
256 * Document Me!
257 *
258 * @param i
259 */
260 public void setMatchType(int i) {
261 matchType = i;
262 }
263
264 /***
265 * Document Me!
266 *
267 * @return
268 */
269 public int getMatchType() {
270 return matchType;
271 }
272
273 /***
274 * Document Me!
275 *
276 * @param i
277 */
278 public void setSeason(int i) {
279 season = i;
280 }
281
282 /***
283 * Document Me!
284 *
285 * @return
286 */
287 public int getSeason() {
288 return season;
289 }
290
291 /***
292 * Document Me!
293 *
294 * @param i
295 */
296 public void setWeek(int i) {
297 week = i;
298 }
299
300 /***
301 * Document Me!
302 *
303 * @return
304 */
305 public int getWeek() {
306 return week;
307 }
308
309 /***
310 * toString methode: creates a String representation of the object
311 *
312 * @return the String representation
313 */
314 public String toString() {
315 StringBuffer buffer = new StringBuffer();
316
317 buffer.append("Match[");
318 buffer.append("homeId = " + homeId);
319 buffer.append(", awayId = " + awayId);
320 buffer.append(", matchId = " + matchId);
321 buffer.append(", homeTeam = " + homeTeam);
322 buffer.append(", awayTeam = " + awayTeam);
323 buffer.append(", homeGoals = " + homeGoals);
324 buffer.append(", awayGoals = " + awayGoals);
325 buffer.append(", season = " + season);
326 buffer.append(", week = " + week);
327 buffer.append(", matchType = " + matchType);
328 buffer.append(", matchDate = " + matchDate);
329 buffer.append("]");
330
331 return buffer.toString();
332 }
333 }