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

Diff of /android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/DepartureBean.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 697 by torben, Mon May 3 07:42:02 2010 UTC revision 1021 by torben, Mon Aug 30 13:59:54 2010 UTC
# Line 1  Line 1 
1  package dk.thoerup.traininfoservice.banedk;  package dk.thoerup.traininfoservice.banedk;
2    
3  public class DepartureBean implements Comparable<DepartureBean> {  import java.util.ArrayList;
4          private String time;      import java.util.HashSet;
5          private int updated;      import java.util.List;
6          private String trainNumber;  import java.util.Set;
7          private String destination;  
8          private String origin;    public class DepartureBean {
9          private String location;                  
10          private String status;            String stationName;
11          private String note;          
12          private String type;          Set<String> notifications = new HashSet<String>();
13                    List<DepartureEntry> departureEntries = new ArrayList<DepartureEntry>();
14                    
15          public String getTime() {          public Set<String> getNotifications() {
16                  return time;                  return notifications;
17          }          }
18          public void setTime(String time) {          
19                  this.time = time;          public List<DepartureEntry> getEntries() {
20          }                  return departureEntries;
21          public int getUpdated() {          }
22                  return updated;          
23          }          public String getStationName() {
24          public void setUpdated(int updated) {                  return stationName;
25                  this.updated = updated;          }
26          }          
27          public String getTrainNumber() {  }
                 return trainNumber;  
         }  
         public void setTrainNumber(String trainNumber) {  
                 this.trainNumber = trainNumber;  
         }  
         public String getDestination() {  
                 return destination;  
         }  
         public void setDestination(String destination) {  
                 this.destination = destination;  
         }  
         public String getOrigin() {  
                 return origin;  
         }  
         public void setOrigin(String origin) {  
                 this.origin = origin;  
         }  
         public String getLocation() {  
                 return location;  
         }  
         public void setLocation(String location) {  
                 this.location = location;  
         }  
         public String getStatus() {  
                 return status;  
         }  
         public void setStatus(String status) {  
                 this.status = status;  
         }  
         public String getNote() {  
                 return note;  
         }  
         public void setNote(String note) {  
                 this.note = note;  
         }  
           
         public String getType() {  
                 return type;  
         }  
           
         public void setType(String type) {  
                 this.type = type;  
         }  
           
         @Override  
         public int compareTo(DepartureBean otherBean) {  
                 String timeStr1 = time.replace(":","").trim();  
                 String timeStr2 = otherBean.time.replace(":","").trim();  
                   
                 int time1 = 0;  
                 int time2 = 0;  
                   
                 if (timeStr1.length() > 0)  
                         time1 = Integer.parseInt(timeStr1);  
                   
                 if (timeStr2.length() > 0)  
                         time2 = Integer.parseInt(timeStr2);  
                   
                 //work correctly when clock wraps around at midnight  
                 if (Math.abs(time1-time2) < 1200) {  
                         if (time1 > time2)  
                                 return 1;  
                         else  
                                 return -1;  
                 } else {  
                         if (time1 < time2)  
                                 return 1;  
                         else  
                                 return -1;  
   
                 }  
                   
         }  
           
         public String getUpdatedString() {  
                 String updStr;  
                   
                 switch (updated) {  
                 case 1:  
                         updStr = "&lt; 3 min";  
                         break;  
                 case 2:  
                         updStr = "3-10 min";  
                         break;  
                 case 3:  
                         updStr = "&gt; 10 min";  
                         break;  
                 case 4:  
                         updStr = "No info";  
                         break;  
                 default:  
                         updStr = "Unknown:" + updated;                    
                 }  
                   
                 return updStr;  
         }  
           
 }  

Legend:
Removed from v.697  
changed lines
  Added in v.1021

  ViewVC Help
Powered by ViewVC 1.1.20