-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added jsonbale interface, filter non-buses
- Loading branch information
tinypony
committed
Jan 16, 2015
1 parent
3da3c2b
commit aa6f579
Showing
9 changed files
with
309 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<String, BusStop> stops; // time - stop | ||
private int route; | ||
public class Bus implements Jsonable { | ||
|
||
private String serviceID; | ||
private String serviceNbr; | ||
private ArrayList<Stop> stops; //stop | ||
private String route; | ||
private String companyId; | ||
private String trnsmode; | ||
|
||
public Bus() { | ||
this.stops = new HashMap<String, BusStop>(); | ||
this.stops = new ArrayList<Stop>(); | ||
} | ||
|
||
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<Stop> 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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package edu.aalto.emn; | ||
|
||
import org.json.JSONObject; | ||
|
||
public interface Jsonable { | ||
|
||
public JSONObject toJson(); | ||
} |
Oops, something went wrong.