separate Line class for lines without destination

git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@524 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
andreas.schildbach@gmail.com 2011-03-06 10:40:11 +00:00
parent 11154da61f
commit 4da349339d
8 changed files with 90 additions and 15 deletions

View file

@ -42,6 +42,7 @@ import de.schildbach.pte.dto.Departure;
import de.schildbach.pte.dto.Fare;
import de.schildbach.pte.dto.Fare.Type;
import de.schildbach.pte.dto.GetConnectionDetailsResult;
import de.schildbach.pte.dto.Line;
import de.schildbach.pte.dto.LineDestination;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
@ -903,8 +904,8 @@ public abstract class AbstractEfaProvider implements NetworkProvider
{
final Location assignedLocation = processItdOdvAssignedStop(pp);
if (findStationDepartures(result.stationDepartures, assignedLocation.id) == null)
result.stationDepartures
.add(new StationDepartures(assignedLocation, new LinkedList<Departure>(), new LinkedList<LineDestination>()));
result.stationDepartures.add(new StationDepartures(assignedLocation, new LinkedList<Departure>(),
new LinkedList<LineDestination>()));
}
XmlPullUtil.exit(pp, "itdOdvAssignedStops");
}
@ -1355,12 +1356,13 @@ public abstract class AbstractEfaProvider implements NetworkProvider
final Location destination = destinationIdStr.length() > 0 ? new Location(LocationType.STATION,
Integer.parseInt(destinationIdStr), null, destinationName) : new Location(LocationType.ANY, 0, null,
destinationName);
String line;
final String lineStr;
if ("AST".equals(pp.getAttributeValue(null, "symbol")))
line = "BAST";
lineStr = "BAST";
else
line = parseLine(pp.getAttributeValue(null, "motType"), pp.getAttributeValue(null, "shortname"),
lineStr = parseLine(pp.getAttributeValue(null, "motType"), pp.getAttributeValue(null, "shortname"),
pp.getAttributeValue(null, "name"), null);
final Line line = new Line(lineStr, lineColors(lineStr));
XmlPullUtil.enter(pp, "itdMeansOfTransport");
XmlPullUtil.exit(pp, "itdMeansOfTransport");

View file

@ -38,6 +38,7 @@ import org.xmlpull.v1.XmlPullParserFactory;
import de.schildbach.pte.dto.Connection;
import de.schildbach.pte.dto.GetConnectionDetailsResult;
import de.schildbach.pte.dto.Line;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyStationsResult;
@ -365,7 +366,7 @@ public abstract class AbstractHafasProvider implements NetworkProvider
XmlPullUtil.exit(pp);
// journey
String line = null;
final Line line;
Location destination = null;
int min = 0;
@ -406,7 +407,8 @@ public abstract class AbstractHafasProvider implements NetworkProvider
XmlPullUtil.exit(pp);
XmlPullUtil.exit(pp);
line = _normalizeLine(category, name, longCategory);
final String lineStr = _normalizeLine(category, name, longCategory);
line = new Line(lineStr, lineColors(lineStr));
}
else if (tag.equals("Walk") || tag.equals("Transfer") || tag.equals("GisRoute"))
{
@ -416,6 +418,8 @@ public abstract class AbstractHafasProvider implements NetworkProvider
min = parseDuration(XmlPullUtil.text(pp).substring(3, 8));
XmlPullUtil.exit(pp);
XmlPullUtil.exit(pp);
line = null;
}
else
{

View file

@ -32,6 +32,7 @@ import java.util.regex.Pattern;
import de.schildbach.pte.dto.Connection;
import de.schildbach.pte.dto.Departure;
import de.schildbach.pte.dto.GetConnectionDetailsResult;
import de.schildbach.pte.dto.Line;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyStationsResult;
@ -349,7 +350,8 @@ public final class BahnProvider extends AbstractHafasProvider
if (mDetFine.group(2) != null)
{
final String line = normalizeLine(ParserUtils.resolveEntities(mDetFine.group(2)));
final String lineStr = normalizeLine(ParserUtils.resolveEntities(mDetFine.group(2)));
final Line line = new Line(lineStr, lineColors(lineStr));
final Date departureTime = ParserUtils.parseTime(mDetFine.group(3));

View file

@ -34,6 +34,7 @@ import java.util.regex.Pattern;
import de.schildbach.pte.dto.Connection;
import de.schildbach.pte.dto.Departure;
import de.schildbach.pte.dto.GetConnectionDetailsResult;
import de.schildbach.pte.dto.Line;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyStationsResult;
@ -502,7 +503,8 @@ public final class BvgProvider extends AbstractHafasProvider
final String departurePosition = mDetFine.group(7);
final String line = normalizeLine(ParserUtils.resolveEntities(mDetFine.group(8)));
final String lineStr = normalizeLine(ParserUtils.resolveEntities(mDetFine.group(8)));
final Line line = new Line(lineStr, lineColors(lineStr));
final String[] destinationPlaceAndName = splitNameAndPlace(ParserUtils.resolveEntities(mDetFine.group(9)));

View file

@ -35,6 +35,7 @@ import org.json.JSONObject;
import de.schildbach.pte.dto.Connection;
import de.schildbach.pte.dto.Departure;
import de.schildbach.pte.dto.GetConnectionDetailsResult;
import de.schildbach.pte.dto.Line;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.QueryConnectionsResult;
@ -455,7 +456,8 @@ public class OebbProvider extends AbstractHafasProvider
final String departurePosition = mDetFine.group(5) != null ? ParserUtils.resolveEntities(mDetFine.group(5)) : null;
final String line = normalizeLine(lineType, ParserUtils.resolveEntities(mDetFine.group(7)));
final String lineStr = normalizeLine(lineType, ParserUtils.resolveEntities(mDetFine.group(7)));
final Line line = new Line(lineStr, lineColors(lineStr));
if (arrivalId == 0)
throw new IllegalStateException("arrivalId");

View file

@ -33,6 +33,7 @@ import java.util.regex.Pattern;
import de.schildbach.pte.dto.Connection;
import de.schildbach.pte.dto.Departure;
import de.schildbach.pte.dto.GetConnectionDetailsResult;
import de.schildbach.pte.dto.Line;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.QueryConnectionsResult;
@ -358,7 +359,8 @@ public class RmvProvider extends AbstractHafasProvider
final String min = mDetFine.group(7);
if (min == null)
{
final String line = normalizeLine(ParserUtils.resolveEntities(mDetFine.group(1)));
final String lineStr = normalizeLine(ParserUtils.resolveEntities(mDetFine.group(1)));
final Line line = new Line(lineStr, lineColors(lineStr));
final Location destination = new Location(LocationType.ANY, 0, null, ParserUtils.resolveEntities(mDetFine.group(2)));

View file

@ -89,7 +89,7 @@ public final class Connection implements Serializable
public final static class Trip extends Part
{
public final String line;
public final Line line;
public final Location destination;
public final Date departureTime;
public final String departurePosition;
@ -97,9 +97,9 @@ public final class Connection implements Serializable
public final String arrivalPosition;
public final List<Stop> intermediateStops;
public Trip(final String line, final Location destination, final Date departureTime, final String departurePosition,
final Location departure, final Date arrivalTime, final String arrivalPosition, final Location arrival,
final List<Stop> intermediateStops, final List<Point> path)
public Trip(final Line line, final Location destination, final Date departureTime, final String departurePosition, final Location departure,
final Date arrivalTime, final String arrivalPosition, final Location arrival, final List<Stop> intermediateStops,
final List<Point> path)
{
super(departure, arrival, path);

View file

@ -0,0 +1,61 @@
/*
* 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.dto;
import java.io.Serializable;
/**
* @author Andreas Schildbach
*/
public final class Line implements Serializable
{
final public String label;
final public int[] colors;
public Line(final String label, final int[] colors)
{
this.label = label;
this.colors = colors;
}
@Override
public String toString()
{
final StringBuilder builder = new StringBuilder("Line(");
builder.append(label);
builder.append(")");
return builder.toString();
}
@Override
public boolean equals(final Object o)
{
if (o == this)
return true;
if (!(o instanceof Line))
return false;
final Line other = (Line) o;
return (this.label.equals(other.label));
}
@Override
public int hashCode()
{
return label.hashCode();
}
}