From 0b40edff29ff3d5ab7ef2f67485bd8c0ff3d22c0 Mon Sep 17 00:00:00 2001 From: Andreas Schildbach Date: Mon, 19 Mar 2012 14:24:04 +0100 Subject: [PATCH] disable earlier connections querying for efa based providers --- .../schildbach/pte/AbstractEfaProvider.java | 26 ++++++++++-- .../pte/dto/SimpleStringContext.java | 41 ------------------- .../pte/live/LinzProviderLiveTest.java | 2 + 3 files changed, 24 insertions(+), 45 deletions(-) delete mode 100644 enabler/src/de/schildbach/pte/dto/SimpleStringContext.java diff --git a/enabler/src/de/schildbach/pte/AbstractEfaProvider.java b/enabler/src/de/schildbach/pte/AbstractEfaProvider.java index 50e0e877..b0cffccc 100644 --- a/enabler/src/de/schildbach/pte/AbstractEfaProvider.java +++ b/enabler/src/de/schildbach/pte/AbstractEfaProvider.java @@ -59,7 +59,6 @@ import de.schildbach.pte.dto.QueryConnectionsContext; import de.schildbach.pte.dto.QueryConnectionsResult; import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.ResultHeader; -import de.schildbach.pte.dto.SimpleStringContext; import de.schildbach.pte.dto.StationDepartures; import de.schildbach.pte.dto.Stop; import de.schildbach.pte.exception.ParserException; @@ -84,6 +83,26 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider private boolean suppressPositions = false; private final XmlPullParserFactory parserFactory; + private static class Context implements QueryConnectionsContext + { + private final String context; + + private Context(final String context) + { + this.context = context; + } + + public boolean canQueryLater() + { + return context != null; + } + + public boolean canQueryEarlier() + { + return false; // TODO enable earlier querying + } + } + public AbstractEfaProvider() { this(null, null); @@ -1670,7 +1689,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider public QueryConnectionsResult queryMoreConnections(final QueryConnectionsContext contextObj, final boolean later) throws IOException { - final SimpleStringContext context = (SimpleStringContext) contextObj; + final Context context = (Context) contextObj; final String commandUri = context.context; final StringBuilder uri = new StringBuilder(commandUri); uri.append("&command=").append(later ? "tripNext" : "tripPrev"); @@ -2082,8 +2101,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider XmlPullUtil.exit(pp, "itdRouteList"); - return new QueryConnectionsResult(header, uri, from, via, to, new SimpleStringContext(commandLink((String) context, requestId)), - connections); + return new QueryConnectionsResult(header, uri, from, via, to, new Context(commandLink((String) context, requestId)), connections); } else { diff --git a/enabler/src/de/schildbach/pte/dto/SimpleStringContext.java b/enabler/src/de/schildbach/pte/dto/SimpleStringContext.java deleted file mode 100644 index 93543873..00000000 --- a/enabler/src/de/schildbach/pte/dto/SimpleStringContext.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2012 the original author or authors. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.schildbach.pte.dto; - -/** - * @author Andreas Schildbach - */ -public class SimpleStringContext implements QueryConnectionsContext -{ - public final String context; - - public SimpleStringContext(final String context) - { - this.context = context; - } - - public boolean canQueryLater() - { - return context != null; - } - - public boolean canQueryEarlier() - { - return context != null; - } -} diff --git a/enabler/test/de/schildbach/pte/live/LinzProviderLiveTest.java b/enabler/test/de/schildbach/pte/live/LinzProviderLiveTest.java index b2996c6e..b57cd122 100644 --- a/enabler/test/de/schildbach/pte/live/LinzProviderLiveTest.java +++ b/enabler/test/de/schildbach/pte/live/LinzProviderLiveTest.java @@ -109,6 +109,8 @@ public class LinzProviderLiveTest extends AbstractProviderLiveTest System.out.println(result); final QueryConnectionsResult laterResult = provider.queryMoreConnections(result.context, true); System.out.println(laterResult); + final QueryConnectionsResult earlierResult = provider.queryMoreConnections(laterResult.context, false); + System.out.println(earlierResult); } @Test