mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-20 09:19:57 +00:00
moved product filter from network providers to task
git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@10 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
parent
d416fd35b0
commit
0388466320
5 changed files with 11 additions and 49 deletions
|
@ -414,7 +414,7 @@ public final class BahnProvider implements NetworkProvider
|
|||
private static final Pattern P_DEPARTURES_FINE = Pattern.compile(".*?<span class=\"bold\">(.*?)</span>.*?"
|
||||
+ ">>\\n?\\s*(.+?)\\s*\\n?<br />\\n?<span class=\"bold\">(\\d+:\\d+)</span>.*?", Pattern.DOTALL);
|
||||
|
||||
public QueryDeparturesResult queryDepartures(final String uri, final Product[] products, final int maxDepartures) throws IOException
|
||||
public QueryDeparturesResult queryDepartures(final String uri, final int maxDepartures) throws IOException
|
||||
{
|
||||
final CharSequence page = ParserUtils.scrape(uri);
|
||||
|
||||
|
@ -434,9 +434,8 @@ public final class BahnProvider implements NetworkProvider
|
|||
if (mDepFine.matches())
|
||||
{
|
||||
final Departure dep = parseDeparture(mDepFine, currentTime);
|
||||
if (products == null || filter(dep.line.charAt(0), products))
|
||||
if (!departures.contains(dep))
|
||||
departures.add(dep);
|
||||
if (!departures.contains(dep))
|
||||
departures.add(dep);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -477,17 +476,6 @@ public final class BahnProvider implements NetworkProvider
|
|||
return new Departure(parsed.getTime(), line, lineColors, destination);
|
||||
}
|
||||
|
||||
private boolean filter(final char line, final Product[] products)
|
||||
{
|
||||
final Product lineProduct = Product.fromCode(line);
|
||||
|
||||
for (final Product p : products)
|
||||
if (lineProduct == p)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static final Pattern P_NORMALIZE_LINE = Pattern.compile("([A-Za-zÄÖÜäöüß]+)[\\s-]*(.*)");
|
||||
private static final Pattern P_NORMALIZE_LINE_SBAHN = Pattern.compile("S\\w*\\d+");
|
||||
private static final Pattern P_NORMALIZE_LINE_NUMBER = Pattern.compile("\\d{4,5}");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue