mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-18 16:29:51 +00:00
correct handling of empty element tags
This commit is contained in:
parent
699fa20344
commit
9286139ab6
1 changed files with 72 additions and 43 deletions
|
@ -1459,6 +1459,10 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
||||||
|
|
||||||
XmlPullUtil.exit(pp, "itdDepartureList");
|
XmlPullUtil.exit(pp, "itdDepartureList");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
XmlPullUtil.next(pp);
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -1864,8 +1868,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
||||||
|
|
||||||
XmlPullUtil.enter(pp, "itdTripDateTime");
|
XmlPullUtil.enter(pp, "itdTripDateTime");
|
||||||
XmlPullUtil.enter(pp, "itdDateTime");
|
XmlPullUtil.enter(pp, "itdDateTime");
|
||||||
if (!XmlPullUtil.test(pp, "itdDate"))
|
XmlPullUtil.require(pp, "itdDate");
|
||||||
throw new IllegalStateException("cannot find <itdDate />");
|
|
||||||
if (!pp.isEmptyElementTag())
|
if (!pp.isEmptyElementTag())
|
||||||
{
|
{
|
||||||
XmlPullUtil.enter(pp, "itdDate");
|
XmlPullUtil.enter(pp, "itdDate");
|
||||||
|
@ -1879,6 +1882,10 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
||||||
}
|
}
|
||||||
XmlPullUtil.exit(pp, "itdDate");
|
XmlPullUtil.exit(pp, "itdDate");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
XmlPullUtil.next(pp);
|
||||||
|
}
|
||||||
XmlPullUtil.exit(pp, "itdDateTime");
|
XmlPullUtil.exit(pp, "itdDateTime");
|
||||||
|
|
||||||
final Calendar time = new GregorianCalendar(timeZone());
|
final Calendar time = new GregorianCalendar(timeZone());
|
||||||
|
@ -2030,18 +2037,25 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
||||||
XmlPullUtil.next(pp);
|
XmlPullUtil.next(pp);
|
||||||
|
|
||||||
boolean lowFloorVehicle = false;
|
boolean lowFloorVehicle = false;
|
||||||
if (XmlPullUtil.test(pp, "itdInfoTextList") && !pp.isEmptyElementTag())
|
if (XmlPullUtil.test(pp, "itdInfoTextList"))
|
||||||
{
|
{
|
||||||
XmlPullUtil.enter(pp, "itdInfoTextList");
|
if (!pp.isEmptyElementTag())
|
||||||
while (XmlPullUtil.test(pp, "infoTextListElem"))
|
|
||||||
{
|
{
|
||||||
XmlPullUtil.enter(pp, "infoTextListElem");
|
XmlPullUtil.enter(pp, "itdInfoTextList");
|
||||||
final String text = pp.getText();
|
while (XmlPullUtil.test(pp, "infoTextListElem"))
|
||||||
if ("Niederflurwagen soweit verfügbar".equals(text)) // KVV
|
{
|
||||||
lowFloorVehicle = true;
|
XmlPullUtil.enter(pp, "infoTextListElem");
|
||||||
XmlPullUtil.exit(pp, "infoTextListElem");
|
final String text = pp.getText();
|
||||||
|
if ("Niederflurwagen soweit verfügbar".equals(text)) // KVV
|
||||||
|
lowFloorVehicle = true;
|
||||||
|
XmlPullUtil.exit(pp, "infoTextListElem");
|
||||||
|
}
|
||||||
|
XmlPullUtil.exit(pp, "itdInfoTextList");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
XmlPullUtil.next(pp);
|
||||||
}
|
}
|
||||||
XmlPullUtil.exit(pp, "itdInfoTextList");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (XmlPullUtil.test(pp, "itdFootPathInfo"))
|
if (XmlPullUtil.test(pp, "itdFootPathInfo"))
|
||||||
|
@ -2155,47 +2169,58 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
||||||
XmlPullUtil.exit(pp, "itdPartialRouteList");
|
XmlPullUtil.exit(pp, "itdPartialRouteList");
|
||||||
|
|
||||||
final List<Fare> fares = new ArrayList<Fare>(2);
|
final List<Fare> fares = new ArrayList<Fare>(2);
|
||||||
if (XmlPullUtil.test(pp, "itdFare") && !pp.isEmptyElementTag())
|
if (XmlPullUtil.test(pp, "itdFare"))
|
||||||
{
|
{
|
||||||
XmlPullUtil.enter(pp, "itdFare");
|
if (!pp.isEmptyElementTag())
|
||||||
if (XmlPullUtil.test(pp, "itdSingleTicket"))
|
|
||||||
{
|
{
|
||||||
final String net = XmlPullUtil.attr(pp, "net");
|
XmlPullUtil.enter(pp, "itdFare");
|
||||||
final Currency currency = parseCurrency(XmlPullUtil.attr(pp, "currency"));
|
if (XmlPullUtil.test(pp, "itdSingleTicket"))
|
||||||
final String fareAdult = XmlPullUtil.attr(pp, "fareAdult");
|
|
||||||
final String fareChild = XmlPullUtil.attr(pp, "fareChild");
|
|
||||||
final String unitName = XmlPullUtil.attr(pp, "unitName");
|
|
||||||
final String unitsAdult = XmlPullUtil.attr(pp, "unitsAdult");
|
|
||||||
final String unitsChild = XmlPullUtil.attr(pp, "unitsChild");
|
|
||||||
final String levelAdult = pp.getAttributeValue(null, "levelAdult");
|
|
||||||
final boolean hasLevelAdult = levelAdult != null && levelAdult.length() > 0;
|
|
||||||
final String levelChild = pp.getAttributeValue(null, "levelChild");
|
|
||||||
final boolean hasLevelChild = levelChild != null && levelChild.length() > 0;
|
|
||||||
if (fareAdult != null && fareAdult.length() > 0)
|
|
||||||
fares.add(new Fare(net, Type.ADULT, currency, Float.parseFloat(fareAdult), hasLevelAdult ? null : unitName,
|
|
||||||
hasLevelAdult ? levelAdult : unitsAdult));
|
|
||||||
if (fareChild != null && fareChild.length() > 0)
|
|
||||||
fares.add(new Fare(net, Type.CHILD, currency, Float.parseFloat(fareChild), hasLevelChild ? null : unitName,
|
|
||||||
hasLevelChild ? levelChild : unitsChild));
|
|
||||||
|
|
||||||
if (!pp.isEmptyElementTag())
|
|
||||||
{
|
{
|
||||||
XmlPullUtil.enter(pp, "itdSingleTicket");
|
final String net = XmlPullUtil.attr(pp, "net");
|
||||||
if (XmlPullUtil.test(pp, "itdGenericTicketList"))
|
final Currency currency = parseCurrency(XmlPullUtil.attr(pp, "currency"));
|
||||||
|
final String fareAdult = XmlPullUtil.attr(pp, "fareAdult");
|
||||||
|
final String fareChild = XmlPullUtil.attr(pp, "fareChild");
|
||||||
|
final String unitName = XmlPullUtil.attr(pp, "unitName");
|
||||||
|
final String unitsAdult = XmlPullUtil.attr(pp, "unitsAdult");
|
||||||
|
final String unitsChild = XmlPullUtil.attr(pp, "unitsChild");
|
||||||
|
final String levelAdult = pp.getAttributeValue(null, "levelAdult");
|
||||||
|
final boolean hasLevelAdult = levelAdult != null && levelAdult.length() > 0;
|
||||||
|
final String levelChild = pp.getAttributeValue(null, "levelChild");
|
||||||
|
final boolean hasLevelChild = levelChild != null && levelChild.length() > 0;
|
||||||
|
if (fareAdult != null && fareAdult.length() > 0)
|
||||||
|
fares.add(new Fare(net, Type.ADULT, currency, Float.parseFloat(fareAdult), hasLevelAdult ? null : unitName,
|
||||||
|
hasLevelAdult ? levelAdult : unitsAdult));
|
||||||
|
if (fareChild != null && fareChild.length() > 0)
|
||||||
|
fares.add(new Fare(net, Type.CHILD, currency, Float.parseFloat(fareChild), hasLevelChild ? null : unitName,
|
||||||
|
hasLevelChild ? levelChild : unitsChild));
|
||||||
|
|
||||||
|
if (!pp.isEmptyElementTag())
|
||||||
{
|
{
|
||||||
XmlPullUtil.enter(pp, "itdGenericTicketList");
|
XmlPullUtil.enter(pp, "itdSingleTicket");
|
||||||
while (XmlPullUtil.test(pp, "itdGenericTicketGroup"))
|
if (XmlPullUtil.test(pp, "itdGenericTicketList"))
|
||||||
{
|
{
|
||||||
final Fare fare = processItdGenericTicketGroup(pp, net, currency);
|
XmlPullUtil.enter(pp, "itdGenericTicketList");
|
||||||
if (fare != null)
|
while (XmlPullUtil.test(pp, "itdGenericTicketGroup"))
|
||||||
fares.add(fare);
|
{
|
||||||
|
final Fare fare = processItdGenericTicketGroup(pp, net, currency);
|
||||||
|
if (fare != null)
|
||||||
|
fares.add(fare);
|
||||||
|
}
|
||||||
|
XmlPullUtil.exit(pp, "itdGenericTicketList");
|
||||||
}
|
}
|
||||||
XmlPullUtil.exit(pp, "itdGenericTicketList");
|
XmlPullUtil.exit(pp, "itdSingleTicket");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
XmlPullUtil.next(pp);
|
||||||
}
|
}
|
||||||
XmlPullUtil.exit(pp, "itdSingleTicket");
|
|
||||||
}
|
}
|
||||||
|
XmlPullUtil.exit(pp, "itdFare");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
XmlPullUtil.next(pp);
|
||||||
}
|
}
|
||||||
XmlPullUtil.exit(pp, "itdFare");
|
|
||||||
}
|
}
|
||||||
connections.add(new Connection(id, firstDeparture, lastArrival, parts, fares.isEmpty() ? null : fares, null, numChanges));
|
connections.add(new Connection(id, firstDeparture, lastArrival, parts, fares.isEmpty() ? null : fares, null, numChanges));
|
||||||
XmlPullUtil.exit(pp, "itdRoute");
|
XmlPullUtil.exit(pp, "itdRoute");
|
||||||
|
@ -2270,6 +2295,10 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
||||||
value = value.trim();
|
value = value.trim();
|
||||||
XmlPullUtil.exit(pp, "value");
|
XmlPullUtil.exit(pp, "value");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
XmlPullUtil.next(pp);
|
||||||
|
}
|
||||||
|
|
||||||
if (key.equals("FOR_RIDER"))
|
if (key.equals("FOR_RIDER"))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue