Rename XmlPullUtil.exit() to skipExit().

This commit is contained in:
Andreas Schildbach 2014-08-10 16:28:46 +02:00
parent 96c3ce459e
commit 0b5ee4ffb7
3 changed files with 113 additions and 113 deletions

View file

@ -412,11 +412,11 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
throw new RuntimeException("unknown nameState '" + nameState + "' on " + uri); throw new RuntimeException("unknown nameState '" + nameState + "' on " + uri);
} }
XmlPullUtil.exit(pp, "itdOdvName"); XmlPullUtil.skipExit(pp, "itdOdvName");
XmlPullUtil.exit(pp, "itdOdv"); XmlPullUtil.skipExit(pp, "itdOdv");
XmlPullUtil.exit(pp, "itdStopFinderRequest"); XmlPullUtil.skipExit(pp, "itdStopFinderRequest");
return new SuggestLocationsResult(header, locations); return new SuggestLocationsResult(header, locations);
} }
@ -493,12 +493,12 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
XmlPullUtil.valueTag(pp, "pid"); XmlPullUtil.valueTag(pp, "pid");
final Point coord = coordStrToPoint(XmlPullUtil.optValueTag(pp, "c", null)); final Point coord = coordStrToPoint(XmlPullUtil.optValueTag(pp, "c", null));
XmlPullUtil.exit(pp, "r"); XmlPullUtil.skipExit(pp, "r");
final String qal = XmlPullUtil.optValueTag(pp, "qal", null); final String qal = XmlPullUtil.optValueTag(pp, "qal", null);
final int quality = qal != null ? Integer.parseInt(qal) : 0; final int quality = qal != null ? Integer.parseInt(qal) : 0;
XmlPullUtil.exit(pp, "p"); XmlPullUtil.skipExit(pp, "p");
final Location location = new Location(type, type == LocationType.STATION ? id : null, coord != null ? coord.lat : 0, final Location location = new Location(type, type == LocationType.STATION ? id : null, coord != null ? coord.lat : 0,
coord != null ? coord.lon : 0, place, name); coord != null ? coord.lon : 0, place, name);
@ -506,7 +506,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
locations.add(locationAndQuality); locations.add(locationAndQuality);
} }
XmlPullUtil.exit(pp, "sf"); XmlPullUtil.skipExit(pp, "sf");
} }
else else
{ {
@ -568,7 +568,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
XmlPullUtil.enter(pp, "itdCoordInfo"); XmlPullUtil.enter(pp, "itdCoordInfo");
XmlPullUtil.enter(pp, "coordInfoRequest"); XmlPullUtil.enter(pp, "coordInfoRequest");
XmlPullUtil.exit(pp, "coordInfoRequest"); XmlPullUtil.skipExit(pp, "coordInfoRequest");
final List<Location> stations = new ArrayList<Location>(); final List<Location> stations = new ArrayList<Location>();
@ -590,12 +590,12 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
// FIXME this is always only one coordinate // FIXME this is always only one coordinate
final Point coord = processItdPathCoordinates(pp).get(0); final Point coord = processItdPathCoordinates(pp).get(0);
XmlPullUtil.exit(pp, "coordInfoItem"); XmlPullUtil.skipExit(pp, "coordInfoItem");
stations.add(new Location(LocationType.STATION, id, coord.lat, coord.lon, place, name)); stations.add(new Location(LocationType.STATION, id, coord.lat, coord.lon, place, name));
} }
XmlPullUtil.exit(pp, "coordInfoItemList"); XmlPullUtil.skipExit(pp, "coordInfoItemList");
} }
return new NearbyStationsResult(header, stations); return new NearbyStationsResult(header, stations);
@ -637,7 +637,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
XmlPullUtil.enter(pp, "ci"); XmlPullUtil.enter(pp, "ci");
XmlPullUtil.enter(pp, "request"); XmlPullUtil.enter(pp, "request");
XmlPullUtil.exit(pp, "request"); XmlPullUtil.skipExit(pp, "request");
final List<Location> stations = new ArrayList<Location>(); final List<Location> stations = new ArrayList<Location>();
@ -665,13 +665,13 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
stations.add(new Location(LocationType.STATION, id, coord.lat, coord.lon, place, name)); stations.add(new Location(LocationType.STATION, id, coord.lat, coord.lon, place, name));
XmlPullUtil.exit(pp, "pi"); XmlPullUtil.skipExit(pp, "pi");
} }
XmlPullUtil.exit(pp, "pis"); XmlPullUtil.skipExit(pp, "pis");
} }
XmlPullUtil.exit(pp, "ci"); XmlPullUtil.skipExit(pp, "ci");
return new NearbyStationsResult(header, stations); return new NearbyStationsResult(header, stations);
} }
@ -705,7 +705,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
if (XmlPullUtil.test(pp, "odvPlaceElem")) if (XmlPullUtil.test(pp, "odvPlaceElem"))
place = normalizeLocationName(XmlPullUtil.valueTag(pp, "odvPlaceElem")); place = normalizeLocationName(XmlPullUtil.valueTag(pp, "odvPlaceElem"));
} }
XmlPullUtil.exit(pp, "itdOdvPlace"); XmlPullUtil.skipExit(pp, "itdOdvPlace");
return place; return place;
} }
@ -919,7 +919,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
final Location ownLocation = processOdvNameElem(pp, place); final Location ownLocation = processOdvNameElem(pp, place);
final Location ownStation = ownLocation.type == LocationType.STATION ? ownLocation : null; final Location ownStation = ownLocation.type == LocationType.STATION ? ownLocation : null;
XmlPullUtil.exit(pp, "itdOdvName"); XmlPullUtil.skipExit(pp, "itdOdvName");
final List<Location> stations = new ArrayList<Location>(); final List<Location> stations = new ArrayList<Location>();
@ -933,10 +933,10 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
if (!stations.contains(newStation)) if (!stations.contains(newStation))
stations.add(newStation); stations.add(newStation);
} }
XmlPullUtil.exit(pp, "itdOdvAssignedStops"); XmlPullUtil.skipExit(pp, "itdOdvAssignedStops");
} }
XmlPullUtil.exit(pp, "itdOdv"); XmlPullUtil.skipExit(pp, "itdOdv");
if (ownStation != null && !stations.contains(ownStation)) if (ownStation != null && !stations.contains(ownStation))
stations.add(ownStation); stations.add(ownStation);
@ -1460,7 +1460,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
final Location location = processOdvNameElem(pp, place); final Location location = processOdvNameElem(pp, place);
result.stationDepartures.add(new StationDepartures(location, new LinkedList<Departure>(), new LinkedList<LineDestination>())); result.stationDepartures.add(new StationDepartures(location, new LinkedList<Departure>(), new LinkedList<LineDestination>()));
XmlPullUtil.exit(pp, "itdOdvName"); XmlPullUtil.skipExit(pp, "itdOdvName");
if (XmlPullUtil.test(pp, "itdOdvAssignedStops")) if (XmlPullUtil.test(pp, "itdOdvAssignedStops"))
{ {
@ -1472,10 +1472,10 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
result.stationDepartures.add(new StationDepartures(assignedLocation, new LinkedList<Departure>(), result.stationDepartures.add(new StationDepartures(assignedLocation, new LinkedList<Departure>(),
new LinkedList<LineDestination>())); new LinkedList<LineDestination>()));
} }
XmlPullUtil.exit(pp, "itdOdvAssignedStops"); XmlPullUtil.skipExit(pp, "itdOdvAssignedStops");
} }
XmlPullUtil.exit(pp, "itdOdv"); XmlPullUtil.skipExit(pp, "itdOdv");
if (XmlPullUtil.test(pp, "itdDateTime")) if (XmlPullUtil.test(pp, "itdDateTime"))
XmlPullUtil.next(pp); XmlPullUtil.next(pp);
@ -1521,7 +1521,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
if (!assignedStationDepartures.lines.contains(line)) if (!assignedStationDepartures.lines.contains(line))
assignedStationDepartures.lines.add(line); assignedStationDepartures.lines.add(line);
} }
XmlPullUtil.exit(pp, "itdServingLines"); XmlPullUtil.skipExit(pp, "itdServingLines");
} }
else else
{ {
@ -1593,7 +1593,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
if (isRealtime && !predictedDepartureTime.isSet(Calendar.HOUR_OF_DAY)) if (isRealtime && !predictedDepartureTime.isSet(Calendar.HOUR_OF_DAY))
predictedDepartureTime.setTimeInMillis(plannedDepartureTime.getTimeInMillis()); predictedDepartureTime.setTimeInMillis(plannedDepartureTime.getTimeInMillis());
XmlPullUtil.exit(pp, "itdDeparture"); XmlPullUtil.skipExit(pp, "itdDeparture");
final Departure departure = new Departure(plannedDepartureTime.getTime(), final Departure departure = new Departure(plannedDepartureTime.getTime(),
predictedDepartureTime.isSet(Calendar.HOUR_OF_DAY) ? predictedDepartureTime.getTime() : null, line, position, predictedDepartureTime.isSet(Calendar.HOUR_OF_DAY) ? predictedDepartureTime.getTime() : null, line, position,
@ -1601,7 +1601,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
assignedStationDepartures.departures.add(departure); assignedStationDepartures.departures.add(departure);
} }
XmlPullUtil.exit(pp, "itdDepartureList"); XmlPullUtil.skipExit(pp, "itdDepartureList");
} }
else else
{ {
@ -1681,7 +1681,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
final String assignedId = XmlPullUtil.valueTag(pp, "id"); final String assignedId = XmlPullUtil.valueTag(pp, "id");
XmlPullUtil.valueTag(pp, "a"); XmlPullUtil.valueTag(pp, "a");
final Position position = new Position(XmlPullUtil.optValueTag(pp, "pl", null)); final Position position = new Position(XmlPullUtil.optValueTag(pp, "pl", null));
XmlPullUtil.exit(pp, "r"); XmlPullUtil.skipExit(pp, "r");
/* final Point positionCoordinate = */coordStrToPoint(XmlPullUtil.optValueTag(pp, "c", null)); /* final Point positionCoordinate = */coordStrToPoint(XmlPullUtil.optValueTag(pp, "c", null));
@ -1699,10 +1699,10 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
predictedDepartureTime.isSet(Calendar.HOUR_OF_DAY) ? predictedDepartureTime.getTime() : null, lineDestination.line, predictedDepartureTime.isSet(Calendar.HOUR_OF_DAY) ? predictedDepartureTime.getTime() : null, lineDestination.line,
position, lineDestination.destination, null, null)); position, lineDestination.destination, null, null));
XmlPullUtil.exit(pp, "dp"); XmlPullUtil.skipExit(pp, "dp");
} }
XmlPullUtil.exit(pp, "dps"); XmlPullUtil.skipExit(pp, "dps");
return result; return result;
} }
@ -1786,7 +1786,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
line = new Line(lineId, lineLabel, lineStyle(network, lineLabel)); line = new Line(lineId, lineLabel, lineStyle(network, lineLabel));
} }
XmlPullUtil.exit(pp, "m"); XmlPullUtil.skipExit(pp, "m");
return new LineDestination(line, destination); return new LineDestination(line, destination);
} }
@ -1800,7 +1800,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
final String lineIdPr = XmlPullUtil.valueTag(pp, "pr"); final String lineIdPr = XmlPullUtil.valueTag(pp, "pr");
final String lineIdDct = XmlPullUtil.valueTag(pp, "dct"); final String lineIdDct = XmlPullUtil.valueTag(pp, "dct");
final String lineIdNe = XmlPullUtil.valueTag(pp, "ne"); final String lineIdNe = XmlPullUtil.valueTag(pp, "ne");
XmlPullUtil.exit(pp, "dv"); XmlPullUtil.skipExit(pp, "dv");
return lineIdNe + ":" + lineIdLi + ":" + lineIdSu + ":" + lineIdDct + ":" + lineIdPr; return lineIdNe + ":" + lineIdLi + ":" + lineIdSu + ":" + lineIdDct + ":" + lineIdPr;
} }
@ -1821,7 +1821,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
ParserUtils.parseIsoTime(predictedDepartureTime, XmlPullUtil.valueTag(pp, "rt")); ParserUtils.parseIsoTime(predictedDepartureTime, XmlPullUtil.valueTag(pp, "rt"));
} }
XmlPullUtil.exit(pp, "st"); XmlPullUtil.skipExit(pp, "st");
} }
private StationDepartures findStationDepartures(final List<StationDepartures> stationDepartures, final String id) private StationDepartures findStationDepartures(final List<StationDepartures> stationDepartures, final String id)
@ -1876,7 +1876,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
final boolean success = processItdDate(pp, calendar); final boolean success = processItdDate(pp, calendar);
if (success) if (success)
processItdTime(pp, calendar); processItdTime(pp, calendar);
XmlPullUtil.exit(pp); XmlPullUtil.skipExit(pp);
return success; return success;
} }
@ -1937,7 +1937,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
if (!pp.isEmptyElementTag()) if (!pp.isEmptyElementTag())
{ {
XmlPullUtil.enter(pp, "itdTrain"); XmlPullUtil.enter(pp, "itdTrain");
XmlPullUtil.exit(pp, "itdTrain"); XmlPullUtil.skipExit(pp, "itdTrain");
} }
else else
{ {
@ -1965,7 +1965,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
XmlPullUtil.require(pp, "motDivaParams"); XmlPullUtil.require(pp, "motDivaParams");
final String divaNetwork = XmlPullUtil.attr(pp, "network"); final String divaNetwork = XmlPullUtil.attr(pp, "network");
XmlPullUtil.exit(pp, "itdServingLine"); XmlPullUtil.skipExit(pp, "itdServingLine");
final String trainType = ParserUtils.firstNotEmpty(slTrainType, itdTrainType); final String trainType = ParserUtils.firstNotEmpty(slTrainType, itdTrainType);
final String trainName = ParserUtils.firstNotEmpty(slTrainName, itdTrainName); final String trainName = ParserUtils.firstNotEmpty(slTrainName, itdTrainName);
@ -2342,8 +2342,8 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
else else
throw new IllegalStateException("unknown usage: " + usage); throw new IllegalStateException("unknown usage: " + usage);
} }
XmlPullUtil.exit(pp, "itdOdvName"); XmlPullUtil.skipExit(pp, "itdOdvName");
XmlPullUtil.exit(pp, "itdOdv"); XmlPullUtil.skipExit(pp, "itdOdv");
} }
if (ambiguousFrom != null || ambiguousTo != null || ambiguousVia != null) if (ambiguousFrom != null || ambiguousTo != null || ambiguousVia != null)
@ -2364,14 +2364,14 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
else else
throw new IllegalStateException("unknown message: " + message); throw new IllegalStateException("unknown message: " + message);
} }
XmlPullUtil.exit(pp, "itdDate"); XmlPullUtil.skipExit(pp, "itdDate");
} }
else else
{ {
XmlPullUtil.next(pp); XmlPullUtil.next(pp);
} }
XmlPullUtil.exit(pp, "itdDateTime"); XmlPullUtil.skipExit(pp, "itdDateTime");
XmlPullUtil.exit(pp, "itdTripDateTime"); XmlPullUtil.skipExit(pp, "itdTripDateTime");
XmlPullUtil.requireSkip(pp, "itdTripOptions"); XmlPullUtil.requireSkip(pp, "itdTripOptions");
@ -2438,7 +2438,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
{ {
departureTargetTime = null; departureTargetTime = null;
} }
XmlPullUtil.exit(pp, "itdPoint"); XmlPullUtil.skipExit(pp, "itdPoint");
XmlPullUtil.test(pp, "itdPoint"); XmlPullUtil.test(pp, "itdPoint");
if (!"arrival".equals(pp.getAttributeValue(null, "usage"))) if (!"arrival".equals(pp.getAttributeValue(null, "usage")))
@ -2462,7 +2462,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
{ {
arrivalTargetTime = null; arrivalTargetTime = null;
} }
XmlPullUtil.exit(pp, "itdPoint"); XmlPullUtil.skipExit(pp, "itdPoint");
XmlPullUtil.test(pp, "itdMeansOfTransport"); XmlPullUtil.test(pp, "itdMeansOfTransport");
final String productName = pp.getAttributeValue(null, "productName"); final String productName = pp.getAttributeValue(null, "productName");
@ -2471,7 +2471,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
final Trip.Individual.Type type = "Taxi".equals(productName) ? Trip.Individual.Type.TRANSFER : Trip.Individual.Type.WALK; final Trip.Individual.Type type = "Taxi".equals(productName) ? Trip.Individual.Type.TRANSFER : Trip.Individual.Type.WALK;
XmlPullUtil.enter(pp, "itdMeansOfTransport"); XmlPullUtil.enter(pp, "itdMeansOfTransport");
XmlPullUtil.exit(pp, "itdMeansOfTransport"); XmlPullUtil.skipExit(pp, "itdMeansOfTransport");
if (XmlPullUtil.test(pp, "itdStopSeq")) if (XmlPullUtil.test(pp, "itdStopSeq"))
XmlPullUtil.next(pp); XmlPullUtil.next(pp);
@ -2502,7 +2502,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
// ignore // ignore
XmlPullUtil.enter(pp, "itdMeansOfTransport"); XmlPullUtil.enter(pp, "itdMeansOfTransport");
XmlPullUtil.exit(pp, "itdMeansOfTransport"); XmlPullUtil.skipExit(pp, "itdMeansOfTransport");
} }
else if ("PT".equals(partialRouteType)) else if ("PT".equals(partialRouteType))
{ {
@ -2534,7 +2534,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
final String divaDirection = XmlPullUtil.attr(pp, "direction"); final String divaDirection = XmlPullUtil.attr(pp, "direction");
final String divaProject = XmlPullUtil.attr(pp, "project"); final String divaProject = XmlPullUtil.attr(pp, "project");
final String lineId = divaNetwork + ':' + divaLine + ':' + divaSupplement + ':' + divaDirection + ':' + divaProject; final String lineId = divaNetwork + ':' + divaLine + ':' + divaSupplement + ':' + divaDirection + ':' + divaProject;
XmlPullUtil.exit(pp, "itdMeansOfTransport"); XmlPullUtil.skipExit(pp, "itdMeansOfTransport");
final Integer departureDelay; final Integer departureDelay;
final Integer arrivalDelay; final Integer arrivalDelay;
@ -2572,7 +2572,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
message = text; message = text;
} }
} }
XmlPullUtil.exit(pp, "itdInfoTextList"); XmlPullUtil.skipExit(pp, "itdInfoTextList");
} }
else else
{ {
@ -2589,7 +2589,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
final String infoLinkText = XmlPullUtil.valueTag(pp, "infoLinkText"); final String infoLinkText = XmlPullUtil.valueTag(pp, "infoLinkText");
if (message == null) if (message == null)
message = infoLinkText; message = infoLinkText;
XmlPullUtil.exit(pp, "infoLink"); XmlPullUtil.skipExit(pp, "infoLink");
} }
List<Stop> intermediateStops = null; List<Stop> intermediateStops = null;
@ -2653,9 +2653,9 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
intermediateStops.add(stop); intermediateStops.add(stop);
XmlPullUtil.exit(pp, "itdPoint"); XmlPullUtil.skipExit(pp, "itdPoint");
} }
XmlPullUtil.exit(pp, "itdStopSeq"); XmlPullUtil.skipExit(pp, "itdStopSeq");
// remove first and last, because they are not intermediate // remove first and last, because they are not intermediate
final int size = intermediateStops.size(); final int size = intermediateStops.size();
@ -2684,14 +2684,14 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
XmlPullUtil.enter(pp, "genAttrElem"); XmlPullUtil.enter(pp, "genAttrElem");
final String name = XmlPullUtil.valueTag(pp, "name"); final String name = XmlPullUtil.valueTag(pp, "name");
final String value = XmlPullUtil.valueTag(pp, "value"); final String value = XmlPullUtil.valueTag(pp, "value");
XmlPullUtil.exit(pp, "genAttrElem"); XmlPullUtil.skipExit(pp, "genAttrElem");
// System.out.println("genAttrElem: name='" + name + "' value='" + value + "'"); // System.out.println("genAttrElem: name='" + name + "' value='" + value + "'");
if ("PlanWheelChairAccess".equals(name) && "1".equals(value)) if ("PlanWheelChairAccess".equals(name) && "1".equals(value))
wheelChairAccess = true; wheelChairAccess = true;
} }
XmlPullUtil.exit(pp, "genAttrList"); XmlPullUtil.skipExit(pp, "genAttrList");
} }
if (XmlPullUtil.test(pp, "nextDeps")) if (XmlPullUtil.test(pp, "nextDeps"))
@ -2702,7 +2702,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
processItdDateTime(pp, time); processItdDateTime(pp, time);
/* final Date nextDepartureTime = */time.getTime(); /* final Date nextDepartureTime = */time.getTime();
} }
XmlPullUtil.exit(pp, "nextDeps"); XmlPullUtil.skipExit(pp, "nextDeps");
} }
final Set<Line.Attr> lineAttrs = new HashSet<Line.Attr>(); final Set<Line.Attr> lineAttrs = new HashSet<Line.Attr>();
@ -2722,10 +2722,10 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
throw new IllegalStateException("unknown type: '" + partialRouteType + "' '" + productName + "'"); throw new IllegalStateException("unknown type: '" + partialRouteType + "' '" + productName + "'");
} }
XmlPullUtil.exit(pp, "itdPartialRoute"); XmlPullUtil.skipExit(pp, "itdPartialRoute");
} }
XmlPullUtil.exit(pp, "itdPartialRouteList"); XmlPullUtil.skipExit(pp, "itdPartialRouteList");
final List<Fare> fares = new ArrayList<Fare>(2); final List<Fare> fares = new ArrayList<Fare>(2);
if (XmlPullUtil.test(pp, "itdFare")) if (XmlPullUtil.test(pp, "itdFare"))
@ -2763,16 +2763,16 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
if (fare != null) if (fare != null)
fares.add(fare); fares.add(fare);
} }
XmlPullUtil.exit(pp, "itdGenericTicketList"); XmlPullUtil.skipExit(pp, "itdGenericTicketList");
} }
XmlPullUtil.exit(pp, "itdSingleTicket"); XmlPullUtil.skipExit(pp, "itdSingleTicket");
} }
else else
{ {
XmlPullUtil.next(pp); XmlPullUtil.next(pp);
} }
} }
XmlPullUtil.exit(pp, "itdFare"); XmlPullUtil.skipExit(pp, "itdFare");
} }
else else
{ {
@ -2780,7 +2780,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
} }
} }
XmlPullUtil.exit(pp, "itdRoute"); XmlPullUtil.skipExit(pp, "itdRoute");
final Trip trip = new Trip(id, firstDepartureLocation, lastArrivalLocation, legs, fares.isEmpty() ? null : fares, null, final Trip trip = new Trip(id, firstDepartureLocation, lastArrivalLocation, legs, fares.isEmpty() ? null : fares, null,
numChanges); numChanges);
@ -2789,9 +2789,9 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
trips.add(trip); trips.add(trip);
} }
XmlPullUtil.exit(pp, "itdRouteList"); XmlPullUtil.skipExit(pp, "itdRouteList");
} }
XmlPullUtil.exit(pp, "itdItinerary"); XmlPullUtil.skipExit(pp, "itdItinerary");
} }
else else
{ {
@ -2866,7 +2866,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
final Position position = new Position(XmlPullUtil.optValueTag(pp, "pl", null)); final Position position = new Position(XmlPullUtil.optValueTag(pp, "pl", null));
final String place = normalizeLocationName(XmlPullUtil.optValueTag(pp, "pc", null)); final String place = normalizeLocationName(XmlPullUtil.optValueTag(pp, "pc", null));
final Point coord = coordStrToPoint(XmlPullUtil.optValueTag(pp, "c", null)); final Point coord = coordStrToPoint(XmlPullUtil.optValueTag(pp, "c", null));
XmlPullUtil.exit(pp, "r"); XmlPullUtil.skipExit(pp, "r");
final Location location; final Location location;
if (id.equals("99999997") || id.equals("99999998")) if (id.equals("99999997") || id.equals("99999998"))
@ -2876,7 +2876,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
location = new Location(LocationType.STATION, id, coord != null ? coord.lat : 0, coord != null ? coord.lon : 0, location = new Location(LocationType.STATION, id, coord != null ? coord.lat : 0, coord != null ? coord.lon : 0,
place, name); place, name);
XmlPullUtil.exit(pp, "p"); XmlPullUtil.skipExit(pp, "p");
if ("departure".equals(usage)) if ("departure".equals(usage))
{ {
@ -2899,7 +2899,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
} }
} }
XmlPullUtil.exit(pp, "ps"); XmlPullUtil.skipExit(pp, "ps");
final boolean isRealtime = XmlPullUtil.valueTag(pp, "realtime").equals("1"); final boolean isRealtime = XmlPullUtil.valueTag(pp, "realtime").equals("1");
@ -2975,7 +2975,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
} }
} }
XmlPullUtil.exit(pp, "pss"); XmlPullUtil.skipExit(pp, "pss");
} }
else else
{ {
@ -2989,7 +2989,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
XmlPullUtil.requireSkip(pp, "ns"); XmlPullUtil.requireSkip(pp, "ns");
// TODO messages // TODO messages
XmlPullUtil.exit(pp, "l"); XmlPullUtil.skipExit(pp, "l");
if (lineDestination.line == Line.FOOTWAY) if (lineDestination.line == Line.FOOTWAY)
{ {
@ -3012,7 +3012,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
} }
} }
XmlPullUtil.exit(pp, "ls"); XmlPullUtil.skipExit(pp, "ls");
XmlPullUtil.require(pp, "tcs"); XmlPullUtil.require(pp, "tcs");
@ -3028,10 +3028,10 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
{ {
XmlPullUtil.enter(pp, "tc"); XmlPullUtil.enter(pp, "tc");
// TODO fares // TODO fares
XmlPullUtil.exit(pp, "tc"); XmlPullUtil.skipExit(pp, "tc");
} }
XmlPullUtil.exit(pp, "tcs"); XmlPullUtil.skipExit(pp, "tcs");
} }
else else
{ {
@ -3043,10 +3043,10 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
final Trip trip = new Trip(tripId, firstDepartureLocation, lastArrivalLocation, legs, fares, null, numChanges); final Trip trip = new Trip(tripId, firstDepartureLocation, lastArrivalLocation, legs, fares, null, numChanges);
trips.add(trip); trips.add(trip);
XmlPullUtil.exit(pp, "tp"); XmlPullUtil.skipExit(pp, "tp");
} }
XmlPullUtil.exit(pp, "ts"); XmlPullUtil.skipExit(pp, "ts");
} }
else else
{ {
@ -3091,7 +3091,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
throw new IllegalStateException(pp.getPositionDescription()); throw new IllegalStateException(pp.getPositionDescription());
} }
XmlPullUtil.exit(pp, "itdPathCoordinates"); XmlPullUtil.skipExit(pp, "itdPathCoordinates");
return path; return path;
} }
@ -3121,10 +3121,10 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
final int lat = Math.round(Float.parseFloat(XmlPullUtil.valueTag(pp, "y"))); final int lat = Math.round(Float.parseFloat(XmlPullUtil.valueTag(pp, "y")));
path.add(new Point(lat, lon)); path.add(new Point(lat, lon));
XmlPullUtil.exit(pp, "itdCoordinateBaseElem"); XmlPullUtil.skipExit(pp, "itdCoordinateBaseElem");
} }
XmlPullUtil.exit(pp, "itdCoordinateBaseElemList"); XmlPullUtil.skipExit(pp, "itdCoordinateBaseElemList");
return path; return path;
} }
@ -3166,10 +3166,10 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
fare = Float.parseFloat(value) * fareCorrectionFactor; fare = Float.parseFloat(value) * fareCorrectionFactor;
} }
XmlPullUtil.exit(pp, "itdGenericTicket"); XmlPullUtil.skipExit(pp, "itdGenericTicket");
} }
XmlPullUtil.exit(pp, "itdGenericTicketGroup"); XmlPullUtil.skipExit(pp, "itdGenericTicketGroup");
if (type != null) if (type != null)
return new Fare(net, type, currency, fare, null, null); return new Fare(net, type, currency, fare, null, null);
@ -3342,10 +3342,10 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
final String name = XmlPullUtil.valueTag(pp, "n"); final String name = XmlPullUtil.valueTag(pp, "n");
final String value = XmlPullUtil.valueTag(pp, "v"); final String value = XmlPullUtil.valueTag(pp, "v");
params.put(name, value); params.put(name, value);
XmlPullUtil.exit(pp, "pa"); XmlPullUtil.skipExit(pp, "pa");
} }
XmlPullUtil.exit(pp, "pas"); XmlPullUtil.skipExit(pp, "pas");
return params; return params;
} }

View file

@ -304,7 +304,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
{ {
XmlPullUtil.enter(pp, "Platform"); XmlPullUtil.enter(pp, "Platform");
final String platformText = XmlPullUtil.valueTag(pp, "Text"); final String platformText = XmlPullUtil.valueTag(pp, "Text");
XmlPullUtil.exit(pp, "Platform"); XmlPullUtil.skipExit(pp, "Platform");
if (platformText == null || platformText.length() == 0) if (platformText == null || platformText.length() == 0)
return null; return null;
@ -957,7 +957,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
XmlPullUtil.next(pp); XmlPullUtil.next(pp);
final Location departureLocation = parseLocation(pp); final Location departureLocation = parseLocation(pp);
XmlPullUtil.enter(pp, "Dep"); XmlPullUtil.enter(pp, "Dep");
XmlPullUtil.exit(pp, "Dep"); XmlPullUtil.skipExit(pp, "Dep");
final int[] capacity; final int[] capacity;
if (XmlPullUtil.test(pp, "StopPrognosis")) if (XmlPullUtil.test(pp, "StopPrognosis"))
{ {
@ -967,33 +967,33 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
if (XmlPullUtil.test(pp, "Dep")) if (XmlPullUtil.test(pp, "Dep"))
XmlPullUtil.next(pp); XmlPullUtil.next(pp);
XmlPullUtil.enter(pp, "Status"); XmlPullUtil.enter(pp, "Status");
XmlPullUtil.exit(pp, "Status"); XmlPullUtil.skipExit(pp, "Status");
final int capacity1st = Integer.parseInt(XmlPullUtil.optValueTag(pp, "Capacity1st", "0")); final int capacity1st = Integer.parseInt(XmlPullUtil.optValueTag(pp, "Capacity1st", "0"));
final int capacity2nd = Integer.parseInt(XmlPullUtil.optValueTag(pp, "Capacity2nd", "0")); final int capacity2nd = Integer.parseInt(XmlPullUtil.optValueTag(pp, "Capacity2nd", "0"));
if (capacity1st > 0 || capacity2nd > 0) if (capacity1st > 0 || capacity2nd > 0)
capacity = new int[] { capacity1st, capacity2nd }; capacity = new int[] { capacity1st, capacity2nd };
else else
capacity = null; capacity = null;
XmlPullUtil.exit(pp, "StopPrognosis"); XmlPullUtil.skipExit(pp, "StopPrognosis");
} }
else else
{ {
capacity = null; capacity = null;
} }
XmlPullUtil.exit(pp, "BasicStop"); XmlPullUtil.skipExit(pp, "BasicStop");
XmlPullUtil.exit(pp, "Departure"); XmlPullUtil.skipExit(pp, "Departure");
XmlPullUtil.enter(pp, "Arrival"); XmlPullUtil.enter(pp, "Arrival");
XmlPullUtil.enter(pp, "BasicStop"); XmlPullUtil.enter(pp, "BasicStop");
while (pp.getName().equals("StAttrList")) while (pp.getName().equals("StAttrList"))
XmlPullUtil.next(pp); XmlPullUtil.next(pp);
final Location arrivalLocation = parseLocation(pp); final Location arrivalLocation = parseLocation(pp);
XmlPullUtil.exit(pp, "BasicStop"); XmlPullUtil.skipExit(pp, "BasicStop");
XmlPullUtil.exit(pp, "Arrival"); XmlPullUtil.skipExit(pp, "Arrival");
final int numTransfers = Integer.parseInt(XmlPullUtil.valueTag(pp, "Transfers")); final int numTransfers = Integer.parseInt(XmlPullUtil.valueTag(pp, "Transfers"));
XmlPullUtil.exit(pp, "Overview"); XmlPullUtil.skipExit(pp, "Overview");
final List<Trip.Leg> legs = new ArrayList<Trip.Leg>(4); final List<Trip.Leg> legs = new ArrayList<Trip.Leg>(4);
@ -1015,17 +1015,17 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
if (XmlPullUtil.test(pp, "Arr")) if (XmlPullUtil.test(pp, "Arr"))
{ {
XmlPullUtil.enter(pp, "Arr"); XmlPullUtil.enter(pp, "Arr");
XmlPullUtil.exit(pp, "Arr"); XmlPullUtil.skipExit(pp, "Arr");
} }
XmlPullUtil.enter(pp, "Dep"); XmlPullUtil.enter(pp, "Dep");
time.setTimeInMillis(currentDate.getTimeInMillis()); time.setTimeInMillis(currentDate.getTimeInMillis());
parseTime(time, XmlPullUtil.valueTag(pp, "Time")); parseTime(time, XmlPullUtil.valueTag(pp, "Time"));
final Date departureTime = time.getTime(); final Date departureTime = time.getTime();
final Position departurePos = parsePlatform(pp); final Position departurePos = parsePlatform(pp);
XmlPullUtil.exit(pp, "Dep"); XmlPullUtil.skipExit(pp, "Dep");
XmlPullUtil.exit(pp, "BasicStop"); XmlPullUtil.skipExit(pp, "BasicStop");
XmlPullUtil.exit(pp, "Departure"); XmlPullUtil.skipExit(pp, "Departure");
// journey // journey
final Line line; final Line line;
@ -1053,8 +1053,8 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
final String code = pp.getAttributeValue(null, "code"); final String code = pp.getAttributeValue(null, "code");
XmlPullUtil.enter(pp, "Attribute"); XmlPullUtil.enter(pp, "Attribute");
final Map<String, String> attributeVariants = parseAttributeVariants(pp); final Map<String, String> attributeVariants = parseAttributeVariants(pp);
XmlPullUtil.exit(pp, "Attribute"); XmlPullUtil.skipExit(pp, "Attribute");
XmlPullUtil.exit(pp, "JourneyAttribute"); XmlPullUtil.skipExit(pp, "JourneyAttribute");
if ("bf".equals(code)) if ("bf".equals(code))
{ {
@ -1076,7 +1076,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
destination = new Location(LocationType.ANY, null, destinationPlaceAndName[0], destinationPlaceAndName[1]); destination = new Location(LocationType.ANY, null, destinationPlaceAndName[0], destinationPlaceAndName[1]);
} }
} }
XmlPullUtil.exit(pp, "JourneyAttributeList"); XmlPullUtil.skipExit(pp, "JourneyAttributeList");
if (XmlPullUtil.test(pp, "PassList")) if (XmlPullUtil.test(pp, "PassList"))
{ {
@ -1103,7 +1103,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
parseTime(time, XmlPullUtil.valueTag(pp, "Time")); parseTime(time, XmlPullUtil.valueTag(pp, "Time"));
stopArrivalTime = time.getTime(); stopArrivalTime = time.getTime();
stopArrivalPosition = parsePlatform(pp); stopArrivalPosition = parsePlatform(pp);
XmlPullUtil.exit(pp, "Arr"); XmlPullUtil.skipExit(pp, "Arr");
} }
if (XmlPullUtil.test(pp, "Dep")) if (XmlPullUtil.test(pp, "Dep"))
@ -1113,19 +1113,19 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
parseTime(time, XmlPullUtil.valueTag(pp, "Time")); parseTime(time, XmlPullUtil.valueTag(pp, "Time"));
stopDepartureTime = time.getTime(); stopDepartureTime = time.getTime();
stopDeparturePosition = parsePlatform(pp); stopDeparturePosition = parsePlatform(pp);
XmlPullUtil.exit(pp, "Dep"); XmlPullUtil.skipExit(pp, "Dep");
} }
intermediateStops.add(new Stop(location, stopArrivalTime, stopArrivalPosition, stopDepartureTime, intermediateStops.add(new Stop(location, stopArrivalTime, stopArrivalPosition, stopDepartureTime,
stopDeparturePosition)); stopDeparturePosition));
} }
XmlPullUtil.exit(pp, "BasicStop"); XmlPullUtil.skipExit(pp, "BasicStop");
} }
XmlPullUtil.exit(pp, "PassList"); XmlPullUtil.skipExit(pp, "PassList");
} }
XmlPullUtil.exit(pp, "Journey"); XmlPullUtil.skipExit(pp, "Journey");
if (category == null) if (category == null)
category = shortCategory; category = shortCategory;
@ -1136,8 +1136,8 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
{ {
XmlPullUtil.enter(pp); XmlPullUtil.enter(pp);
XmlPullUtil.enter(pp, "Duration"); XmlPullUtil.enter(pp, "Duration");
XmlPullUtil.exit(pp, "Duration"); XmlPullUtil.skipExit(pp, "Duration");
XmlPullUtil.exit(pp); XmlPullUtil.skipExit(pp);
line = null; line = null;
} }
@ -1159,7 +1159,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
path.add(new Point(y, x)); path.add(new Point(y, x));
XmlPullUtil.next(pp); XmlPullUtil.next(pp);
} }
XmlPullUtil.exit(pp, "Polyline"); XmlPullUtil.skipExit(pp, "Polyline");
} }
else else
{ {
@ -1177,10 +1177,10 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
parseTime(time, XmlPullUtil.valueTag(pp, "Time")); parseTime(time, XmlPullUtil.valueTag(pp, "Time"));
final Date arrivalTime = time.getTime(); final Date arrivalTime = time.getTime();
final Position arrivalPos = parsePlatform(pp); final Position arrivalPos = parsePlatform(pp);
XmlPullUtil.exit(pp, "Arr"); XmlPullUtil.skipExit(pp, "Arr");
XmlPullUtil.exit(pp, "BasicStop"); XmlPullUtil.skipExit(pp, "BasicStop");
XmlPullUtil.exit(pp, "Arrival"); XmlPullUtil.skipExit(pp, "Arrival");
// remove last intermediate // remove last intermediate
final int size = intermediateStops != null ? intermediateStops.size() : 0; final int size = intermediateStops != null ? intermediateStops.size() : 0;
@ -1188,7 +1188,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
if (!intermediateStops.get(size - 1).location.id.equals(sectionArrivalLocation.id)) if (!intermediateStops.get(size - 1).location.id.equals(sectionArrivalLocation.id))
intermediateStops.remove(size - 1); intermediateStops.remove(size - 1);
XmlPullUtil.exit(pp, "ConSection"); XmlPullUtil.skipExit(pp, "ConSection");
if (line != null) if (line != null)
{ {
@ -1213,14 +1213,14 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
} }
} }
XmlPullUtil.exit(pp, "ConSectionList"); XmlPullUtil.skipExit(pp, "ConSectionList");
XmlPullUtil.exit(pp, "Connection"); XmlPullUtil.skipExit(pp, "Connection");
trips.add(new Trip(id, departureLocation, arrivalLocation, legs, null, capacity, numTransfers)); trips.add(new Trip(id, departureLocation, arrivalLocation, legs, null, capacity, numTransfers));
} }
XmlPullUtil.exit(pp, "ConnectionList"); XmlPullUtil.skipExit(pp, "ConnectionList");
return new QueryTripsResult(header, null, from, via, to, context, trips); return new QueryTripsResult(header, null, from, via, to, context, trips);
} }
@ -1259,7 +1259,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
final String type = XmlPullUtil.attr(pp, "type"); final String type = XmlPullUtil.attr(pp, "type");
XmlPullUtil.enter(pp, "AttributeVariant"); XmlPullUtil.enter(pp, "AttributeVariant");
final String value = XmlPullUtil.optValueTag(pp, "Text", null); final String value = XmlPullUtil.optValueTag(pp, "Text", null);
XmlPullUtil.exit(pp, "AttributeVariant"); XmlPullUtil.skipExit(pp, "AttributeVariant");
attributeVariants.put(type, value); attributeVariants.put(type, value);
} }

View file

@ -49,9 +49,9 @@ public final class XmlPullUtil
enter(pp); enter(pp);
} }
public static void exit(final XmlPullParser pp) throws XmlPullParserException, IOException public static void skipExit(final XmlPullParser pp) throws XmlPullParserException, IOException
{ {
exitSkipToEnd(pp); skipToEnd(pp);
if (pp.getEventType() != XmlPullParser.END_TAG) if (pp.getEventType() != XmlPullParser.END_TAG)
throw new IllegalStateException("expecting end tag to exit"); throw new IllegalStateException("expecting end tag to exit");
@ -59,15 +59,15 @@ public final class XmlPullUtil
pp.next(); pp.next();
} }
public static void exit(final XmlPullParser pp, final String tagName) throws XmlPullParserException, IOException public static void skipExit(final XmlPullParser pp, final String tagName) throws XmlPullParserException, IOException
{ {
exitSkipToEnd(pp); skipToEnd(pp);
pp.require(XmlPullParser.END_TAG, null, tagName); pp.require(XmlPullParser.END_TAG, null, tagName);
pp.next(); pp.next();
} }
private static void exitSkipToEnd(final XmlPullParser pp) throws XmlPullParserException, IOException private static void skipToEnd(final XmlPullParser pp) throws XmlPullParserException, IOException
{ {
while (pp.getEventType() != XmlPullParser.END_TAG) while (pp.getEventType() != XmlPullParser.END_TAG)
{ {
@ -95,7 +95,7 @@ public final class XmlPullUtil
if (!pp.isEmptyElementTag()) if (!pp.isEmptyElementTag())
{ {
enter(pp, tagName); enter(pp, tagName);
exit(pp, tagName); skipExit(pp, tagName);
} }
else else
{ {
@ -178,7 +178,7 @@ public final class XmlPullUtil
{ {
XmlPullUtil.enter(pp, tagName); XmlPullUtil.enter(pp, tagName);
final String value = pp.getText(); final String value = pp.getText();
XmlPullUtil.exit(pp, tagName); XmlPullUtil.skipExit(pp, tagName);
return value != null ? value.trim() : null; return value != null ? value.trim() : null;
} }