Add XmlPullUtil.optEnter() and use it where possible.

This commit is contained in:
Andreas Schildbach 2017-03-23 16:51:50 +01:00
parent 12a2093912
commit 9398b454a5
2 changed files with 225 additions and 291 deletions

View file

@ -413,12 +413,8 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
final List<SuggestedLocation> locations = new ArrayList<>(); final List<SuggestedLocation> locations = new ArrayList<>();
XmlPullUtil.require(pp, "sf"); XmlPullUtil.require(pp, "sf");
if (!pp.isEmptyElementTag()) { if (XmlPullUtil.optEnter(pp, "sf")) {
XmlPullUtil.enter(pp, "sf"); while (XmlPullUtil.optEnter(pp, "p")) {
while (XmlPullUtil.test(pp, "p")) {
XmlPullUtil.enter(pp, "p");
final String name = normalizeLocationName(XmlPullUtil.valueTag(pp, "n")); final String name = normalizeLocationName(XmlPullUtil.valueTag(pp, "n"));
final String u = XmlPullUtil.valueTag(pp, "u"); final String u = XmlPullUtil.valueTag(pp, "u");
if (!"sf".equals(u)) if (!"sf".equals(u))
@ -462,8 +458,6 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
} }
XmlPullUtil.skipExit(pp, "sf"); XmlPullUtil.skipExit(pp, "sf");
} else {
XmlPullUtil.next(pp);
} }
result.set(new SuggestLocationsResult(header, locations)); result.set(new SuggestLocationsResult(header, locations));
@ -529,9 +523,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
final List<Location> locations = new ArrayList<>(); final List<Location> locations = new ArrayList<>();
if (XmlPullUtil.test(pp, "coordInfoItemList")) { if (XmlPullUtil.optEnter(pp, "coordInfoItemList")) {
XmlPullUtil.enter(pp, "coordInfoItemList");
while (XmlPullUtil.test(pp, "coordInfoItem")) { while (XmlPullUtil.test(pp, "coordInfoItem")) {
final String type = XmlPullUtil.attr(pp, "type"); final String type = XmlPullUtil.attr(pp, "type");
final LocationType locationType; final LocationType locationType;
@ -601,12 +593,8 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
final List<Location> stations = new ArrayList<>(); final List<Location> stations = new ArrayList<>();
if (XmlPullUtil.test(pp, "pis")) { if (XmlPullUtil.optEnter(pp, "pis")) {
XmlPullUtil.enter(pp, "pis"); while (XmlPullUtil.optEnter(pp, "pi")) {
while (XmlPullUtil.test(pp, "pi")) {
XmlPullUtil.enter(pp, "pi");
final String name = normalizeLocationName(XmlPullUtil.optValueTag(pp, "de", null)); final String name = normalizeLocationName(XmlPullUtil.optValueTag(pp, "de", null));
final String type = XmlPullUtil.valueTag(pp, "ty"); final String type = XmlPullUtil.valueTag(pp, "ty");
final LocationType locationType; final LocationType locationType;
@ -714,9 +702,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
XmlPullUtil.optSkip(pp, "itdPoiHierarchyRoot"); XmlPullUtil.optSkip(pp, "itdPoiHierarchyRoot");
if (XmlPullUtil.test(pp, "itdOdvAssignedStops")) { if (XmlPullUtil.optEnter(pp, "itdOdvAssignedStops")) {
XmlPullUtil.enter(pp, "itdOdvAssignedStops");
while (XmlPullUtil.test(pp, "itdOdvAssignedStop")) { while (XmlPullUtil.test(pp, "itdOdvAssignedStop")) {
final Location stop = processItdOdvAssignedStop(pp); final Location stop = processItdOdvAssignedStop(pp);
@ -1540,8 +1526,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
} }
XmlPullUtil.require(pp, "itdDepartureList"); XmlPullUtil.require(pp, "itdDepartureList");
if (!pp.isEmptyElementTag()) { if (XmlPullUtil.optEnter(pp, "itdDepartureList")) {
XmlPullUtil.enter(pp, "itdDepartureList");
final Calendar plannedDepartureTime = new GregorianCalendar(timeZone); final Calendar plannedDepartureTime = new GregorianCalendar(timeZone);
final Calendar predictedDepartureTime = new GregorianCalendar(timeZone); final Calendar predictedDepartureTime = new GregorianCalendar(timeZone);
@ -1594,8 +1579,6 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
} }
XmlPullUtil.skipExit(pp, "itdDepartureList"); XmlPullUtil.skipExit(pp, "itdDepartureList");
} else {
XmlPullUtil.next(pp);
} }
result.set(r); result.set(r);
@ -1630,15 +1613,11 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
final QueryDeparturesResult r = new QueryDeparturesResult(header); final QueryDeparturesResult r = new QueryDeparturesResult(header);
XmlPullUtil.require(pp, "dps"); XmlPullUtil.require(pp, "dps");
if (!pp.isEmptyElementTag()) { if (XmlPullUtil.optEnter(pp, "dps")) {
XmlPullUtil.enter(pp, "dps");
final Calendar plannedDepartureTime = new GregorianCalendar(timeZone); final Calendar plannedDepartureTime = new GregorianCalendar(timeZone);
final Calendar predictedDepartureTime = new GregorianCalendar(timeZone); final Calendar predictedDepartureTime = new GregorianCalendar(timeZone);
while (XmlPullUtil.test(pp, "dp")) { while (XmlPullUtil.optEnter(pp, "dp")) {
XmlPullUtil.enter(pp, "dp");
// misc // misc
/* final String stationName = */normalizeLocationName(XmlPullUtil.valueTag(pp, "n")); /* final String stationName = */normalizeLocationName(XmlPullUtil.valueTag(pp, "n"));
/* final boolean isRealtime = */XmlPullUtil.valueTag(pp, "realtime").equals("1"); /* final boolean isRealtime = */XmlPullUtil.valueTag(pp, "realtime").equals("1");
@ -2251,8 +2230,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
XmlPullUtil.enter(pp, "itdTripDateTime"); XmlPullUtil.enter(pp, "itdTripDateTime");
XmlPullUtil.enter(pp, "itdDateTime"); XmlPullUtil.enter(pp, "itdDateTime");
XmlPullUtil.require(pp, "itdDate"); XmlPullUtil.require(pp, "itdDate");
if (!pp.isEmptyElementTag()) { if (XmlPullUtil.optEnter(pp, "itdDate")) {
XmlPullUtil.enter(pp, "itdDate");
if (XmlPullUtil.test(pp, "itdMessage")) { if (XmlPullUtil.test(pp, "itdMessage")) {
final String message = XmlPullUtil.nextText(pp, null, "itdMessage"); final String message = XmlPullUtil.nextText(pp, null, "itdMessage");
@ -2262,8 +2240,6 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
throw new IllegalStateException("unknown message: " + message); throw new IllegalStateException("unknown message: " + message);
} }
XmlPullUtil.skipExit(pp, "itdDate"); XmlPullUtil.skipExit(pp, "itdDate");
} else {
XmlPullUtil.next(pp);
} }
XmlPullUtil.skipExit(pp, "itdDateTime"); XmlPullUtil.skipExit(pp, "itdDateTime");
XmlPullUtil.skipExit(pp, "itdTripDateTime"); XmlPullUtil.skipExit(pp, "itdTripDateTime");
@ -2274,14 +2250,10 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
final List<Trip> trips = new ArrayList<>(); final List<Trip> trips = new ArrayList<>();
XmlPullUtil.require(pp, "itdItinerary"); XmlPullUtil.require(pp, "itdItinerary");
if (!pp.isEmptyElementTag()) { if (XmlPullUtil.optEnter(pp, "itdItinerary")) {
XmlPullUtil.enter(pp, "itdItinerary");
XmlPullUtil.optSkip(pp, "itdLegTTs"); XmlPullUtil.optSkip(pp, "itdLegTTs");
if (XmlPullUtil.test(pp, "itdRouteList")) { if (XmlPullUtil.optEnter(pp, "itdRouteList")) {
XmlPullUtil.enter(pp, "itdRouteList");
final Calendar calendar = new GregorianCalendar(timeZone); final Calendar calendar = new GregorianCalendar(timeZone);
while (XmlPullUtil.test(pp, "itdRoute")) { while (XmlPullUtil.test(pp, "itdRoute")) {
@ -2397,9 +2369,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
XmlPullUtil.skipExit(pp, "itdPartialRouteList"); XmlPullUtil.skipExit(pp, "itdPartialRouteList");
final List<Fare> fares = new ArrayList<>(2); final List<Fare> fares = new ArrayList<>(2);
if (XmlPullUtil.test(pp, "itdFare")) { if (XmlPullUtil.optEnter(pp, "itdFare")) {
if (!pp.isEmptyElementTag()) {
XmlPullUtil.enter(pp, "itdFare");
if (XmlPullUtil.test(pp, "itdSingleTicket")) { if (XmlPullUtil.test(pp, "itdSingleTicket")) {
final String net = XmlPullUtil.optAttr(pp, "net", null); final String net = XmlPullUtil.optAttr(pp, "net", null);
if (net != null) { if (net != null) {
@ -2422,10 +2392,8 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
levelChild != null ? null : unitName, levelChild != null ? null : unitName,
levelChild != null ? levelChild : unitsChild)); levelChild != null ? levelChild : unitsChild));
if (!pp.isEmptyElementTag()) { if (XmlPullUtil.optEnter(pp, "itdSingleTicket")) {
XmlPullUtil.enter(pp, "itdSingleTicket"); if (XmlPullUtil.optEnter(pp, "itdGenericTicketList")) {
if (XmlPullUtil.test(pp, "itdGenericTicketList")) {
XmlPullUtil.enter(pp, "itdGenericTicketList");
while (XmlPullUtil.test(pp, "itdGenericTicketGroup")) { while (XmlPullUtil.test(pp, "itdGenericTicketGroup")) {
final Fare fare = processItdGenericTicketGroup(pp, net.toUpperCase(), final Fare fare = processItdGenericTicketGroup(pp, net.toUpperCase(),
currency); currency);
@ -2435,15 +2403,10 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
XmlPullUtil.skipExit(pp, "itdGenericTicketList"); XmlPullUtil.skipExit(pp, "itdGenericTicketList");
} }
XmlPullUtil.skipExit(pp, "itdSingleTicket"); XmlPullUtil.skipExit(pp, "itdSingleTicket");
} else {
XmlPullUtil.next(pp);
} }
} }
} }
XmlPullUtil.skipExit(pp, "itdFare"); XmlPullUtil.skipExit(pp, "itdFare");
} else {
XmlPullUtil.next(pp);
}
} }
XmlPullUtil.skipExit(pp, "itdRoute"); XmlPullUtil.skipExit(pp, "itdRoute");
@ -2458,8 +2421,6 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
XmlPullUtil.skipExit(pp, "itdRouteList"); XmlPullUtil.skipExit(pp, "itdRouteList");
} }
XmlPullUtil.skipExit(pp, "itdItinerary"); XmlPullUtil.skipExit(pp, "itdItinerary");
} else {
XmlPullUtil.next(pp);
} }
return new QueryTripsResult(header, url.toString(), from, via, to, return new QueryTripsResult(header, url.toString(), from, via, to,
@ -2550,9 +2511,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
boolean lowFloorVehicle = false; boolean lowFloorVehicle = false;
String message = null; String message = null;
if (XmlPullUtil.test(pp, "itdInfoTextList")) { if (XmlPullUtil.optEnter(pp, "itdInfoTextList")) {
if (!pp.isEmptyElementTag()) {
XmlPullUtil.enter(pp, "itdInfoTextList");
while (XmlPullUtil.test(pp, "infoTextListElem")) { while (XmlPullUtil.test(pp, "infoTextListElem")) {
final String text = XmlPullUtil.valueTag(pp, "infoTextListElem"); final String text = XmlPullUtil.valueTag(pp, "infoTextListElem");
if (text != null) { if (text != null) {
@ -2564,15 +2523,11 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
} }
} }
XmlPullUtil.skipExit(pp, "itdInfoTextList"); XmlPullUtil.skipExit(pp, "itdInfoTextList");
} else {
XmlPullUtil.next(pp);
}
} }
XmlPullUtil.optSkip(pp, "itdFootPathInfo"); XmlPullUtil.optSkip(pp, "itdFootPathInfo");
while (XmlPullUtil.test(pp, "infoLink")) { while (XmlPullUtil.optEnter(pp, "infoLink")) {
XmlPullUtil.enter(pp, "infoLink");
XmlPullUtil.optSkip(pp, "paramList"); XmlPullUtil.optSkip(pp, "paramList");
final String infoLinkText = XmlPullUtil.valueTag(pp, "infoLinkText"); final String infoLinkText = XmlPullUtil.valueTag(pp, "infoLinkText");
if (message == null) if (message == null)
@ -2581,8 +2536,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
} }
List<Stop> intermediateStops = null; List<Stop> intermediateStops = null;
if (XmlPullUtil.test(pp, "itdStopSeq")) { if (XmlPullUtil.optEnter(pp, "itdStopSeq")) {
XmlPullUtil.enter(pp, "itdStopSeq");
intermediateStops = new LinkedList<>(); intermediateStops = new LinkedList<>();
while (XmlPullUtil.test(pp, "itdPoint")) { while (XmlPullUtil.test(pp, "itdPoint")) {
final Location stopLocation = processItdPointAttributes(pp); final Location stopLocation = processItdPointAttributes(pp);
@ -2650,10 +2604,8 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
path = processItdPathCoordinates(pp); path = processItdPathCoordinates(pp);
boolean wheelChairAccess = false; boolean wheelChairAccess = false;
if (XmlPullUtil.test(pp, "genAttrList")) { if (XmlPullUtil.optEnter(pp, "genAttrList")) {
XmlPullUtil.enter(pp, "genAttrList"); while (XmlPullUtil.optEnter(pp, "genAttrElem")) {
while (XmlPullUtil.test(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.skipExit(pp, "genAttrElem"); XmlPullUtil.skipExit(pp, "genAttrElem");
@ -2666,8 +2618,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
XmlPullUtil.skipExit(pp, "genAttrList"); XmlPullUtil.skipExit(pp, "genAttrList");
} }
if (XmlPullUtil.test(pp, "nextDeps")) { if (XmlPullUtil.optEnter(pp, "nextDeps")) {
XmlPullUtil.enter(pp, "nextDeps");
while (XmlPullUtil.test(pp, "itdDateTime")) { while (XmlPullUtil.test(pp, "itdDateTime")) {
processItdDateTime(pp, calendar); processItdDateTime(pp, calendar);
/* final Date nextDepartureTime = */calendar.getTime(); /* final Date nextDepartureTime = */calendar.getTime();
@ -2704,13 +2655,8 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
final List<Trip> trips = new ArrayList<>(); final List<Trip> trips = new ArrayList<>();
if (XmlPullUtil.test(pp, "ts")) { if (XmlPullUtil.optEnter(pp, "ts")) {
if (!pp.isEmptyElementTag()) { while (XmlPullUtil.optEnter(pp, "tp")) {
XmlPullUtil.enter(pp, "ts");
while (XmlPullUtil.test(pp, "tp")) {
XmlPullUtil.enter(pp, "tp");
XmlPullUtil.optSkip(pp, "attrs"); XmlPullUtil.optSkip(pp, "attrs");
XmlPullUtil.valueTag(pp, "d"); // duration XmlPullUtil.valueTag(pp, "d"); // duration
@ -2734,9 +2680,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
Stop departure = null; Stop departure = null;
Stop arrival = null; Stop arrival = null;
while (XmlPullUtil.test(pp, "p")) { while (XmlPullUtil.optEnter(pp, "p")) {
XmlPullUtil.enter(pp, "p");
final String name = XmlPullUtil.valueTag(pp, "n"); final String name = XmlPullUtil.valueTag(pp, "n");
final String usage = XmlPullUtil.valueTag(pp, "u"); final String usage = XmlPullUtil.valueTag(pp, "u");
XmlPullUtil.optValueTag(pp, "de", null); XmlPullUtil.optValueTag(pp, "de", null);
@ -2763,8 +2707,8 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
XmlPullUtil.skipExit(pp, "p"); XmlPullUtil.skipExit(pp, "p");
final Date plannedTime = plannedTimeCal.isSet(Calendar.HOUR_OF_DAY) final Date plannedTime = plannedTimeCal.isSet(Calendar.HOUR_OF_DAY) ? plannedTimeCal.getTime()
? plannedTimeCal.getTime() : null; : null;
final Date predictedTime = predictedTimeCal.isSet(Calendar.HOUR_OF_DAY) final Date predictedTime = predictedTimeCal.isSet(Calendar.HOUR_OF_DAY)
? predictedTimeCal.getTime() : null; ? predictedTimeCal.getTime() : null;
@ -2795,13 +2739,9 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
else else
path = null; path = null;
XmlPullUtil.require(pp, "pss");
final List<Stop> intermediateStops; final List<Stop> intermediateStops;
XmlPullUtil.require(pp, "pss");
if (!pp.isEmptyElementTag()) { if (XmlPullUtil.optEnter(pp, "pss")) {
XmlPullUtil.enter(pp, "pss");
intermediateStops = new LinkedList<>(); intermediateStops = new LinkedList<>();
while (XmlPullUtil.test(pp, "s")) { while (XmlPullUtil.test(pp, "s")) {
@ -2814,8 +2754,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
if (!id.equals(departure.location.id) && !id.equals(arrival.location.id)) { if (!id.equals(departure.location.id) && !id.equals(arrival.location.id)) {
final String name = normalizeLocationName(intermediateParts[1]); final String name = normalizeLocationName(intermediateParts[1]);
if (!("0000-1".equals(intermediateParts[2]) if (!("0000-1".equals(intermediateParts[2]) && "000-1".equals(intermediateParts[3]))) {
&& "000-1".equals(intermediateParts[3]))) {
ParserUtils.parseIsoDate(plannedTimeCal, intermediateParts[2]); ParserUtils.parseIsoDate(plannedTimeCal, intermediateParts[2]);
ParserUtils.parseIsoTime(plannedTimeCal, intermediateParts[3]); ParserUtils.parseIsoTime(plannedTimeCal, intermediateParts[3]);
@ -2844,8 +2783,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
} else { } else {
coords = null; coords = null;
} }
final Location location = new Location(LocationType.STATION, id, coords, null, final Location location = new Location(LocationType.STATION, id, coords, null, name);
name);
final Date plannedTime = plannedTimeCal.isSet(Calendar.HOUR_OF_DAY) final Date plannedTime = plannedTimeCal.isSet(Calendar.HOUR_OF_DAY)
? plannedTimeCal.getTime() : null; ? plannedTimeCal.getTime() : null;
@ -2860,8 +2798,6 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
XmlPullUtil.skipExit(pp, "pss"); XmlPullUtil.skipExit(pp, "pss");
} else { } else {
intermediateStops = null; intermediateStops = null;
XmlPullUtil.next(pp);
} }
XmlPullUtil.optSkip(pp, "interchange"); XmlPullUtil.optSkip(pp, "interchange");
@ -2881,8 +2817,8 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
|| lineDestination.line == Line.DO_NOT_CHANGE) { || lineDestination.line == Line.DO_NOT_CHANGE) {
// ignore // ignore
} else { } else {
legs.add(new Trip.Public(lineDestination.line, lineDestination.destination, departure, legs.add(new Trip.Public(lineDestination.line, lineDestination.destination, departure, arrival,
arrival, intermediateStops, path, null)); intermediateStops, path, null));
} }
} }
@ -2891,18 +2827,10 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
XmlPullUtil.optSkip(pp, "seqroutes"); XmlPullUtil.optSkip(pp, "seqroutes");
final List<Fare> fares; final List<Fare> fares;
if (XmlPullUtil.test(pp, "tcs")) { if (XmlPullUtil.optEnter(pp, "tcs")) {
if (!pp.isEmptyElementTag()) {
XmlPullUtil.enter(pp, "tcs");
fares = new ArrayList<>(2); fares = new ArrayList<>(2);
XmlPullUtil.optSkipMultiple(pp, "tc"); // TODO fares XmlPullUtil.optSkipMultiple(pp, "tc"); // TODO fares
XmlPullUtil.skipExit(pp, "tcs"); XmlPullUtil.skipExit(pp, "tcs");
} else {
fares = null;
XmlPullUtil.next(pp);
}
} else { } else {
fares = null; fares = null;
} }
@ -2915,9 +2843,6 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
} }
XmlPullUtil.skipExit(pp, "ts"); XmlPullUtil.skipExit(pp, "ts");
} else {
XmlPullUtil.next(pp);
}
} }
if (trips.size() > 0) { if (trips.size() > 0) {
@ -2969,9 +2894,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
XmlPullUtil.enter(pp, "itdCoordinateBaseElemList"); XmlPullUtil.enter(pp, "itdCoordinateBaseElemList");
while (XmlPullUtil.test(pp, "itdCoordinateBaseElem")) { while (XmlPullUtil.optEnter(pp, "itdCoordinateBaseElem")) {
XmlPullUtil.enter(pp, "itdCoordinateBaseElem");
final int lon = (int) Math.round(Double.parseDouble(XmlPullUtil.valueTag(pp, "x"))); final int lon = (int) Math.round(Double.parseDouble(XmlPullUtil.valueTag(pp, "x")));
final int lat = (int) Math.round(Double.parseDouble(XmlPullUtil.valueTag(pp, "y"))); final int lat = (int) Math.round(Double.parseDouble(XmlPullUtil.valueTag(pp, "y")));
path.add(new Point(lat, lon)); path.add(new Point(lat, lon));
@ -3015,9 +2938,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
Type type = null; Type type = null;
float fare = 0; float fare = 0;
while (XmlPullUtil.test(pp, "itdGenericTicket")) { while (XmlPullUtil.optEnter(pp, "itdGenericTicket")) {
XmlPullUtil.enter(pp, "itdGenericTicket");
final String key = XmlPullUtil.valueTag(pp, "ticket"); final String key = XmlPullUtil.valueTag(pp, "ticket");
final String value = XmlPullUtil.valueTag(pp, "value"); final String value = XmlPullUtil.valueTag(pp, "value");
@ -3192,8 +3113,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
XmlPullUtil.enter(pp, "pas"); XmlPullUtil.enter(pp, "pas");
while (XmlPullUtil.test(pp, "pa")) { while (XmlPullUtil.optEnter(pp, "pa")) {
XmlPullUtil.enter(pp, "pa");
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);

View file

@ -48,6 +48,20 @@ public final class XmlPullUtil {
enter(pp); enter(pp);
} }
public static boolean optEnter(final XmlPullParser pp, final String tagName)
throws XmlPullParserException, IOException {
if (!test(pp, tagName))
return false;
final boolean isEmpty = pp.isEmptyElementTag();
pp.next(); // Skip start tag
if (isEmpty) {
pp.next(); // Skip (virtual) end tag
return false;
} else {
return true;
}
}
public static void skipExit(final XmlPullParser pp) throws XmlPullParserException, IOException { public static void skipExit(final XmlPullParser pp) throws XmlPullParserException, IOException {
skipToEnd(pp); skipToEnd(pp);