diff --git a/.classpath b/.classpath
index 9fc2de7..534b5e5 100644
--- a/.classpath
+++ b/.classpath
@@ -22,7 +22,7 @@
-
+
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
index abec6ca..69c31cd 100644
--- a/.settings/org.eclipse.jdt.core.prefs
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -1,5 +1,8 @@
eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
-org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/pom.xml b/pom.xml
index c4ab8e6..dc5a93f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,5 +10,26 @@
jcommander
1.30
+
+ org.json
+ json
+ 20140107
+
-
\ No newline at end of file
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.2
+
+ 1.6
+ 1.6
+
+
+
+
+
+
diff --git a/src/main/java/edu/aalto/emn/Bus.java b/src/main/java/edu/aalto/emn/Bus.java
index 3959202..05ee61f 100644
--- a/src/main/java/edu/aalto/emn/Bus.java
+++ b/src/main/java/edu/aalto/emn/Bus.java
@@ -1,22 +1,86 @@
package edu.aalto.emn;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.ArrayList;
-public class Bus {
+import org.json.JSONArray;
+import org.json.JSONObject;
- private Map stops; // time - stop
- private int route;
+public class Bus implements Jsonable {
+
+ private String serviceID;
+ private String serviceNbr;
+ private ArrayList stops; //stop
+ private String route;
+ private String companyId;
+ private String trnsmode;
public Bus() {
- this.stops = new HashMap();
+ this.stops = new ArrayList();
}
- public void setRoute(int route) {
+ public void setRoute(String route) {
this.route = route;
}
+
+ public String getRoute() {
+ return this.route;
+ }
- public void addStop(String time, BusStop stop) {
- this.stops.put(time, stop);
+ public void addStop(Stop stop) {
+ this.stops.add(stop);
+ }
+
+ public ArrayList getStops() {
+ return this.stops;
}
+
+ public String getServiceID() {
+ return serviceID;
+ }
+
+ public void setServiceID(String serviceID) {
+ this.serviceID = serviceID;
+ }
+
+ public String getServiceNbr() {
+ return serviceNbr;
+ }
+
+ public void setServiceNbr(String serviceNbr) {
+ this.serviceNbr = serviceNbr;
+ }
+
+ public void setCompany(String companyId) {
+ this.companyId = companyId;
+ }
+
+ public String getCompany() {
+ return this.companyId;
+ }
+
+ @Override
+ public JSONObject toJson() {
+ JSONObject jBus = new JSONObject();
+ jBus.put("serviceId", this.getServiceID());
+ jBus.put("companyId", this.getCompany());
+ jBus.put("serviceNbr", this.getServiceNbr());
+ jBus.put("route", this.getRoute());
+ JSONArray jstops = new JSONArray();
+
+ for(Stop stop : this.getStops()) {
+ jstops.put(stop.toJson());
+ }
+
+ jBus.put("stops", jstops);
+
+ return jBus;
+ }
+
+ public String getTrnsmode() {
+ return trnsmode;
+ }
+
+ public void setTrnsmode(String trnsmode) {
+ this.trnsmode = trnsmode;
+ }
}
diff --git a/src/main/java/edu/aalto/emn/BusStop.java b/src/main/java/edu/aalto/emn/BusStop.java
index 054bbe0..03c5a25 100644
--- a/src/main/java/edu/aalto/emn/BusStop.java
+++ b/src/main/java/edu/aalto/emn/BusStop.java
@@ -1,9 +1,10 @@
package edu.aalto.emn;
+import org.json.JSONObject;
import org.xml.sax.Attributes;
-public class BusStop {
+public class BusStop{
private String id;
private String name;
private String x;
diff --git a/src/main/java/edu/aalto/emn/DBHandler.java b/src/main/java/edu/aalto/emn/DBHandler.java
index eb57b07..163b4be 100644
--- a/src/main/java/edu/aalto/emn/DBHandler.java
+++ b/src/main/java/edu/aalto/emn/DBHandler.java
@@ -1,6 +1,7 @@
package edu.aalto.emn;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -11,60 +12,107 @@
import org.xml.sax.helpers.DefaultHandler;
public class DBHandler extends DefaultHandler {
- private Map stops;
- private List buses;
- private int route;
+ private Map stops;
+ private ArrayList buses;
- private Stack elementStack = new Stack();
- private Stack