aboutsummaryrefslogtreecommitdiff
path: root/src/net/cbaines/suma/Stop.java
diff options
context:
space:
mode:
authorChristopher Baines <cbaines8@gmail.com>2012-01-25 13:53:22 +0000
committerChristopher Baines <cbaines8@gmail.com>2012-01-25 13:53:22 +0000
commitabcbffd80637a8aea379e6a774aa5747fd5cd0c7 (patch)
treee6912fb2fe412fd36b989af26be1051dbbf1a27e /src/net/cbaines/suma/Stop.java
parentde2979e0f22264ada8326833bfb39746e9bf78cc (diff)
downloadsouthamptonuniversitymap-abcbffd80637a8aea379e6a774aa5747fd5cd0c7.tar
southamptonuniversitymap-abcbffd80637a8aea379e6a774aa5747fd5cd0c7.tar.gz
Lots of changes, need to regenerate the database, and add code to replace old databases with the current one.
Diffstat (limited to 'src/net/cbaines/suma/Stop.java')
-rw-r--r--src/net/cbaines/suma/Stop.java80
1 files changed, 47 insertions, 33 deletions
diff --git a/src/net/cbaines/suma/Stop.java b/src/net/cbaines/suma/Stop.java
index 04eb118..8e2d466 100644
--- a/src/net/cbaines/suma/Stop.java
+++ b/src/net/cbaines/suma/Stop.java
@@ -23,54 +23,64 @@ import java.util.Date;
import android.text.format.DateUtils;
-import com.j256.ormlite.field.DatabaseField;
-import com.j256.ormlite.table.DatabaseTable;
-
-@DatabaseTable(tableName = "stops")
+/**
+ * Stop represents a Bus stopping at a time at a BusStop.
+ *
+ * @author Christopher Baines <cbaines8@gmail.com>
+ *
+ */
public class Stop {
- @DatabaseField(generatedId = true)
- int id;
-
- @DatabaseField(canBeNull = false)
- public String name;
+ public static final String ID_FIELD_NAME = "id";
+ public static final String BUS_FIELD_NAME = "bus";
+ public static final String BUS_STOP_FIELD_NAME = "busStop";
+ public static final String ARIVAL_TIME_FIELD_NAME = "arivalTime";
+ public static final String FETCH_TIME_FIELD_NAME = "timeOfFetch";
- @DatabaseField(canBeNull = false, foreign = true)
- BusStop destStop;
+ /**
+ * A generated id for the bus
+ */
+ int id;
- @DatabaseField(canBeNull = true, foreign = true)
- public Bus bus;
+ /**
+ * The Bus stopping at the stop
+ */
+ Bus bus;
- @DatabaseField(canBeNull = false, foreign = true)
- public BusStop busStop;
+ /**
+ * The busStop that the bus is stopping at
+ */
+ BusStop busStop;
- @DatabaseField(canBeNull = false)
- public Date arivalTime;
+ /**
+ * The time that the bus is estimated to arrive
+ */
+ Date arivalTime;
- @DatabaseField(canBeNull = false)
+ /**
+ * The time this data was fetched from the server
+ */
Date timeOfFetch;
- BusRoute route;
-
- Stop() {
-
- }
-
- public Stop(String name, BusStop busStop, BusStop dest, Bus bus, Date arivalTime, Date timeOfFetch) {
- this.name = name;
+ /**
+ *
+ * @param bus
+ * @param busStop
+ * @param arivalTime
+ * @param timeOfFetch
+ */
+ public Stop(Bus bus, BusStop busStop, Date arivalTime, Date timeOfFetch) {
this.busStop = busStop;
- this.destStop = dest;
this.bus = bus;
this.arivalTime = arivalTime;
this.timeOfFetch = timeOfFetch;
}
- public Stop(String name, BusStop busStop, BusStop dest, Date arivalTime, Date timeOfFetch) {
- this(name, busStop, dest, null, arivalTime, timeOfFetch);
- }
-
+ /**
+ *
+ * @return
+ */
public String getTimeToArival() {
-
if (arivalTime.getTime() - System.currentTimeMillis() <= 60000) {
return "Due";
} else {
@@ -89,12 +99,16 @@ public class Stop {
return result;
}
+ /**
+ * A printout of the stop data for debugging
+ */
@Override
public String toString() {
- return "Stop [id=" + id + ", bus=" + bus + ", busStop=" + busStop + ", arivalTime=" + arivalTime + "]";
+ return "Stop [bus=" + bus + ", busStop=" + busStop + ", arivalTime=" + arivalTime + "]";
}
@Override
+ // TODO: If this is used, the paramaters need to be checked?
public boolean equals(Object obj) {
if (this == obj)
return true;