/[projects]/android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/DepartureEntry.java
ViewVC logotype

Annotation of /android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/DepartureEntry.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1060 - (hide annotations) (download)
Thu Sep 16 13:32:10 2010 UTC (13 years, 8 months ago) by torben
File size: 2717 byte(s)
Experimental: use Simple (simple.sourceforge.net) for XML serialization
1 torben 305 package dk.thoerup.traininfoservice.banedk;
2    
3 torben 1060 import org.simpleframework.xml.Element;
4     import org.simpleframework.xml.Root;
5    
6     @Root(name="train")
7 torben 978 public class DepartureEntry implements Comparable<DepartureEntry> {
8 torben 1060
9     @Element
10     private String time;
11    
12     @Element
13     private int updated;
14    
15     @Element(name="trainnumber")
16 torben 305 private String trainNumber;
17 torben 1060
18     @Element
19 torben 305 private String destination;
20 torben 1060
21     @Element
22     private String origin;
23    
24     @Element
25     private String location;
26    
27     @Element
28     private String status;
29    
30     @Element
31 torben 305 private String note;
32 torben 1060
33     @Element
34 torben 697 private String type;
35 torben 305
36    
37     public String getTime() {
38     return time;
39     }
40     public void setTime(String time) {
41     this.time = time;
42     }
43     public int getUpdated() {
44     return updated;
45     }
46     public void setUpdated(int updated) {
47     this.updated = updated;
48     }
49     public String getTrainNumber() {
50     return trainNumber;
51     }
52     public void setTrainNumber(String trainNumber) {
53     this.trainNumber = trainNumber;
54     }
55     public String getDestination() {
56     return destination;
57     }
58     public void setDestination(String destination) {
59     this.destination = destination;
60     }
61     public String getOrigin() {
62     return origin;
63     }
64     public void setOrigin(String origin) {
65     this.origin = origin;
66     }
67     public String getLocation() {
68     return location;
69     }
70     public void setLocation(String location) {
71     this.location = location;
72     }
73     public String getStatus() {
74     return status;
75     }
76     public void setStatus(String status) {
77     this.status = status;
78     }
79     public String getNote() {
80     return note;
81     }
82     public void setNote(String note) {
83     this.note = note;
84     }
85    
86 torben 697 public String getType() {
87     return type;
88     }
89    
90     public void setType(String type) {
91     this.type = type;
92     }
93    
94 torben 307 @Override
95 torben 978 public int compareTo(DepartureEntry otherBean) {
96 torben 373 String timeStr1 = time.replace(":","").trim();
97     String timeStr2 = otherBean.time.replace(":","").trim();
98 torben 307
99 torben 373 int time1 = 0;
100     int time2 = 0;
101 torben 307
102 torben 373 if (timeStr1.length() > 0)
103     time1 = Integer.parseInt(timeStr1);
104    
105     if (timeStr2.length() > 0)
106     time2 = Integer.parseInt(timeStr2);
107    
108 torben 321 //work correctly when clock wraps around at midnight
109     if (Math.abs(time1-time2) < 1200) {
110     if (time1 > time2)
111     return 1;
112     else
113     return -1;
114     } else {
115     if (time1 < time2)
116     return 1;
117     else
118     return -1;
119    
120     }
121    
122 torben 307 }
123 torben 1060
124 torben 312 public String getUpdatedString() {
125     String updStr;
126    
127     switch (updated) {
128     case 1:
129     updStr = "&lt; 3 min";
130     break;
131     case 2:
132 torben 321 updStr = "3-10 min";
133 torben 312 break;
134     case 3:
135     updStr = "&gt; 10 min";
136     break;
137     case 4:
138     updStr = "No info";
139     break;
140     default:
141     updStr = "Unknown:" + updated;
142     }
143    
144     return updStr;
145     }
146 torben 307
147 torben 305 }

  ViewVC Help
Powered by ViewVC 1.1.20