Hafas: Set up default API endpoints in the constructor.

This commit is contained in:
Andreas Schildbach 2015-09-04 17:07:29 +02:00
parent 10d04bcb39
commit 8b93e6135a
27 changed files with 58 additions and 42 deletions

View file

@ -92,9 +92,10 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
private static final String REQC_PROD = "hafas";
protected static final int DEFAULT_MAX_DEPARTURES = 100;
protected final String stationBoardEndpoint;
protected final String getStopEndpoint;
protected final String queryEndpoint;
protected String stationBoardEndpoint;
protected String getStopEndpoint;
protected String queryEndpoint;
private @Nullable String extXmlEndpoint = null;
private Product[] productsMap;
private @Nullable String accessId = null;
private @Nullable String clientType = "ANDROID";
@ -103,7 +104,6 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
private Charset jsonNearbyLocationsEncoding = Charsets.ISO_8859_1;
private boolean dominantPlanStopTime = false;
private boolean useIso8601 = false;
private @Nullable String extXmlEndpoint = null;
private boolean stationBoardHasStationTable = true;
private boolean stationBoardHasLocation = false;
private boolean stationBoardCanDoEquivs = true;
@ -162,17 +162,36 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
}
}
public AbstractHafasProvider(final NetworkId network, final String stationBoardEndpoint, final String getStopEndpoint, final String queryEndpoint,
final Product[] productsMap)
public AbstractHafasProvider(final NetworkId network, final String apiBase, final String apiLanguage, final Product[] productsMap)
{
super(network);
this.stationBoardEndpoint = stationBoardEndpoint;
this.getStopEndpoint = getStopEndpoint;
this.queryEndpoint = queryEndpoint;
this.stationBoardEndpoint = apiBase + "stboard.exe/" + apiLanguage;
this.getStopEndpoint = apiBase + "ajax-getstop.exe/" + apiLanguage;
this.queryEndpoint = apiBase + "query.exe/" + apiLanguage;
this.productsMap = productsMap;
}
protected void setStationBoardEndpoint(final String stationBoardEndpoint)
{
this.stationBoardEndpoint = stationBoardEndpoint;
}
protected void setGetStopEndpoint(final String getStopEndpoint)
{
this.getStopEndpoint = getStopEndpoint;
}
protected void setQueryEndpoint(final String queryEndpoint)
{
this.queryEndpoint = queryEndpoint;
}
protected void setExtXmlEndpoint(final String extXmlEndpoint)
{
this.extXmlEndpoint = extXmlEndpoint;
}
protected void setClientType(final String clientType)
{
this.clientType = clientType;
@ -208,11 +227,6 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
this.useIso8601 = useIso8601;
}
protected void setExtXmlEndpoint(final String extXmlEndpoint)
{
this.extXmlEndpoint = extXmlEndpoint;
}
protected void setStationBoardHasStationTable(final boolean stationBoardHasStationTable)
{
this.stationBoardHasStationTable = stationBoardHasStationTable;