diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/net/cbaines/suma/BusStop.java | 3 | ||||
-rw-r--r-- | src/net/cbaines/suma/DatabaseConfigUtil.java | 5 | ||||
-rw-r--r-- | src/net/cbaines/suma/DatabaseHelper.java | 37 | ||||
-rw-r--r-- | src/net/cbaines/suma/POI.java | 82 |
4 files changed, 59 insertions, 68 deletions
diff --git a/src/net/cbaines/suma/BusStop.java b/src/net/cbaines/suma/BusStop.java index 750f2d1..85f6d01 100644 --- a/src/net/cbaines/suma/BusStop.java +++ b/src/net/cbaines/suma/BusStop.java @@ -50,8 +50,7 @@ public class BusStop extends POI { String bay; /** - * Used to speed up accessing the relevent uni link routes for a bus stop, - * this is not a uni link stop + * Used to speed up accessing the relevent uni link routes for a bus stop, this is not a uni link stop */ @DatabaseField(canBeNull = false) byte routes; diff --git a/src/net/cbaines/suma/DatabaseConfigUtil.java b/src/net/cbaines/suma/DatabaseConfigUtil.java index 08a54b0..31cc934 100644 --- a/src/net/cbaines/suma/DatabaseConfigUtil.java +++ b/src/net/cbaines/suma/DatabaseConfigUtil.java @@ -22,7 +22,10 @@ package net.cbaines.suma; import com.j256.ormlite.android.apptools.OrmLiteConfigUtil; public class DatabaseConfigUtil extends OrmLiteConfigUtil { + private static final Class<?>[] classes = new Class[] { Building.class, BusStop.class, BusRoute.class, RouteStop.class, + Site.class, Bus.class, POI.class }; + public static void main(String[] args) throws Exception { - writeConfigFile("ormlite_config.txt"); + writeConfigFile("ormlite_config.txt", classes); } } diff --git a/src/net/cbaines/suma/DatabaseHelper.java b/src/net/cbaines/suma/DatabaseHelper.java index 73f4c79..17ef720 100644 --- a/src/net/cbaines/suma/DatabaseHelper.java +++ b/src/net/cbaines/suma/DatabaseHelper.java @@ -55,7 +55,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { private Context context; public DatabaseHelper(Context context) { - super(context, DATABASE_NAME, null, DATABASE_VERSION); + super(context, DATABASE_NAME, null, DATABASE_VERSION, R.raw.ormlite_config); Log.i(TAG, "Database Helper created"); this.context = context; } @@ -89,8 +89,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { } /** - * Returns the Database Access Object (DAO) for our SimpleData class. It - * will create it or just give the cached value. + * Returns the Database Access Object (DAO) for our SimpleData class. It will create it or just give the cached value. */ public Dao<Building, String> getBuildingDao() throws SQLException { if (buildingDao == null) { @@ -100,8 +99,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { } /** - * Returns the Database Access Object (DAO) for our SimpleData class. It - * will create it or just give the cached value. + * Returns the Database Access Object (DAO) for our SimpleData class. It will create it or just give the cached value. */ public Dao<BusStop, String> getBusStopDao() throws SQLException { if (busStopDao == null) { @@ -111,8 +109,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { } /** - * Returns the Database Access Object (DAO) for our SimpleData class. It - * will create it or just give the cached value. + * Returns the Database Access Object (DAO) for our SimpleData class. It will create it or just give the cached value. */ public Dao<BusRoute, Integer> getBusRouteDao() throws SQLException { if (busRouteDao == null) { @@ -122,8 +119,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { } /** - * Returns the Database Access Object (DAO) for our SimpleData class. It - * will create it or just give the cached value. + * Returns the Database Access Object (DAO) for our SimpleData class. It will create it or just give the cached value. */ public Dao<RouteStop, Integer> getRouteStopsDao() throws SQLException { if (routeStopsDao == null) { @@ -133,8 +129,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { } /** - * Returns the Database Access Object (DAO) for our SimpleData class. It - * will create it or just give the cached value. + * Returns the Database Access Object (DAO) for our SimpleData class. It will create it or just give the cached value. */ public Dao<Site, String> getSiteDao() throws SQLException { if (siteDao == null) { @@ -144,8 +139,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { } /** - * Returns the Database Access Object (DAO) for our SimpleData class. It - * will create it or just give the cached value. + * Returns the Database Access Object (DAO) for our SimpleData class. It will create it or just give the cached value. */ public Dao<Bus, Integer> getBusDao() throws SQLException { if (busDao == null) { @@ -155,8 +149,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { } /** - * Check if the database already exist to avoid re-copying the file each - * time you open the application. + * Check if the database already exist to avoid re-copying the file each time you open the application. * * @return true if it exists, false if it doesn't */ @@ -166,8 +159,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { /* * SQLiteDatabase checkDB = null; * - * try { String myPath = DATABASE_PATH + DATABASE_NAME; checkDB = - * SQLiteDatabase.openDatabase(myPath, null, + * try { String myPath = DATABASE_PATH + DATABASE_NAME; checkDB = SQLiteDatabase.openDatabase(myPath, null, * SQLiteDatabase.OPEN_READONLY); } catch (SQLiteException e) { * * // database does't exist yet. @@ -180,8 +172,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { * * } * - * Log.i(TAG, "Finished checking database"); return checkDB != null ? - * true : false; + * Log.i(TAG, "Finished checking database"); return checkDB != null ? true : false; */ File dbFile = new File(DATABASE_PATH + DATABASE_NAME); @@ -189,9 +180,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { } /** - * Copies your database from your local assets-folder to the just created - * empty database in the system folder, from where it can be accessed and - * handled. This is done by transfering bytestream. + * Copies your database from your local assets-folder to the just created empty database in the system folder, from where it + * can be accessed and handled. This is done by transfering bytestream. * */ public void copyDataBase() throws IOException { Log.i(TAG, "Begining copy database"); @@ -228,8 +218,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { } /** - * Creates a empty database on the system and rewrites it with your own - * database. + * Creates a empty database on the system and rewrites it with your own database. * */ public void createDataBase() throws IOException { diff --git a/src/net/cbaines/suma/POI.java b/src/net/cbaines/suma/POI.java index 485845c..c84f90e 100644 --- a/src/net/cbaines/suma/POI.java +++ b/src/net/cbaines/suma/POI.java @@ -25,54 +25,54 @@ import com.j256.ormlite.field.DataType; import com.j256.ormlite.field.DatabaseField; public abstract class POI { - public static final String BUS_STOP = "busstop"; - public static final String BUILDING = "building"; - public static final String WAYPOINT = "waypoint"; - public static final String SITE = "site"; + public static final String BUS_STOP = "busstop"; + public static final String BUILDING = "building"; + public static final String WAYPOINT = "waypoint"; + public static final String SITE = "site"; - public static final String ID_FIELD_NAME = "id"; - public static final String POINT_FIELD_NAME = "point"; + public static final String ID_FIELD_NAME = "id"; + public static final String POINT_FIELD_NAME = "point"; - POI() { - } + POI() { + } - public POI(String id, GeoPoint point) { - this.id = id; - this.point = point; - } + public POI(String id, GeoPoint point) { + this.id = id; + this.point = point; + } - @DatabaseField(dataType = DataType.SERIALIZABLE, canBeNull = false) - public GeoPoint point; + @DatabaseField(dataType = DataType.SERIALIZABLE, canBeNull = false) + public GeoPoint point; - @DatabaseField(id = true) - public String id; + @DatabaseField(id = true) + public String id; - public int distTo = -1; // Used by the comparator to store distances, then later by the gui to display them. + public int distTo = -1; // Used by the comparator to store distances, then later by the gui to display them. - public String type; + public String type; - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((id == null) ? 0 : id.hashCode()); - return result; - } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((id == null) ? 0 : id.hashCode()); + return result; + } - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - POI other = (POI) obj; - if (id == null) { - if (other.id != null) - return false; - } else if (!id.equals(other.id)) - return false; - return true; - } + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + POI other = (POI) obj; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + return true; + } } |