mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-07 06:08:52 +00:00
Replace anonymous nested classes with lambdas.
This commit is contained in:
parent
dd96d33afa
commit
0c10251957
4 changed files with 1495 additions and 1564 deletions
|
@ -381,9 +381,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
|
||||||
appendStopfinderRequestParameters(url, constraint, "XML", types, maxLocations);
|
appendStopfinderRequestParameters(url, constraint, "XML", types, maxLocations);
|
||||||
final AtomicReference<SuggestLocationsResult> result = new AtomicReference<>();
|
final AtomicReference<SuggestLocationsResult> result = new AtomicReference<>();
|
||||||
|
|
||||||
final HttpClient.Callback callback = new HttpClient.Callback() {
|
final HttpClient.Callback callback = (bodyPeek, body) -> {
|
||||||
@Override
|
|
||||||
public void onSuccessful(final CharSequence bodyPeek, final ResponseBody body) throws IOException {
|
|
||||||
try {
|
try {
|
||||||
final XmlPullParser pp = parserFactory.newPullParser();
|
final XmlPullParser pp = parserFactory.newPullParser();
|
||||||
pp.setInput(body.charStream());
|
pp.setInput(body.charStream());
|
||||||
|
@ -443,7 +441,6 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
|
||||||
} catch (final XmlPullParserException | ParserException x) {
|
} catch (final XmlPullParserException | ParserException x) {
|
||||||
throw new ParserException("cannot parse xml: " + bodyPeek, x);
|
throw new ParserException("cannot parse xml: " + bodyPeek, x);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
httpClient.getInputStream(callback, url.build(), httpReferer);
|
httpClient.getInputStream(callback, url.build(), httpReferer);
|
||||||
|
@ -478,9 +475,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
|
||||||
appendCoordRequestParameters(url, types, coord, maxDistance, maxStations);
|
appendCoordRequestParameters(url, types, coord, maxDistance, maxStations);
|
||||||
final AtomicReference<NearbyLocationsResult> result = new AtomicReference<>();
|
final AtomicReference<NearbyLocationsResult> result = new AtomicReference<>();
|
||||||
|
|
||||||
final HttpClient.Callback callback = new HttpClient.Callback() {
|
final HttpClient.Callback callback = (bodyPeek, body) -> {
|
||||||
@Override
|
|
||||||
public void onSuccessful(final CharSequence bodyPeek, final ResponseBody body) throws IOException {
|
|
||||||
try {
|
try {
|
||||||
final XmlPullParser pp = parserFactory.newPullParser();
|
final XmlPullParser pp = parserFactory.newPullParser();
|
||||||
pp.setInput(body.charStream());
|
pp.setInput(body.charStream());
|
||||||
|
@ -517,12 +512,12 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
|
||||||
|
|
||||||
// FIXME this is always only one coordinate
|
// FIXME this is always only one coordinate
|
||||||
final List<Point> path = processItdPathCoordinates(pp);
|
final List<Point> path = processItdPathCoordinates(pp);
|
||||||
final Point coord = path != null ? path.get(0) : null;
|
final Point coord1 = path != null ? path.get(0) : null;
|
||||||
|
|
||||||
XmlPullUtil.skipExit(pp, "coordInfoItem");
|
XmlPullUtil.skipExit(pp, "coordInfoItem");
|
||||||
|
|
||||||
if (name != null)
|
if (name != null)
|
||||||
locations.add(new Location(locationType, id, coord, place, name));
|
locations.add(new Location(locationType, id, coord1, place, name));
|
||||||
}
|
}
|
||||||
|
|
||||||
XmlPullUtil.skipExit(pp, "coordInfoItemList");
|
XmlPullUtil.skipExit(pp, "coordInfoItemList");
|
||||||
|
@ -532,7 +527,6 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
|
||||||
} catch (final XmlPullParserException | ParserException x) {
|
} catch (final XmlPullParserException | ParserException x) {
|
||||||
throw new ParserException("cannot parse xml: " + bodyPeek, x);
|
throw new ParserException("cannot parse xml: " + bodyPeek, x);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
httpClient.getInputStream(callback, url.build(), httpReferer);
|
httpClient.getInputStream(callback, url.build(), httpReferer);
|
||||||
|
@ -546,9 +540,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
|
||||||
appendCoordRequestParameters(url, types, coord, maxDistance, maxStations);
|
appendCoordRequestParameters(url, types, coord, maxDistance, maxStations);
|
||||||
final AtomicReference<NearbyLocationsResult> result = new AtomicReference<>();
|
final AtomicReference<NearbyLocationsResult> result = new AtomicReference<>();
|
||||||
|
|
||||||
final HttpClient.Callback callback = new HttpClient.Callback() {
|
final HttpClient.Callback callback = (bodyPeek, body) -> {
|
||||||
@Override
|
|
||||||
public void onSuccessful(final CharSequence bodyPeek, final ResponseBody body) throws IOException {
|
|
||||||
try {
|
try {
|
||||||
final XmlPullParser pp = parserFactory.newPullParser();
|
final XmlPullParser pp = parserFactory.newPullParser();
|
||||||
pp.setInput(body.charStream());
|
pp.setInput(body.charStream());
|
||||||
|
@ -582,13 +574,13 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
|
||||||
XmlPullUtil.valueTag(pp, "ds");
|
XmlPullUtil.valueTag(pp, "ds");
|
||||||
final String stateless = XmlPullUtil.valueTag(pp, "stateless");
|
final String stateless = XmlPullUtil.valueTag(pp, "stateless");
|
||||||
final String locationId = locationType == LocationType.STATION ? id : stateless;
|
final String locationId = locationType == LocationType.STATION ? id : stateless;
|
||||||
final Point coord = parseCoord(XmlPullUtil.valueTag(pp, "c"));
|
final Point coord1 = parseCoord(XmlPullUtil.valueTag(pp, "c"));
|
||||||
|
|
||||||
final Location location;
|
final Location location;
|
||||||
if (name != null)
|
if (name != null)
|
||||||
location = new Location(locationType, locationId, coord, place, name);
|
location = new Location(locationType, locationId, coord1, place, name);
|
||||||
else
|
else
|
||||||
location = new Location(locationType, locationId, coord, null, place);
|
location = new Location(locationType, locationId, coord1, null, place);
|
||||||
stations.add(location);
|
stations.add(location);
|
||||||
|
|
||||||
XmlPullUtil.skipExit(pp, "pi");
|
XmlPullUtil.skipExit(pp, "pi");
|
||||||
|
@ -603,7 +595,6 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
|
||||||
} catch (final XmlPullParserException | ParserException x) {
|
} catch (final XmlPullParserException | ParserException x) {
|
||||||
throw new ParserException("cannot parse xml: " + bodyPeek, x);
|
throw new ParserException("cannot parse xml: " + bodyPeek, x);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
httpClient.getInputStream(callback, url.build(), httpReferer);
|
httpClient.getInputStream(callback, url.build(), httpReferer);
|
||||||
|
@ -813,9 +804,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
|
||||||
url.addEncodedQueryParameter("mode", "direct");
|
url.addEncodedQueryParameter("mode", "direct");
|
||||||
final AtomicReference<NearbyLocationsResult> result = new AtomicReference<>();
|
final AtomicReference<NearbyLocationsResult> result = new AtomicReference<>();
|
||||||
|
|
||||||
final HttpClient.Callback callback = new HttpClient.Callback() {
|
final HttpClient.Callback callback = (bodyPeek, body) -> {
|
||||||
@Override
|
|
||||||
public void onSuccessful(final CharSequence bodyPeek, final ResponseBody body) throws IOException {
|
|
||||||
try {
|
try {
|
||||||
final XmlPullParser pp = parserFactory.newPullParser();
|
final XmlPullParser pp = parserFactory.newPullParser();
|
||||||
pp.setInput(body.charStream());
|
pp.setInput(body.charStream());
|
||||||
|
@ -826,18 +815,13 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
|
||||||
final AtomicReference<Location> ownStation = new AtomicReference<>();
|
final AtomicReference<Location> ownStation = new AtomicReference<>();
|
||||||
final List<Location> stations = new ArrayList<>();
|
final List<Location> stations = new ArrayList<>();
|
||||||
|
|
||||||
final String nameState = processItdOdv(pp, "dm", new ProcessItdOdvCallback() {
|
final String nameState = processItdOdv(pp, "dm", (nameState1, location, matchQuality) -> {
|
||||||
@Override
|
|
||||||
public void location(final String nameState, final Location location, final int matchQuality) {
|
|
||||||
if (location.type == LocationType.STATION) {
|
if (location.type == LocationType.STATION) {
|
||||||
if ("identified".equals(nameState))
|
if ("identified".equals(nameState1)) ownStation.set(location);
|
||||||
ownStation.set(location);
|
else if ("assigned".equals(nameState1)) stations.add(location);
|
||||||
else if ("assigned".equals(nameState))
|
|
||||||
stations.add(location);
|
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalStateException("cannot handle: " + location.type);
|
throw new IllegalStateException("cannot handle: " + location.type);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if ("notidentified".equals(nameState)) {
|
if ("notidentified".equals(nameState)) {
|
||||||
|
@ -855,7 +839,6 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
|
||||||
} catch (final XmlPullParserException | ParserException x) {
|
} catch (final XmlPullParserException | ParserException x) {
|
||||||
throw new ParserException("cannot parse xml: " + bodyPeek, x);
|
throw new ParserException("cannot parse xml: " + bodyPeek, x);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
httpClient.getInputStream(callback, url.build(), httpReferer);
|
httpClient.getInputStream(callback, url.build(), httpReferer);
|
||||||
|
@ -1433,9 +1416,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
|
||||||
appendDepartureMonitorRequestParameters(url, stationId, time, maxDepartures, equivs);
|
appendDepartureMonitorRequestParameters(url, stationId, time, maxDepartures, equivs);
|
||||||
final AtomicReference<QueryDeparturesResult> result = new AtomicReference<>();
|
final AtomicReference<QueryDeparturesResult> result = new AtomicReference<>();
|
||||||
|
|
||||||
final HttpClient.Callback callback = new HttpClient.Callback() {
|
final HttpClient.Callback callback = (bodyPeek, body) -> {
|
||||||
@Override
|
|
||||||
public void onSuccessful(final CharSequence bodyPeek, final ResponseBody body) throws IOException {
|
|
||||||
try {
|
try {
|
||||||
final XmlPullParser pp = parserFactory.newPullParser();
|
final XmlPullParser pp = parserFactory.newPullParser();
|
||||||
pp.setInput(body.charStream());
|
pp.setInput(body.charStream());
|
||||||
|
@ -1446,14 +1427,10 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
|
||||||
XmlPullUtil.enter(pp, "itdDepartureMonitorRequest");
|
XmlPullUtil.enter(pp, "itdDepartureMonitorRequest");
|
||||||
XmlPullUtil.optSkipMultiple(pp, "itdMessage");
|
XmlPullUtil.optSkipMultiple(pp, "itdMessage");
|
||||||
|
|
||||||
final String nameState = processItdOdv(pp, "dm", new ProcessItdOdvCallback() {
|
final String nameState = processItdOdv(pp, "dm", (nameState1, location, matchQuality) -> {
|
||||||
@Override
|
|
||||||
public void location(final String nameState, final Location location, final int matchQuality) {
|
|
||||||
if (location.type == LocationType.STATION)
|
if (location.type == LocationType.STATION)
|
||||||
if (findStationDepartures(r.stationDepartures, location.id) == null)
|
if (findStationDepartures(r.stationDepartures, location.id) == null)
|
||||||
r.stationDepartures.add(new StationDepartures(location, new LinkedList<Departure>(),
|
r.stationDepartures.add(new StationDepartures(location, new LinkedList<Departure>(), new LinkedList<LineDestination>()));
|
||||||
new LinkedList<LineDestination>()));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!"identified".equals(nameState)) {
|
if (!"identified".equals(nameState)) {
|
||||||
|
@ -1567,7 +1544,6 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
|
||||||
} catch (final XmlPullParserException | ParserException x) {
|
} catch (final XmlPullParserException | ParserException x) {
|
||||||
throw new ParserException("cannot parse xml: " + bodyPeek, x);
|
throw new ParserException("cannot parse xml: " + bodyPeek, x);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
httpClient.getInputStream(callback, url.build(), httpReferer);
|
httpClient.getInputStream(callback, url.build(), httpReferer);
|
||||||
|
@ -1581,9 +1557,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
|
||||||
appendDepartureMonitorRequestParameters(url, stationId, time, maxDepartures, equivs);
|
appendDepartureMonitorRequestParameters(url, stationId, time, maxDepartures, equivs);
|
||||||
final AtomicReference<QueryDeparturesResult> result = new AtomicReference<>();
|
final AtomicReference<QueryDeparturesResult> result = new AtomicReference<>();
|
||||||
|
|
||||||
final HttpClient.Callback callback = new HttpClient.Callback() {
|
final HttpClient.Callback callback = (bodyPeek, body) -> {
|
||||||
@Override
|
|
||||||
public void onSuccessful(final CharSequence bodyPeek, final ResponseBody body) throws IOException {
|
|
||||||
try {
|
try {
|
||||||
final XmlPullParser pp = parserFactory.newPullParser();
|
final XmlPullParser pp = parserFactory.newPullParser();
|
||||||
pp.setInput(body.charStream());
|
pp.setInput(body.charStream());
|
||||||
|
@ -1660,7 +1634,6 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
|
||||||
} catch (final XmlPullParserException | ParserException x) {
|
} catch (final XmlPullParserException | ParserException x) {
|
||||||
throw new ParserException("cannot parse xml: " + bodyPeek, x);
|
throw new ParserException("cannot parse xml: " + bodyPeek, x);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
httpClient.getInputStream(callback, url.build(), httpReferer);
|
httpClient.getInputStream(callback, url.build(), httpReferer);
|
||||||
|
@ -2040,9 +2013,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
|
||||||
appendTripRequestParameters(url, from, via, to, date, dep, options);
|
appendTripRequestParameters(url, from, via, to, date, dep, options);
|
||||||
final AtomicReference<QueryTripsResult> result = new AtomicReference<>();
|
final AtomicReference<QueryTripsResult> result = new AtomicReference<>();
|
||||||
|
|
||||||
final HttpClient.Callback callback = new HttpClient.Callback() {
|
final HttpClient.Callback callback = (bodyPeek, body) -> {
|
||||||
@Override
|
|
||||||
public void onSuccessful(final CharSequence bodyPeek, final ResponseBody body) throws IOException {
|
|
||||||
try {
|
try {
|
||||||
result.set(queryTrips(url.build(), body.charStream()));
|
result.set(queryTrips(url.build(), body.charStream()));
|
||||||
} catch (final XmlPullParserException | ParserException x) {
|
} catch (final XmlPullParserException | ParserException x) {
|
||||||
|
@ -2050,7 +2021,6 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
|
||||||
} catch (final RuntimeException x) {
|
} catch (final RuntimeException x) {
|
||||||
throw new RuntimeException("uncategorized problem while processing " + url, x);
|
throw new RuntimeException("uncategorized problem while processing " + url, x);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
httpClient.getInputStream(callback, url.build(), httpRefererTrip);
|
httpClient.getInputStream(callback, url.build(), httpRefererTrip);
|
||||||
|
@ -2064,9 +2034,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
|
||||||
appendTripRequestParameters(url, from, via, to, date, dep, options);
|
appendTripRequestParameters(url, from, via, to, date, dep, options);
|
||||||
final AtomicReference<QueryTripsResult> result = new AtomicReference<>();
|
final AtomicReference<QueryTripsResult> result = new AtomicReference<>();
|
||||||
|
|
||||||
final HttpClient.Callback callback = new HttpClient.Callback() {
|
final HttpClient.Callback callback = (bodyPeek, body) -> {
|
||||||
@Override
|
|
||||||
public void onSuccessful(final CharSequence bodyPeek, final ResponseBody body) throws IOException {
|
|
||||||
try {
|
try {
|
||||||
result.set(queryTripsMobile(url.build(), from, via, to, body.charStream()));
|
result.set(queryTripsMobile(url.build(), from, via, to, body.charStream()));
|
||||||
} catch (final XmlPullParserException | ParserException x) {
|
} catch (final XmlPullParserException | ParserException x) {
|
||||||
|
@ -2074,7 +2042,6 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
|
||||||
} catch (final RuntimeException x) {
|
} catch (final RuntimeException x) {
|
||||||
throw new RuntimeException("uncategorized problem while processing " + url, x);
|
throw new RuntimeException("uncategorized problem while processing " + url, x);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
httpClient.getInputStream(callback, url.build(), httpRefererTrip);
|
httpClient.getInputStream(callback, url.build(), httpRefererTrip);
|
||||||
|
@ -2091,9 +2058,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
|
||||||
url.addEncodedQueryParameter("command", later ? "tripNext" : "tripPrev");
|
url.addEncodedQueryParameter("command", later ? "tripNext" : "tripPrev");
|
||||||
final AtomicReference<QueryTripsResult> result = new AtomicReference<>();
|
final AtomicReference<QueryTripsResult> result = new AtomicReference<>();
|
||||||
|
|
||||||
final HttpClient.Callback callback = new HttpClient.Callback() {
|
final HttpClient.Callback callback = (bodyPeek, body) -> {
|
||||||
@Override
|
|
||||||
public void onSuccessful(final CharSequence bodyPeek, final ResponseBody body) throws IOException {
|
|
||||||
try {
|
try {
|
||||||
result.set(queryTrips(url.build(), body.charStream()));
|
result.set(queryTrips(url.build(), body.charStream()));
|
||||||
} catch (final XmlPullParserException | ParserException x) {
|
} catch (final XmlPullParserException | ParserException x) {
|
||||||
|
@ -2101,7 +2066,6 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
|
||||||
} catch (final RuntimeException x) {
|
} catch (final RuntimeException x) {
|
||||||
throw new RuntimeException("uncategorized problem while processing " + url, x);
|
throw new RuntimeException("uncategorized problem while processing " + url, x);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
httpClient.getInputStream(callback, url.build(), httpRefererTrip);
|
httpClient.getInputStream(callback, url.build(), httpRefererTrip);
|
||||||
|
@ -2118,9 +2082,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
|
||||||
url.addEncodedQueryParameter("command", later ? "tripNext" : "tripPrev");
|
url.addEncodedQueryParameter("command", later ? "tripNext" : "tripPrev");
|
||||||
final AtomicReference<QueryTripsResult> result = new AtomicReference<>();
|
final AtomicReference<QueryTripsResult> result = new AtomicReference<>();
|
||||||
|
|
||||||
final HttpClient.Callback callback = new HttpClient.Callback() {
|
final HttpClient.Callback callback = (bodyPeek, body) -> {
|
||||||
@Override
|
|
||||||
public void onSuccessful(final CharSequence bodyPeek, final ResponseBody body) throws IOException {
|
|
||||||
try {
|
try {
|
||||||
result.set(queryTripsMobile(url.build(), null, null, null, body.charStream()));
|
result.set(queryTripsMobile(url.build(), null, null, null, body.charStream()));
|
||||||
} catch (final XmlPullParserException | ParserException x) {
|
} catch (final XmlPullParserException | ParserException x) {
|
||||||
|
@ -2128,7 +2090,6 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
|
||||||
} catch (final RuntimeException x) {
|
} catch (final RuntimeException x) {
|
||||||
throw new RuntimeException("uncategorized problem while processing " + url, x);
|
throw new RuntimeException("uncategorized problem while processing " + url, x);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
httpClient.getInputStream(callback, url.build(), httpRefererTrip);
|
httpClient.getInputStream(callback, url.build(), httpRefererTrip);
|
||||||
|
@ -2163,12 +2124,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
|
||||||
final String usage = XmlPullUtil.attr(pp, "usage");
|
final String usage = XmlPullUtil.attr(pp, "usage");
|
||||||
|
|
||||||
final List<Location> locations = new ArrayList<>();
|
final List<Location> locations = new ArrayList<>();
|
||||||
final String nameState = processItdOdv(pp, usage, new ProcessItdOdvCallback() {
|
final String nameState = processItdOdv(pp, usage, (nameState1, location, matchQuality) -> locations.add(location));
|
||||||
@Override
|
|
||||||
public void location(final String nameState, final Location location, final int matchQuality) {
|
|
||||||
locations.add(location);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if ("list".equals(nameState)) {
|
if ("list".equals(nameState)) {
|
||||||
if ("origin".equals(usage))
|
if ("origin".equals(usage))
|
||||||
|
|
|
@ -440,10 +440,7 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
|
||||||
final String normalizedStationId = normalizeStationId(stationId);
|
final String normalizedStationId = normalizeStationId(stationId);
|
||||||
final AtomicReference<QueryDeparturesResult> result = new AtomicReference<>();
|
final AtomicReference<QueryDeparturesResult> result = new AtomicReference<>();
|
||||||
|
|
||||||
httpClient.getInputStream(new HttpClient.Callback() {
|
httpClient.getInputStream((bodyPeek, body) -> {
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSuccessful(final CharSequence bodyPeek, final ResponseBody body) throws IOException {
|
|
||||||
StringReplaceReader reader = null;
|
StringReplaceReader reader = null;
|
||||||
String firstChars = null;
|
String firstChars = null;
|
||||||
|
|
||||||
|
@ -594,14 +591,14 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
|
||||||
final Set<Attr> attrs = prodLine.attrs;
|
final Set<Attr> attrs = prodLine.attrs;
|
||||||
if (attrs != null)
|
if (attrs != null)
|
||||||
line = newLine(administration, product, prodLine.label, null,
|
line = newLine(administration, product, prodLine.label, null,
|
||||||
attrs.toArray(new Line.Attr[0]));
|
attrs.toArray(new Attr[0]));
|
||||||
else
|
else
|
||||||
line = newLine(administration, product, prodLine.label, null);
|
line = newLine(administration, product, prodLine.label, null);
|
||||||
} else {
|
} else {
|
||||||
final Set<Attr> attrs = prodLine.attrs;
|
final Set<Attr> attrs = prodLine.attrs;
|
||||||
if (attrs != null)
|
if (attrs != null)
|
||||||
line = newLine(administration, prodLine.product, prodLine.label, null,
|
line = newLine(administration, prodLine.product, prodLine.label, null,
|
||||||
attrs.toArray(new Line.Attr[0]));
|
attrs.toArray(new Attr[0]));
|
||||||
else
|
else
|
||||||
line = newLine(administration, prodLine.product, prodLine.label, null);
|
line = newLine(administration, prodLine.product, prodLine.label, null);
|
||||||
}
|
}
|
||||||
|
@ -663,7 +660,6 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
|
||||||
} catch (final XmlPullParserException x) {
|
} catch (final XmlPullParserException x) {
|
||||||
throw new ParserException("cannot parse xml: " + firstChars, x);
|
throw new ParserException("cannot parse xml: " + firstChars, x);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}, url);
|
}, url);
|
||||||
|
|
||||||
return result.get();
|
return result.get();
|
||||||
|
@ -794,9 +790,7 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
|
||||||
final HttpUrl endpoint = extXmlEndpoint != null ? extXmlEndpoint
|
final HttpUrl endpoint = extXmlEndpoint != null ? extXmlEndpoint
|
||||||
: queryEndpoint.newBuilder().addPathSegment(apiLanguage).build();
|
: queryEndpoint.newBuilder().addPathSegment(apiLanguage).build();
|
||||||
final AtomicReference<QueryTripsResult> result = new AtomicReference<>();
|
final AtomicReference<QueryTripsResult> result = new AtomicReference<>();
|
||||||
httpClient.getInputStream(new HttpClient.Callback() {
|
httpClient.getInputStream((bodyPeek, body) -> {
|
||||||
@Override
|
|
||||||
public void onSuccessful(final CharSequence bodyPeek, final ResponseBody body) throws IOException {
|
|
||||||
try {
|
try {
|
||||||
final XmlPullParserFactory factory = XmlPullParserFactory
|
final XmlPullParserFactory factory = XmlPullParserFactory
|
||||||
.newInstance(System.getProperty(XmlPullParserFactory.PROPERTY_NAME), null);
|
.newInstance(System.getProperty(XmlPullParserFactory.PROPERTY_NAME), null);
|
||||||
|
@ -1184,7 +1178,6 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
|
||||||
} catch (final XmlPullParserException x) {
|
} catch (final XmlPullParserException x) {
|
||||||
throw new ParserException("cannot parse xml: " + bodyPeek, x);
|
throw new ParserException("cannot parse xml: " + bodyPeek, x);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}, endpoint, request, "application/xml", null);
|
}, endpoint, request, "application/xml", null);
|
||||||
|
|
||||||
return result.get();
|
return result.get();
|
||||||
|
@ -1432,9 +1425,7 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
|
||||||
|
|
||||||
final AtomicReference<QueryTripsResult> result = new AtomicReference<>();
|
final AtomicReference<QueryTripsResult> result = new AtomicReference<>();
|
||||||
|
|
||||||
httpClient.getInputStream(new HttpClient.Callback() {
|
httpClient.getInputStream((HttpClient.Callback) (bodyPeek, body) -> {
|
||||||
@Override
|
|
||||||
public void onSuccessful(final CharSequence bodyPeek, final ResponseBody body) throws IOException {
|
|
||||||
final CustomBufferedInputStream bis = new CustomBufferedInputStream(
|
final CustomBufferedInputStream bis = new CustomBufferedInputStream(
|
||||||
new GZIPInputStream(body.byteStream()));
|
new GZIPInputStream(body.byteStream()));
|
||||||
|
|
||||||
|
@ -1661,15 +1652,15 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
|
||||||
|
|
||||||
final int legAttrIndex = is.readShortReverse();
|
final int legAttrIndex = is.readShortReverse();
|
||||||
|
|
||||||
final List<Line.Attr> lineAttrs = new ArrayList<>();
|
final List<Attr> lineAttrs = new ArrayList<>();
|
||||||
String lineComment = null;
|
String lineComment = null;
|
||||||
boolean lineOnDemand = false;
|
boolean lineOnDemand = false;
|
||||||
for (final String comment : comments.read(is)) {
|
for (final String comment : comments.read(is)) {
|
||||||
if (comment.startsWith("bf ")) {
|
if (comment.startsWith("bf ")) {
|
||||||
lineAttrs.add(Line.Attr.WHEEL_CHAIR_ACCESS);
|
lineAttrs.add(Attr.WHEEL_CHAIR_ACCESS);
|
||||||
} else if (comment.startsWith("FA ") || comment.startsWith("FB ")
|
} else if (comment.startsWith("FA ") || comment.startsWith("FB ")
|
||||||
|| comment.startsWith("FR ")) {
|
|| comment.startsWith("FR ")) {
|
||||||
lineAttrs.add(Line.Attr.BICYCLE_CARRIAGE);
|
lineAttrs.add(Attr.BICYCLE_CARRIAGE);
|
||||||
} else if (comment.startsWith("$R ") || comment.startsWith("ga ")
|
} else if (comment.startsWith("$R ") || comment.startsWith("ga ")
|
||||||
|| comment.startsWith("ja ") || comment.startsWith("Vs ")
|
|| comment.startsWith("ja ") || comment.startsWith("Vs ")
|
||||||
|| comment.startsWith("mu ") || comment.startsWith("mx ")) {
|
|| comment.startsWith("mu ") || comment.startsWith("mx ")) {
|
||||||
|
@ -1879,7 +1870,7 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
|
||||||
lineProduct = normalizeType(lineCategory);
|
lineProduct = normalizeType(lineCategory);
|
||||||
|
|
||||||
final Line line = newLine(lineNetwork, lineProduct, normalizeLineName(lineName),
|
final Line line = newLine(lineNetwork, lineProduct, normalizeLineName(lineName),
|
||||||
lineComment, lineAttrs.toArray(new Line.Attr[0]));
|
lineComment, lineAttrs.toArray(new Attr[0]));
|
||||||
|
|
||||||
final Location direction;
|
final Location direction;
|
||||||
if (directionStr != null) {
|
if (directionStr != null) {
|
||||||
|
@ -2015,7 +2006,6 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
|
||||||
throw new IllegalStateException("error " + errorCode + " on " + url);
|
throw new IllegalStateException("error " + errorCode + " on " + url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}, url);
|
}, url);
|
||||||
|
|
||||||
return result.get();
|
return result.get();
|
||||||
|
|
|
@ -96,10 +96,5 @@ public final class Departure implements Serializable {
|
||||||
return Objects.hashCode(plannedTime, predictedTime, line, destination);
|
return Objects.hashCode(plannedTime, predictedTime, line, destination);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Comparator<Departure> TIME_COMPARATOR = new Comparator<Departure>() {
|
public static final Comparator<Departure> TIME_COMPARATOR = (departure0, departure1) -> departure0.getTime().compareTo(departure1.getTime());
|
||||||
@Override
|
|
||||||
public int compare(final Departure departure0, final Departure departure1) {
|
|
||||||
return departure0.getTime().compareTo(departure1.getTime());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,12 +208,7 @@ public final class HttpClient {
|
||||||
public CharSequence get(final HttpUrl url, final String postRequest, final String requestContentType)
|
public CharSequence get(final HttpUrl url, final String postRequest, final String requestContentType)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
final StringBuilder buffer = new StringBuilder();
|
final StringBuilder buffer = new StringBuilder();
|
||||||
final Callback callback = new Callback() {
|
final Callback callback = (bodyPeek, body) -> buffer.append(body.string());
|
||||||
@Override
|
|
||||||
public void onSuccessful(final CharSequence bodyPeek, final ResponseBody body) throws IOException {
|
|
||||||
buffer.append(body.string());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
getInputStream(callback, url, postRequest, requestContentType, null);
|
getInputStream(callback, url, postRequest, requestContentType, null);
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
@ -382,10 +377,5 @@ public final class HttpClient {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private static final HostnameVerifier SSL_ACCEPT_ALL_HOSTNAMES = new HostnameVerifier() {
|
private static final HostnameVerifier SSL_ACCEPT_ALL_HOSTNAMES = (hostname, session) -> true;
|
||||||
@Override
|
|
||||||
public boolean verify(final String hostname, final SSLSession session) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue