Remove support for unused MLcReq (Hafas).

This commit is contained in:
Andreas Schildbach 2014-07-07 15:09:09 +02:00
parent 64d243cbcb
commit 9bfa490c8e
11 changed files with 12 additions and 107 deletions

View file

@ -89,7 +89,6 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
private String clientType; private String clientType;
private Charset jsonGetStopsEncoding; private Charset jsonGetStopsEncoding;
private Charset jsonNearbyStationsEncoding; private Charset jsonNearbyStationsEncoding;
private final Charset xmlMlcResEncoding;
private boolean dominantPlanStopTime = false; private boolean dominantPlanStopTime = false;
private boolean canDoEquivs = true; private boolean canDoEquivs = true;
private boolean useIso8601 = false; private boolean useIso8601 = false;
@ -147,11 +146,11 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
public AbstractHafasProvider(final String stationBoardEndpoint, final String getStopEndpoint, final String queryEndpoint, final int numProductBits) public AbstractHafasProvider(final String stationBoardEndpoint, final String getStopEndpoint, final String queryEndpoint, final int numProductBits)
{ {
this(stationBoardEndpoint, getStopEndpoint, queryEndpoint, numProductBits, ISO_8859_1, ISO_8859_1); this(stationBoardEndpoint, getStopEndpoint, queryEndpoint, numProductBits, ISO_8859_1);
} }
public AbstractHafasProvider(final String stationBoardEndpoint, final String getStopEndpoint, final String queryEndpoint, public AbstractHafasProvider(final String stationBoardEndpoint, final String getStopEndpoint, final String queryEndpoint,
final int numProductBits, final Charset jsonEncoding, final Charset xmlMlcResEncoding) final int numProductBits, final Charset jsonEncoding)
{ {
this.stationBoardEndpoint = stationBoardEndpoint; this.stationBoardEndpoint = stationBoardEndpoint;
this.getStopEndpoint = getStopEndpoint; this.getStopEndpoint = getStopEndpoint;
@ -159,7 +158,6 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
this.numProductBits = numProductBits; this.numProductBits = numProductBits;
this.jsonGetStopsEncoding = jsonEncoding; this.jsonGetStopsEncoding = jsonEncoding;
this.jsonNearbyStationsEncoding = jsonEncoding; this.jsonNearbyStationsEncoding = jsonEncoding;
this.xmlMlcResEncoding = xmlMlcResEncoding;
} }
protected void setClientType(final String clientType) protected void setClientType(final String clientType)
@ -417,99 +415,6 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
} }
} }
private static final Pattern P_XML_MLC_REQ_ID = Pattern.compile(".*?@L=0*(\\d+)@.*?");
private static final Pattern P_XML_MLC_REQ_LONLAT = Pattern.compile(".*?@X=(-?\\d+)@Y=(-?\\d+)@.*?");
protected final List<Location> xmlMLcReq(final CharSequence constraint) throws IOException
{
final String mlcReq = "<MLcReq><MLc n=\"" + constraint + "?\" t=\"ALLTYPE\" /></MLcReq>";
final String request = wrapReqC(mlcReq, xmlMlcResEncoding);
// ParserUtils.printXml(ParserUtils.scrape(queryEndpoint, request, xmlMlcResEncoding, null));
Reader reader = null;
try
{
reader = new InputStreamReader(ParserUtils.scrapeInputStream(queryEndpoint, request, xmlMlcResEncoding, null, null, 3), xmlMlcResEncoding);
final XmlPullParserFactory factory = XmlPullParserFactory.newInstance(System.getProperty(XmlPullParserFactory.PROPERTY_NAME), null);
final XmlPullParser pp = factory.newPullParser();
pp.setInput(reader);
final List<Location> results = new ArrayList<Location>();
XmlPullUtil.enter(pp, "ResC");
XmlPullUtil.enter(pp, "MLcRes");
while (XmlPullUtil.test(pp, "MLc"))
{
final String t = XmlPullUtil.attr(pp, "t");
final LocationType type;
if ("ST".equals(t))
type = LocationType.STATION;
else if ("POI".equals(t))
type = LocationType.POI;
else if ("ADR".equals(t))
type = LocationType.ADDRESS;
else
throw new IllegalStateException("cannot handle: '" + t + "'");
final String id;
final String i = pp.getAttributeValue(null, "i");
if (i != null)
{
final Matcher iMatcherId = P_XML_MLC_REQ_ID.matcher(i);
if (!iMatcherId.matches())
throw new IllegalStateException("cannot parse id: '" + i + "'");
id = iMatcherId.group(1);
}
else
{
id = null;
}
final String name = XmlPullUtil.attr(pp, "n");
final String[] placeAndName = splitPlaceAndName(name);
final String r = pp.getAttributeValue(null, "r");
final Matcher iMatcherLonLat = P_XML_MLC_REQ_LONLAT.matcher(i != null ? i : r);
final int lat;
final int lon;
if (iMatcherLonLat.matches())
{
lon = Integer.parseInt(iMatcherLonLat.group(1));
lat = Integer.parseInt(iMatcherLonLat.group(2));
}
else
{
lat = 0;
lon = 0;
}
final Location location = new Location(type, id, lat, lon, placeAndName[0], placeAndName[1]);
if (location.hasLocation())
results.add(location);
XmlPullUtil.next(pp);
}
XmlPullUtil.exit(pp, "MLcRes");
XmlPullUtil.exit(pp, "ResC");
return results;
}
catch (final XmlPullParserException x)
{
throw new RuntimeException(x);
}
finally
{
if (reader != null)
reader.close();
}
}
protected StringBuilder xmlQueryDeparturesParameters(final String stationId) protected StringBuilder xmlQueryDeparturesParameters(final String stationId)
{ {
final StringBuilder parameters = new StringBuilder(); final StringBuilder parameters = new StringBuilder();

View file

@ -59,7 +59,7 @@ public class InvgProvider extends AbstractHafasProvider
public InvgProvider() public InvgProvider()
{ {
super(API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", 10, UTF_8, UTF_8); super(API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", 10, UTF_8);
setStyles(STYLES); setStyles(STYLES);
setExtXmlEndpoint(API_BASE + "extxml.exe"); setExtXmlEndpoint(API_BASE + "extxml.exe");

View file

@ -40,7 +40,7 @@ public class JetProvider extends AbstractHafasProvider
public JetProvider() public JetProvider()
{ {
super(API_BASE + "stboard.bin/yn", API_BASE + "ajax-getstop.bin/yn", API_BASE + "query.bin/yn", 4, UTF_8, null); super(API_BASE + "stboard.bin/yn", API_BASE + "ajax-getstop.bin/yn", API_BASE + "query.bin/yn", 4, UTF_8);
} }
public NetworkId id() public NetworkId id()

View file

@ -35,7 +35,7 @@ public class LuProvider extends AbstractHafasProvider
public LuProvider() public LuProvider()
{ {
super(API_BASE + "stboard.exe/fn", API_BASE + "ajax-getstop.exe/fn", API_BASE + "query.exe/fn", 9, UTF_8, UTF_8); super(API_BASE + "stboard.exe/fn", API_BASE + "ajax-getstop.exe/fn", API_BASE + "query.exe/fn", 9, UTF_8);
} }
public NetworkId id() public NetworkId id()

View file

@ -36,7 +36,7 @@ public class NvvProvider extends AbstractHafasProvider
public NvvProvider() public NvvProvider()
{ {
super(API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", 12, UTF_8, null); super(API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", 12, UTF_8);
} }
public NetworkId id() public NetworkId id()

View file

@ -40,7 +40,7 @@ public class PlProvider extends AbstractHafasProvider
public PlProvider() public PlProvider()
{ {
super(API_BASE + "stboard.exe/pn", API_BASE + "ajax-getstop.exe/pn", API_BASE + "query.exe/pn", 7, UTF_8, UTF_8); super(API_BASE + "stboard.exe/pn", API_BASE + "ajax-getstop.exe/pn", API_BASE + "query.exe/pn", 7, UTF_8);
} }
public NetworkId id() public NetworkId id()

View file

@ -36,7 +36,7 @@ public class RtProvider extends AbstractHafasProvider
public RtProvider() public RtProvider()
{ {
super(API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", 10, UTF_8, null); super(API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", 10, UTF_8);
} }
public NetworkId id() public NetworkId id()

View file

@ -42,7 +42,7 @@ public class SeProvider extends AbstractHafasProvider
public SeProvider() public SeProvider()
{ {
super(API_BASE + "stboard.exe/sn", API_BASE + "ajax-getstop.exe/sny", API_BASE + "query.exe/sn", 14, UTF_8, null); super(API_BASE + "stboard.exe/sn", API_BASE + "ajax-getstop.exe/sny", API_BASE + "query.exe/sn", 14, UTF_8);
setClientType("ANDROID"); setClientType("ANDROID");
setCanDoEquivs(false); setCanDoEquivs(false);

View file

@ -51,7 +51,7 @@ public class ShProvider extends AbstractHafasProvider
public ShProvider() public ShProvider()
{ {
super(API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", 10, UTF_8, UTF_8); super(API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", 10, UTF_8);
} }
public NetworkId id() public NetworkId id()

View file

@ -49,7 +49,7 @@ public class VbbProvider extends AbstractHafasProvider
public VbbProvider() public VbbProvider()
{ {
super(API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", 7, UTF_8, UTF_8); super(API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", 7, UTF_8);
} }
public NetworkId id() public NetworkId id()

View file

@ -41,7 +41,7 @@ public class ZvvProvider extends AbstractHafasProvider
public ZvvProvider() public ZvvProvider()
{ {
super(API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", 10, UTF_8, UTF_8); super(API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", 10, UTF_8);
setStyles(STYLES); setStyles(STYLES);
} }