diff --git a/enabler/src/de/schildbach/pte/AbstractNetworkProvider.java b/enabler/src/de/schildbach/pte/AbstractNetworkProvider.java index 2fd12a40..4fc10735 100644 --- a/enabler/src/de/schildbach/pte/AbstractNetworkProvider.java +++ b/enabler/src/de/schildbach/pte/AbstractNetworkProvider.java @@ -20,6 +20,7 @@ package de.schildbach.pte; import java.io.IOException; import java.nio.charset.Charset; +import de.schildbach.pte.dto.Connection; import de.schildbach.pte.dto.GetConnectionDetailsResult; import de.schildbach.pte.dto.Point; import de.schildbach.pte.dto.Style; @@ -44,7 +45,7 @@ public abstract class AbstractNetworkProvider implements NetworkProvider return null; } - public GetConnectionDetailsResult getConnectionDetails(final String connectionUri) throws IOException + public GetConnectionDetailsResult getConnectionDetails(final Connection connection) throws IOException { throw new UnsupportedOperationException(); } diff --git a/enabler/src/de/schildbach/pte/BahnProvider.java b/enabler/src/de/schildbach/pte/BahnProvider.java index 26ad90b4..d28407d8 100644 --- a/enabler/src/de/schildbach/pte/BahnProvider.java +++ b/enabler/src/de/schildbach/pte/BahnProvider.java @@ -426,8 +426,10 @@ public final class BahnProvider extends AbstractHafasProvider .compile("
|Dauer: \\d+:\\d+|Anschlusszug nicht mehr rechtzeitig|Anschlusszug jedoch erreicht werden|nur teilweise dargestellt|Längerer Aufenthalt|äquivalentem Bahnhof|Bahnhof wird mehrfach durchfahren|Aktuelle Informationen zu der Verbindung"); @Override - public GetConnectionDetailsResult getConnectionDetails(final String uri) throws IOException + public GetConnectionDetailsResult getConnectionDetails(final Connection connection) throws IOException { + final String uri = connection.link; + final CharSequence page = ParserUtils.scrape(uri); final Matcher mError = P_CONNECTION_DETAILS_ERROR.matcher(page); diff --git a/enabler/src/de/schildbach/pte/NetworkProvider.java b/enabler/src/de/schildbach/pte/NetworkProvider.java index 3cf2e145..58f746eb 100644 --- a/enabler/src/de/schildbach/pte/NetworkProvider.java +++ b/enabler/src/de/schildbach/pte/NetworkProvider.java @@ -21,6 +21,7 @@ import java.io.IOException; import java.util.Date; import java.util.List; +import de.schildbach.pte.dto.Connection; import de.schildbach.pte.dto.GetConnectionDetailsResult; import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.NearbyStationsResult; @@ -145,12 +146,12 @@ public interface NetworkProvider /** * Get details about a connection * - * @param connectionUri - * uri returned via {@link NetworkProvider#queryConnections} + * @param connection + * (non-detailed) connection returned via {@link NetworkProvider#queryConnections} * @return result object containing the details of the connection * @throws IOException */ - GetConnectionDetailsResult getConnectionDetails(String connectionUri) throws IOException; + GetConnectionDetailsResult getConnectionDetails(Connection connection) throws IOException; /** * Get style of line diff --git a/enabler/test/de/schildbach/pte/live/BahnProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/BahnProviderLiveTest.java index 446315e7..2ca621fc 100644 --- a/enabler/test/de/schildbach/pte/live/BahnProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/BahnProviderLiveTest.java @@ -90,7 +90,7 @@ public class BahnProviderLiveTest extends AbstractProviderLiveTest System.out.println(result); final QueryConnectionsResult laterResult = queryMoreConnections(result.context, true); for (final Connection connection : result.connections) - provider.getConnectionDetails(connection.link); + provider.getConnectionDetails(connection); System.out.println(laterResult); final QueryConnectionsResult later2Result = queryMoreConnections(laterResult.context, true); System.out.println(later2Result); @@ -109,7 +109,7 @@ public class BahnProviderLiveTest extends AbstractProviderLiveTest System.out.println(result); final QueryConnectionsResult laterResult = queryMoreConnections(result.context, true); for (final Connection connection : result.connections) - provider.getConnectionDetails(connection.link); + provider.getConnectionDetails(connection); System.out.println(laterResult); } @@ -123,7 +123,7 @@ public class BahnProviderLiveTest extends AbstractProviderLiveTest final QueryConnectionsResult laterResult = queryMoreConnections(result.context, true); for (final Connection connection : result.connections) - provider.getConnectionDetails(connection.link); + provider.getConnectionDetails(connection); System.out.println(laterResult); } }