try to detect IO problems and throw IOException in case

git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@312 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
andreas.schildbach 2010-10-19 19:13:50 +00:00
parent 98ceed52f8
commit c84b8fdbaa
6 changed files with 29 additions and 9 deletions

View file

@ -146,7 +146,7 @@ public abstract class AbstractHafasProvider implements NetworkProvider
final XmlPullParser pp = factory.newPullParser();
pp.setInput(is, DEFAULT_ENCODING);
XmlPullUtil.jump(pp, "ResC");
assertResC(pp);
XmlPullUtil.enter(pp);
XmlPullUtil.require(pp, "LocValRes");
@ -245,7 +245,10 @@ public abstract class AbstractHafasProvider implements NetworkProvider
final XmlPullParser pp = factory.newPullParser();
pp.setInput(is, DEFAULT_ENCODING);
XmlPullUtil.jump(pp, "ConRes");
assertResC(pp);
XmlPullUtil.enter(pp);
XmlPullUtil.require(pp, "ConRes");
XmlPullUtil.enter(pp);
if (pp.getName().equals("Err"))
{
@ -876,4 +879,10 @@ public abstract class AbstractHafasProvider implements NetworkProvider
{
return LINES.get(line.charAt(0));
}
private void assertResC(final XmlPullParser pp) throws XmlPullParserException, IOException
{
if (!XmlPullUtil.jumpToStartTag(pp, null, "ResC"))
throw new IOException("cannot find <ResC />");
}
}