From 297a08e7e7cef5e9c7d598e3153da84386f3747d Mon Sep 17 00:00:00 2001 From: "andreas.schildbach" Date: Mon, 13 Sep 2010 11:22:29 +0000 Subject: [PATCH] fixed could not parse connection overviews with three table rows git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@161 0924bc21-9374-b0fa-ee44-9ff1593b38f0 --- src/de/schildbach/pte/SbbProvider.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/de/schildbach/pte/SbbProvider.java b/src/de/schildbach/pte/SbbProvider.java index 4f3b652d..d8841c4d 100644 --- a/src/de/schildbach/pte/SbbProvider.java +++ b/src/de/schildbach/pte/SbbProvider.java @@ -205,8 +205,9 @@ public class SbbProvider implements NetworkProvider + "(?:(.*?)\n?"// - + "(.+?)", Pattern.DOTALL); + private static final Pattern P_CONNECTIONS_COARSE = Pattern.compile("(.*?)\n"// + + "(.*?)\n"// + + "(?:.*?\n)?", Pattern.DOTALL); private static final Pattern P_CONNECTIONS_FINE = Pattern.compile(".*?" // + "name=\"guiVCtrl_connection_detailsOut_select_([\\w-]+)\".*?" // id + ".., (\\d{2}\\.\\d{2}\\.\\d{2}).*?" // departureDate @@ -248,10 +249,17 @@ public class SbbProvider implements NetworkProvider final String linkEarlier = mHead.group(4) != null ? ParserUtils.resolveEntities(mHead.group(4)) : null; final String linkLater = mHead.group(5) != null ? ParserUtils.resolveEntities(mHead.group(5)) : null; final List connections = new ArrayList(); + String oldZebra = null; final Matcher mConCoarse = P_CONNECTIONS_COARSE.matcher(page); while (mConCoarse.find()) { + final String zebra = mConCoarse.group(1); + if (oldZebra != null && zebra.equals(oldZebra)) + throw new IllegalArgumentException("missed row? last:" + zebra); + else + oldZebra = zebra; + final String set = mConCoarse.group(2) + mConCoarse.group(3); final Matcher mConFine = P_CONNECTIONS_FINE.matcher(set); if (mConFine.matches())