mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-18 00:09:55 +00:00
fixed parsing dependency on links
git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@19 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
parent
dc788b9985
commit
b53b0bc01b
2 changed files with 56 additions and 3 deletions
|
@ -332,11 +332,11 @@ public class MvvProvider implements NetworkProvider
|
||||||
private static final Pattern P_CONNECTION_DETAILS_COARSE = Pattern.compile("<tr bgcolor=\"#(\\w{6})\">(.+?)</tr>.*?"
|
private static final Pattern P_CONNECTION_DETAILS_COARSE = Pattern.compile("<tr bgcolor=\"#(\\w{6})\">(.+?)</tr>.*?"
|
||||||
+ "<tr bgcolor=\"#\\1\">(.+?)</tr>.*?" //
|
+ "<tr bgcolor=\"#\\1\">(.+?)</tr>.*?" //
|
||||||
+ "<tr bgcolor=\"#\\1\">(.+?)</tr>", Pattern.DOTALL);
|
+ "<tr bgcolor=\"#\\1\">(.+?)</tr>", Pattern.DOTALL);
|
||||||
private static final Pattern P_CONNECTION_DETAILS_FINE = Pattern.compile(".*?(?:" //
|
static final Pattern P_CONNECTION_DETAILS_FINE = Pattern.compile(".*?(?:" //
|
||||||
+ "ab (\\d+:\\d+)\\s+(.*?)\\s*<a.*?" //
|
+ "ab (\\d+:\\d+)\\s+(.*?)\\s*<.*?" //
|
||||||
+ "<img src=\"images/means.*?\" alt=\"(.*?)\" />.*?" //
|
+ "<img src=\"images/means.*?\" alt=\"(.*?)\" />.*?" //
|
||||||
+ "<td>\\s*(.*?)\\s*<br />Richtung\\s*(.*?)\\s*</td>.*?" //
|
+ "<td>\\s*(.*?)\\s*<br />Richtung\\s*(.*?)\\s*</td>.*?" //
|
||||||
+ "an (\\d+:\\d+)\\s+(.*?)\\s*<a" //
|
+ "an (\\d+:\\d+)\\s+(.*?)\\s*<" //
|
||||||
+ "|" //
|
+ "|" //
|
||||||
+ "ab\\s+(.*?)\\s*<a.*?" //
|
+ "ab\\s+(.*?)\\s*<a.*?" //
|
||||||
+ "Fußweg[\\xa0\\s]+\\(ca\\.[\\xa0\\s]+(\\d+)[\\xa0\\s]+Minute.*?" //
|
+ "Fußweg[\\xa0\\s]+\\(ca\\.[\\xa0\\s]+(\\d+)[\\xa0\\s]+Minute.*?" //
|
||||||
|
|
53
test/de/schildbach/pte/MvvProviderTest.java
Normal file
53
test/de/schildbach/pte/MvvProviderTest.java
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2010 the original author or authors.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.schildbach.pte;
|
||||||
|
|
||||||
|
import static junit.framework.Assert.assertTrue;
|
||||||
|
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Andreas Schildbach
|
||||||
|
*/
|
||||||
|
public class MvvProviderTest
|
||||||
|
{
|
||||||
|
@Test
|
||||||
|
public void trip()
|
||||||
|
{
|
||||||
|
assertFineConnectionDetails("\n" + "<td colspan=\"4\">ab 04:27 Machern (Sachs) Gleis 2<br />\n" //
|
||||||
|
+ "</td>\n" //
|
||||||
|
+ "\n" //
|
||||||
|
+ "<td width=\"15\" valign=\"middle\">\n" //
|
||||||
|
+ "<img src=\"images/means/zug.gif\" alt=\"Zug\" />\n" //
|
||||||
|
+ "</td>\n" //
|
||||||
|
+ "<td width=\"1\" valign=\"middle\" />\n" //
|
||||||
|
+ "<td>MRB 88040 Mitteldeutsche Regiobahn <br />Richtung Leipzig Hbf</td>\n" //
|
||||||
|
+ "<td width=\"1\"> </td>\n" //
|
||||||
|
+ "\n" //
|
||||||
|
+ "<td colspan=\"4\">an 04:47 Leipzig Hbf Gleis 19</td>\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertFineConnectionDetails(String s)
|
||||||
|
{
|
||||||
|
Matcher m = MvvProvider.P_CONNECTION_DETAILS_FINE.matcher(s);
|
||||||
|
assertTrue(m.matches());
|
||||||
|
// ParserUtils.printGroups(m);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue