Changeset View
Changeset View
Standalone View
Standalone View
src/it/reyboz/bustorino/backend/FiveTStopsFetcher.java
Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | public class FiveTStopsFetcher implements StopsFinderByName { | ||||
public List<Stop> FindByName(String name, AtomicReference<Result> res) { | public List<Stop> FindByName(String name, AtomicReference<Result> res) { | ||||
// API apparently limited to 20 results | // API apparently limited to 20 results | ||||
ArrayList<Stop> busStops = new ArrayList<>(20); | ArrayList<Stop> busStops = new ArrayList<>(20); | ||||
String stopID; | String stopID; | ||||
String stopName; | String stopName; | ||||
String stopLocation; | String stopLocation; | ||||
//Stop busStop; | //Stop busStop; | ||||
if(name.length() < 3) { | if(name.length() < 2) { //some stops are shorter than 3 chars.. "PO" is an example | ||||
res.set(Result.QUERY_TOO_SHORT); | res.set(Result.QUERY_TOO_SHORT); | ||||
return busStops; | return busStops; | ||||
} | } | ||||
String responseInDOMFormatBecause5THaveAbsolutelyNoIdeaWhatJSONWas; | String responseInDOMFormatBecause5THaveAbsolutelyNoIdeaWhatJSONWas; | ||||
URL u; | URL u; | ||||
try { | try { | ||||
u = new URL("http://www.5t.torino.it/5t/trasporto/stop-lookup.jsp?action=search&stopShortName=" + URLEncoder.encode(name, "utf-8")); | u = new URL("http://www.5t.torino.it/5t/trasporto/stop-lookup.jsp?action=search&stopShortName=" + URLEncoder.encode(name, "utf-8")); | ||||
▲ Show 20 Lines • Show All 61 Lines • Show Last 20 Lines |
Public contents are in Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) or GNU Free Documentation License (at your option) unless otherwise noted. · Contact / Register