parse 'server down' message

git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@198 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
andreas.schildbach 2010-09-25 17:48:00 +00:00
parent f042c80877
commit 78012f5ebd

View file

@ -166,9 +166,12 @@ public class LinzProvider implements NetworkProvider
} }
private static final Pattern P_DEPARTURES_HEAD_COARSE = Pattern.compile(".*?" // private static final Pattern P_DEPARTURES_HEAD_COARSE = Pattern.compile(".*?" //
+ "(?:" //
+ "<itdOdv type=\"stop\" usage=\"dm\">(.*?)</itdOdv>.*?" // head + "<itdOdv type=\"stop\" usage=\"dm\">(.*?)</itdOdv>.*?" // head
+ "(?:<itdDepartureList>(.*?)</itdDepartureList>.*?)?" // departures + "(?:<itdDepartureList>(.*?)</itdDepartureList>.*?)?" // departures
// TODO messages + "|" //
+ "(Server-Wartung).*?" // messages
+ ")" //
, Pattern.DOTALL); , Pattern.DOTALL);
private static final Pattern P_DEPARTURES_HEAD_FINE = Pattern.compile(".*?" // private static final Pattern P_DEPARTURES_HEAD_FINE = Pattern.compile(".*?" //
+ "<odvNameElem .*? stopID=\"(\\d+)\" [^>]*>" // locationId + "<odvNameElem .*? stopID=\"(\\d+)\" [^>]*>" // locationId
@ -182,7 +185,7 @@ public class LinzProvider implements NetworkProvider
+ ".*?" // + ".*?" //
+ "<itdServingLine [^>]* number=\"([^<]*)\" symbol=\"([^<]*)\" motType=\"(\\d+)\" " // line, symbol, type + "<itdServingLine [^>]* number=\"([^<]*)\" symbol=\"([^<]*)\" motType=\"(\\d+)\" " // line, symbol, type
+ "realtime=\"(\\d+)\" " // realtime + "realtime=\"(\\d+)\" " // realtime
+ "direction=\"([^<]*)\" destID=\"(\\d+)\"" // destination, destinationId + "direction=\"([^\"]*)\" destID=\"(\\d+)\"" // destination, destinationId
+ ".*?" // + ".*?" //
, Pattern.DOTALL); , Pattern.DOTALL);
@ -194,6 +197,9 @@ public class LinzProvider implements NetworkProvider
final Matcher mHeadCoarse = P_DEPARTURES_HEAD_COARSE.matcher(page); final Matcher mHeadCoarse = P_DEPARTURES_HEAD_COARSE.matcher(page);
if (mHeadCoarse.matches()) if (mHeadCoarse.matches())
{ {
if (mHeadCoarse.group(3) != null)
return new QueryDeparturesResult(uri, QueryDeparturesResult.Status.SERVICE_DOWN);
final String headerText = mHeadCoarse.group(1); final String headerText = mHeadCoarse.group(1);
final String departuresText = mHeadCoarse.group(2); final String departuresText = mHeadCoarse.group(2);
@ -227,8 +233,8 @@ public class LinzProvider implements NetworkProvider
final int destinationId = Integer.parseInt(mDepFine.group(13)); final int destinationId = Integer.parseInt(mDepFine.group(13));
departures.add(new Departure(!isRealtime ? departureDate : null, isRealtime ? departureDate : null, line, departures.add(new Departure(!isRealtime ? departureDate : null, isRealtime ? departureDate : null, line, LINES
line != null ? LINES.get(line.charAt(0)) : null, null, position, destinationId, destination, null)); .get(line.charAt(0)), null, position, destinationId, destination, null));
} }
} }
else else