diff --git a/src/de/schildbach/pte/BahnProvider.java b/src/de/schildbach/pte/BahnProvider.java index 1d2e2580..76d28cdd 100644 --- a/src/de/schildbach/pte/BahnProvider.java +++ b/src/de/schildbach/pte/BahnProvider.java @@ -116,7 +116,7 @@ public final class BahnProvider implements NetworkProvider throw new UnsupportedOperationException(); } - public String connectionsQueryUri(final String from, final String via, final String to, final Date date, final boolean dep) + private String connectionsQueryUri(final String from, final String via, final String to, final Date date, final boolean dep) { final DateFormat DATE_FORMAT = new SimpleDateFormat("dd.MM.yy"); final DateFormat TIME_FORMAT = new SimpleDateFormat("HH:mm"); @@ -158,8 +158,10 @@ public final class BahnProvider implements NetworkProvider private static final Pattern P_CHECK_CONNECTIONS_ERROR = Pattern .compile("(?:(zu dicht beieinander|mehrfach vorhanden oder identisch)|(leider konnte zu Ihrer Anfrage keine Verbindung gefunden werden))"); - public CheckConnectionsQueryResult checkConnectionsQuery(final String queryUri) throws IOException + public CheckConnectionsQueryResult checkConnectionsQuery(final String from, final String via, final String to, final Date date, final boolean dep) + throws IOException { + final String queryUri = connectionsQueryUri(from, via, to, date, dep); final CharSequence page = ParserUtils.scrape(queryUri); final Matcher mError = P_CHECK_CONNECTIONS_ERROR.matcher(page); diff --git a/src/de/schildbach/pte/MvvProvider.java b/src/de/schildbach/pte/MvvProvider.java index 50ef3412..461a0ae4 100644 --- a/src/de/schildbach/pte/MvvProvider.java +++ b/src/de/schildbach/pte/MvvProvider.java @@ -84,7 +84,7 @@ public class MvvProvider implements NetworkProvider throw new UnsupportedOperationException(); } - public String connectionsQueryUri(final String from, final String via, final String to, final Date date, final boolean dep) + private String connectionsQueryUri(final String from, final String via, final String to, final Date date, final boolean dep) { final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyyMMdd"); final DateFormat YEAR_FORMAT = new SimpleDateFormat("yyyy"); @@ -174,8 +174,10 @@ public class MvvProvider implements NetworkProvider private static final Pattern P_CHECK_CONNECTIONS_ERROR = Pattern.compile("(?:(xxxzudichtxxx)|(konnte keine Verbindung gefunden werden))", Pattern.CASE_INSENSITIVE); - public CheckConnectionsQueryResult checkConnectionsQuery(final String queryUri) throws IOException + public CheckConnectionsQueryResult checkConnectionsQuery(final String from, final String via, final String to, final Date date, final boolean dep) + throws IOException { + final String queryUri = connectionsQueryUri(from, via, to, date, dep); CharSequence page = ParserUtils.scrape(queryUri); while (page.length() == 0) { diff --git a/src/de/schildbach/pte/NetworkProvider.java b/src/de/schildbach/pte/NetworkProvider.java index b97e6924..fa855122 100644 --- a/src/de/schildbach/pte/NetworkProvider.java +++ b/src/de/schildbach/pte/NetworkProvider.java @@ -72,7 +72,7 @@ public interface NetworkProvider StationLocationResult stationLocation(String stationId) throws IOException; /** - * Construct an Uri for querying connections + * Check if query is well defined, asking for any ambiguousnesses * * @param from * location to route from, mandatory @@ -84,19 +84,10 @@ public interface NetworkProvider * desired date for departing, mandatory * @param dep * date is departure date? {@code true} for departure, {@code false} for arrival - * @return uri for querying connections - */ - String connectionsQueryUri(String from, String via, String to, Date date, boolean dep); - - /** - * Check if query is well defined, asking for any ambiguousnesses - * - * @param queryUri - * uri constructed by {@link NetworkProvider#connectionsQueryUri} * @return result object that can contain alternatives to clear up ambiguousnesses * @throws IOException */ - CheckConnectionsQueryResult checkConnectionsQuery(String queryUri) throws IOException; + CheckConnectionsQueryResult checkConnectionsQuery(String from, String via, String to, Date date, boolean dep) throws IOException; /** * Execute well-defined connections query diff --git a/src/de/schildbach/pte/RmvProvider.java b/src/de/schildbach/pte/RmvProvider.java index cf55bc53..4f50ab2f 100644 --- a/src/de/schildbach/pte/RmvProvider.java +++ b/src/de/schildbach/pte/RmvProvider.java @@ -128,7 +128,7 @@ public class RmvProvider implements NetworkProvider return (double) value / 1000000; } - public String connectionsQueryUri(final String from, final String via, final String to, final Date date, final boolean dep) + private String connectionsQueryUri(final String from, final String via, final String to, final Date date, final boolean dep) { final DateFormat DATE_FORMAT = new SimpleDateFormat("dd.MM.yy"); final DateFormat TIME_FORMAT = new SimpleDateFormat("HH:mm"); @@ -160,8 +160,9 @@ public class RmvProvider implements NetworkProvider private static final Pattern P_CHECK_CONNECTIONS_ERROR = Pattern.compile( "(?:(mehrfach vorhanden oder identisch)|(keine Verbindung gefunden werden))", Pattern.CASE_INSENSITIVE); - public CheckConnectionsQueryResult checkConnectionsQuery(final String queryUri) throws IOException + public CheckConnectionsQueryResult checkConnectionsQuery(final String from, final String via, final String to, final Date date, final boolean dep) throws IOException { + final String queryUri = connectionsQueryUri(from, via, to, date, dep); final CharSequence page = ParserUtils.scrape(queryUri); final Matcher mError = P_CHECK_CONNECTIONS_ERROR.matcher(page); diff --git a/src/de/schildbach/pte/SbbProvider.java b/src/de/schildbach/pte/SbbProvider.java index d2506337..797000bf 100644 --- a/src/de/schildbach/pte/SbbProvider.java +++ b/src/de/schildbach/pte/SbbProvider.java @@ -86,7 +86,7 @@ public class SbbProvider implements NetworkProvider throw new UnsupportedOperationException(); } - public String connectionsQueryUri(final String from, final String via, final String to, final Date date, final boolean dep) + private String connectionsQueryUri(final String from, final String via, final String to, final Date date, final boolean dep) { final DateFormat DATE_FORMAT = new SimpleDateFormat("dd.MM.yy"); final DateFormat TIME_FORMAT = new SimpleDateFormat("HH:mm"); @@ -113,7 +113,8 @@ public class SbbProvider implements NetworkProvider return uri.toString(); } - public CheckConnectionsQueryResult checkConnectionsQuery(final String queryUri) throws IOException + public CheckConnectionsQueryResult checkConnectionsQuery(final String from, final String via, final String to, final Date date, final boolean dep) + throws IOException { throw new UnsupportedOperationException(); } diff --git a/src/de/schildbach/pte/VbbProvider.java b/src/de/schildbach/pte/VbbProvider.java index 43208d70..7a89e5d9 100644 --- a/src/de/schildbach/pte/VbbProvider.java +++ b/src/de/schildbach/pte/VbbProvider.java @@ -105,7 +105,7 @@ public final class VbbProvider implements NetworkProvider public static final String STATION_URL_CONNECTION = "http://mobil.bvg.de/Fahrinfo/bin/query.bin/dox"; - public String connectionsQueryUri(final String from, final String via, final String to, final Date date, final boolean dep) + private String connectionsQueryUri(final String from, final String via, final String to, final Date date, final boolean dep) { final DateFormat DATE_FORMAT = new SimpleDateFormat("dd.MM.yy"); final DateFormat TIME_FORMAT = new SimpleDateFormat("HH:mm"); @@ -135,8 +135,10 @@ public final class VbbProvider implements NetworkProvider private static final Pattern P_CHECK_TO = Pattern.compile("Nach:"); private static final Pattern P_CHECK_CONNECTIONS_ERROR = Pattern.compile("(zu dicht beieinander)|(keine Verbindung gefunden)"); - public CheckConnectionsQueryResult checkConnectionsQuery(final String queryUri) throws IOException + public CheckConnectionsQueryResult checkConnectionsQuery(final String from, final String via, final String to, final Date date, final boolean dep) + throws IOException { + final String queryUri = connectionsQueryUri(from, via, to, date, dep); final CharSequence page = ParserUtils.scrape(queryUri); final Matcher mError = P_CHECK_CONNECTIONS_ERROR.matcher(page);