1 |
torben |
305 |
package dk.thoerup.traininfoservice.banedk;
|
2 |
|
|
|
3 |
torben |
308 |
public class DepartureBean implements Comparable<DepartureBean> {
|
4 |
torben |
305 |
private String time;
|
5 |
|
|
private int updated;
|
6 |
|
|
private String trainNumber;
|
7 |
|
|
private String destination;
|
8 |
|
|
private String origin;
|
9 |
|
|
private String location;
|
10 |
|
|
private String status;
|
11 |
|
|
private String note;
|
12 |
torben |
697 |
private String type;
|
13 |
torben |
305 |
|
14 |
|
|
|
15 |
|
|
public String getTime() {
|
16 |
|
|
return time;
|
17 |
|
|
}
|
18 |
|
|
public void setTime(String time) {
|
19 |
|
|
this.time = time;
|
20 |
|
|
}
|
21 |
|
|
public int getUpdated() {
|
22 |
|
|
return updated;
|
23 |
|
|
}
|
24 |
|
|
public void setUpdated(int updated) {
|
25 |
|
|
this.updated = updated;
|
26 |
|
|
}
|
27 |
|
|
public String getTrainNumber() {
|
28 |
|
|
return trainNumber;
|
29 |
|
|
}
|
30 |
|
|
public void setTrainNumber(String trainNumber) {
|
31 |
|
|
this.trainNumber = trainNumber;
|
32 |
|
|
}
|
33 |
|
|
public String getDestination() {
|
34 |
|
|
return destination;
|
35 |
|
|
}
|
36 |
|
|
public void setDestination(String destination) {
|
37 |
|
|
this.destination = destination;
|
38 |
|
|
}
|
39 |
|
|
public String getOrigin() {
|
40 |
|
|
return origin;
|
41 |
|
|
}
|
42 |
|
|
public void setOrigin(String origin) {
|
43 |
|
|
this.origin = origin;
|
44 |
|
|
}
|
45 |
|
|
public String getLocation() {
|
46 |
|
|
return location;
|
47 |
|
|
}
|
48 |
|
|
public void setLocation(String location) {
|
49 |
|
|
this.location = location;
|
50 |
|
|
}
|
51 |
|
|
public String getStatus() {
|
52 |
|
|
return status;
|
53 |
|
|
}
|
54 |
|
|
public void setStatus(String status) {
|
55 |
|
|
this.status = status;
|
56 |
|
|
}
|
57 |
|
|
public String getNote() {
|
58 |
|
|
return note;
|
59 |
|
|
}
|
60 |
|
|
public void setNote(String note) {
|
61 |
|
|
this.note = note;
|
62 |
|
|
}
|
63 |
|
|
|
64 |
torben |
697 |
public String getType() {
|
65 |
|
|
return type;
|
66 |
|
|
}
|
67 |
|
|
|
68 |
|
|
public void setType(String type) {
|
69 |
|
|
this.type = type;
|
70 |
|
|
}
|
71 |
|
|
|
72 |
torben |
307 |
@Override
|
73 |
torben |
308 |
public int compareTo(DepartureBean otherBean) {
|
74 |
torben |
373 |
String timeStr1 = time.replace(":","").trim();
|
75 |
|
|
String timeStr2 = otherBean.time.replace(":","").trim();
|
76 |
torben |
307 |
|
77 |
torben |
373 |
int time1 = 0;
|
78 |
|
|
int time2 = 0;
|
79 |
torben |
307 |
|
80 |
torben |
373 |
if (timeStr1.length() > 0)
|
81 |
|
|
time1 = Integer.parseInt(timeStr1);
|
82 |
|
|
|
83 |
|
|
if (timeStr2.length() > 0)
|
84 |
|
|
time2 = Integer.parseInt(timeStr2);
|
85 |
|
|
|
86 |
torben |
321 |
//work correctly when clock wraps around at midnight
|
87 |
|
|
if (Math.abs(time1-time2) < 1200) {
|
88 |
|
|
if (time1 > time2)
|
89 |
|
|
return 1;
|
90 |
|
|
else
|
91 |
|
|
return -1;
|
92 |
|
|
} else {
|
93 |
|
|
if (time1 < time2)
|
94 |
|
|
return 1;
|
95 |
|
|
else
|
96 |
|
|
return -1;
|
97 |
|
|
|
98 |
|
|
}
|
99 |
|
|
|
100 |
torben |
307 |
}
|
101 |
torben |
305 |
|
102 |
torben |
312 |
public String getUpdatedString() {
|
103 |
|
|
String updStr;
|
104 |
|
|
|
105 |
|
|
switch (updated) {
|
106 |
|
|
case 1:
|
107 |
|
|
updStr = "< 3 min";
|
108 |
|
|
break;
|
109 |
|
|
case 2:
|
110 |
torben |
321 |
updStr = "3-10 min";
|
111 |
torben |
312 |
break;
|
112 |
|
|
case 3:
|
113 |
|
|
updStr = "> 10 min";
|
114 |
|
|
break;
|
115 |
|
|
case 4:
|
116 |
|
|
updStr = "No info";
|
117 |
|
|
break;
|
118 |
|
|
default:
|
119 |
|
|
updStr = "Unknown:" + updated;
|
120 |
|
|
}
|
121 |
|
|
|
122 |
|
|
return updStr;
|
123 |
|
|
}
|
124 |
torben |
307 |
|
125 |
torben |
305 |
}
|