Stricter structure check for Hafas station board.

This commit is contained in:
Andreas Schildbach 2014-08-10 15:27:37 +02:00
parent 0b5ee4ffb7
commit b50dc033fd
15 changed files with 76 additions and 18 deletions

View file

@ -67,6 +67,12 @@ public final class XmlPullUtil
pp.next();
}
public static void exit(final XmlPullParser pp, final String tagName) throws XmlPullParserException, IOException
{
pp.require(XmlPullParser.END_TAG, null, tagName);
pp.next();
}
private static void skipToEnd(final XmlPullParser pp) throws XmlPullParserException, IOException
{
while (pp.getEventType() != XmlPullParser.END_TAG)
@ -244,4 +250,12 @@ public final class XmlPullUtil
return text;
}
public static void requireEndDocument(final XmlPullParser pp) throws XmlPullParserException, IOException
{
skipWhitespace(pp);
if (pp.getEventType() != XmlPullParser.END_DOCUMENT)
throw new IllegalStateException("expecting end of document: " + pp.getPositionDescription());
}
}