use Line dto consistently

git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@700 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
andreas.schildbach@gmail.com 2011-06-15 14:56:32 +00:00
parent 4a73175244
commit 36185b840c
16 changed files with 84 additions and 113 deletions

View file

@ -1112,8 +1112,7 @@ public abstract class AbstractEfaProvider implements NetworkProvider
final String destinationIdStr = pp.getAttributeValue(null, "destID"); final String destinationIdStr = pp.getAttributeValue(null, "destID");
final int destinationId = destinationIdStr.length() > 0 ? Integer.parseInt(destinationIdStr) : 0; final int destinationId = destinationIdStr.length() > 0 ? Integer.parseInt(destinationIdStr) : 0;
final String lineStr = processItdServingLine(pp); final LineDestination line = new LineDestination(processItdServingLine(pp), destinationId, destination);
final LineDestination line = new LineDestination(lineStr, lineColors(lineStr), destinationId, destination);
StationDepartures assignedStationDepartures; StationDepartures assignedStationDepartures;
if (assignedStopId == 0) if (assignedStopId == 0)
@ -1177,14 +1176,14 @@ public abstract class AbstractEfaProvider implements NetworkProvider
final String destination = normalizeLocationName(pp.getAttributeValue(null, "direction")); final String destination = normalizeLocationName(pp.getAttributeValue(null, "direction"));
final int destinationId = Integer.parseInt(pp.getAttributeValue(null, "destID")); final int destinationId = Integer.parseInt(pp.getAttributeValue(null, "destID"));
final String line = processItdServingLine(pp); final Line line = processItdServingLine(pp);
if (isRealtime && !predictedDepartureTime.isSet(Calendar.HOUR_OF_DAY)) if (isRealtime && !predictedDepartureTime.isSet(Calendar.HOUR_OF_DAY))
predictedDepartureTime.setTimeInMillis(plannedDepartureTime.getTimeInMillis()); predictedDepartureTime.setTimeInMillis(plannedDepartureTime.getTimeInMillis());
final Departure departure = new Departure(plannedDepartureTime.getTime(), final Departure departure = new Departure(plannedDepartureTime.getTime(),
predictedDepartureTime.isSet(Calendar.HOUR_OF_DAY) ? predictedDepartureTime.getTime() : null, line, lineColors(line), predictedDepartureTime.isSet(Calendar.HOUR_OF_DAY) ? predictedDepartureTime.getTime() : null, line, position,
null, position, destinationId, destination, null, null); destinationId, destination, null, null);
assignedStationDepartures.departures.add(departure); assignedStationDepartures.departures.add(departure);
XmlPullUtil.exit(pp, "itdDeparture"); XmlPullUtil.exit(pp, "itdDeparture");
@ -1224,6 +1223,30 @@ public abstract class AbstractEfaProvider implements NetworkProvider
return null; return null;
} }
private Location processItdPointAttributes(final XmlPullParser pp)
{
final int id = Integer.parseInt(pp.getAttributeValue(null, "stopID"));
final String place = normalizeLocationName(pp.getAttributeValue(null, "locality"));
String name = normalizeLocationName(pp.getAttributeValue(null, "nameWO"));
if (name == null)
name = normalizeLocationName(pp.getAttributeValue(null, "name"));
final int lat, lon;
if ("WGS84".equals(pp.getAttributeValue(null, "mapName")))
{
lat = Integer.parseInt(pp.getAttributeValue(null, "y"));
lon = Integer.parseInt(pp.getAttributeValue(null, "x"));
}
else
{
lat = 0;
lon = 0;
}
return new Location(LocationType.STATION, id, lat, lon, place, name);
}
private boolean processItdDateTime(final XmlPullParser pp, final Calendar calendar) throws XmlPullParserException, IOException private boolean processItdDateTime(final XmlPullParser pp, final Calendar calendar) throws XmlPullParserException, IOException
{ {
XmlPullUtil.enter(pp); XmlPullUtil.enter(pp);
@ -1261,11 +1284,12 @@ public abstract class AbstractEfaProvider implements NetworkProvider
XmlPullUtil.next(pp); XmlPullUtil.next(pp);
} }
private String processItdServingLine(final XmlPullParser pp) throws XmlPullParserException, IOException private Line processItdServingLine(final XmlPullParser pp) throws XmlPullParserException, IOException
{ {
XmlPullUtil.require(pp, "itdServingLine"); XmlPullUtil.require(pp, "itdServingLine");
final String motType = pp.getAttributeValue(null, "motType"); final String motType = pp.getAttributeValue(null, "motType");
final String number = pp.getAttributeValue(null, "number"); final String number = pp.getAttributeValue(null, "number");
final String id = pp.getAttributeValue(null, "stateless");
XmlPullUtil.enter(pp, "itdServingLine"); XmlPullUtil.enter(pp, "itdServingLine");
String noTrainName = null; String noTrainName = null;
@ -1273,7 +1297,8 @@ public abstract class AbstractEfaProvider implements NetworkProvider
noTrainName = pp.getAttributeValue(null, "name"); noTrainName = pp.getAttributeValue(null, "name");
XmlPullUtil.exit(pp, "itdServingLine"); XmlPullUtil.exit(pp, "itdServingLine");
return parseLine(motType, number, number, noTrainName); final String label = parseLine(motType, number, number, noTrainName);
return new Line(id, label, lineColors(label));
} }
private static final Pattern P_STATION_NAME_WHITESPACE = Pattern.compile("\\s+"); private static final Pattern P_STATION_NAME_WHITESPACE = Pattern.compile("\\s+");
@ -1565,24 +1590,7 @@ public abstract class AbstractEfaProvider implements NetworkProvider
XmlPullUtil.test(pp, "itdPoint"); XmlPullUtil.test(pp, "itdPoint");
if (!"departure".equals(pp.getAttributeValue(null, "usage"))) if (!"departure".equals(pp.getAttributeValue(null, "usage")))
throw new IllegalStateException(); throw new IllegalStateException();
final int departureId = Integer.parseInt(pp.getAttributeValue(null, "stopID")); final Location departure = processItdPointAttributes(pp);
final String departurePlace = normalizeLocationName(pp.getAttributeValue(null, "locality"));
String departureName = normalizeLocationName(pp.getAttributeValue(null, "nameWO"));
if (departureName == null)
departureName = normalizeLocationName(pp.getAttributeValue(null, "name"));
final int departureLat, departureLon;
if ("WGS84".equals(pp.getAttributeValue(null, "mapName")))
{
departureLat = Integer.parseInt(pp.getAttributeValue(null, "y"));
departureLon = Integer.parseInt(pp.getAttributeValue(null, "x"));
}
else
{
departureLat = 0;
departureLon = 0;
}
final Location departure = new Location(LocationType.STATION, departureId, departureLat, departureLon, departurePlace,
departureName);
if (firstDeparture == null) if (firstDeparture == null)
firstDeparture = departure; firstDeparture = departure;
final String departurePosition = normalizePlatform(pp.getAttributeValue(null, "platform"), final String departurePosition = normalizePlatform(pp.getAttributeValue(null, "platform"),
@ -1610,23 +1618,7 @@ public abstract class AbstractEfaProvider implements NetworkProvider
XmlPullUtil.test(pp, "itdPoint"); XmlPullUtil.test(pp, "itdPoint");
if (!"arrival".equals(pp.getAttributeValue(null, "usage"))) if (!"arrival".equals(pp.getAttributeValue(null, "usage")))
throw new IllegalStateException(); throw new IllegalStateException();
final int arrivalId = Integer.parseInt(pp.getAttributeValue(null, "stopID")); final Location arrival = processItdPointAttributes(pp);
final String arrivalPlace = normalizeLocationName(pp.getAttributeValue(null, "locality"));
String arrivalName = normalizeLocationName(pp.getAttributeValue(null, "nameWO"));
if (arrivalName == null)
arrivalName = normalizeLocationName(pp.getAttributeValue(null, "name"));
final int arrivalLat, arrivalLon;
if ("WGS84".equals(pp.getAttributeValue(null, "mapName")))
{
arrivalLat = Integer.parseInt(pp.getAttributeValue(null, "y"));
arrivalLon = Integer.parseInt(pp.getAttributeValue(null, "x"));
}
else
{
arrivalLat = 0;
arrivalLon = 0;
}
final Location arrival = new Location(LocationType.STATION, arrivalId, arrivalLat, arrivalLon, arrivalPlace, arrivalName);
lastArrival = arrival; lastArrival = arrival;
final String arrivalPosition = normalizePlatform(pp.getAttributeValue(null, "platform"), final String arrivalPosition = normalizePlatform(pp.getAttributeValue(null, "platform"),
pp.getAttributeValue(null, "platformName")); pp.getAttributeValue(null, "platformName"));
@ -1699,7 +1691,7 @@ public abstract class AbstractEfaProvider implements NetworkProvider
else else
lineStr = parseLine(pp.getAttributeValue(null, "motType"), pp.getAttributeValue(null, "shortname"), lineStr = parseLine(pp.getAttributeValue(null, "motType"), pp.getAttributeValue(null, "shortname"),
pp.getAttributeValue(null, "name"), null); pp.getAttributeValue(null, "name"), null);
final Line line = new Line(lineStr, lineColors(lineStr)); final Line line = new Line(null, lineStr, lineColors(lineStr));
XmlPullUtil.enter(pp, "itdMeansOfTransport"); XmlPullUtil.enter(pp, "itdMeansOfTransport");
XmlPullUtil.exit(pp, "itdMeansOfTransport"); XmlPullUtil.exit(pp, "itdMeansOfTransport");
@ -1720,19 +1712,7 @@ public abstract class AbstractEfaProvider implements NetworkProvider
intermediateStops = new LinkedList<Stop>(); intermediateStops = new LinkedList<Stop>();
while (XmlPullUtil.test(pp, "itdPoint")) while (XmlPullUtil.test(pp, "itdPoint"))
{ {
final int stopId = Integer.parseInt(pp.getAttributeValue(null, "stopID")); final Location stopLocation = processItdPointAttributes(pp);
final String stopName = normalizeLocationName(pp.getAttributeValue(null, "name"));
final int stopLat, stopLon;
if ("WGS84".equals(pp.getAttributeValue(null, "mapName")))
{
stopLat = Integer.parseInt(pp.getAttributeValue(null, "y"));
stopLon = Integer.parseInt(pp.getAttributeValue(null, "x"));
}
else
{
stopLat = 0;
stopLon = 0;
}
final String stopPosition = normalizePlatform(pp.getAttributeValue(null, "platform"), final String stopPosition = normalizePlatform(pp.getAttributeValue(null, "platform"),
pp.getAttributeValue(null, "platformName")); pp.getAttributeValue(null, "platformName"));
XmlPullUtil.enter(pp, "itdPoint"); XmlPullUtil.enter(pp, "itdPoint");
@ -1742,8 +1722,7 @@ public abstract class AbstractEfaProvider implements NetworkProvider
XmlPullUtil.exit(pp, "itdPoint"); XmlPullUtil.exit(pp, "itdPoint");
if (success1 || success2) if (success1 || success2)
intermediateStops.add(new Stop(new Location(LocationType.STATION, stopId, stopLat, stopLon, null, stopName), intermediateStops.add(new Stop(stopLocation, stopPosition, time.getTime()));
stopPosition, time.getTime()));
} }
XmlPullUtil.exit(pp, "itdStopSeq"); XmlPullUtil.exit(pp, "itdStopSeq");
@ -1751,11 +1730,11 @@ public abstract class AbstractEfaProvider implements NetworkProvider
final int size = intermediateStops.size(); final int size = intermediateStops.size();
if (size >= 2) if (size >= 2)
{ {
if (intermediateStops.get(size - 1).location.id != arrivalId) if (intermediateStops.get(size - 1).location.id != arrival.id)
throw new IllegalStateException(); throw new IllegalStateException();
intermediateStops.remove(size - 1); intermediateStops.remove(size - 1);
if (intermediateStops.get(0).location.id != departureId) if (intermediateStops.get(0).location.id != departure.id)
throw new IllegalStateException(); throw new IllegalStateException();
intermediateStops.remove(0); intermediateStops.remove(0);
} }

View file

@ -558,8 +558,8 @@ public abstract class AbstractHafasProvider implements NetworkProvider
message = null; message = null;
} }
departures.add(new Departure(plannedTime.getTime(), predictedTime != null ? predictedTime.getTime() : null, line, departures.add(new Departure(plannedTime.getTime(), predictedTime != null ? predictedTime.getTime() : null, new Line(null, line,
line != null ? lineColors(line) : null, null, position, destinationId, destination, capacity, message)); line != null ? lineColors(line) : null), position, destinationId, destination, capacity, message));
} }
} }
else else
@ -873,7 +873,7 @@ public abstract class AbstractHafasProvider implements NetworkProvider
category = shortCategory; category = shortCategory;
final String lineStr = normalizeLine(category, name); final String lineStr = normalizeLine(category, name);
line = new Line(lineStr, lineColors(lineStr)); line = new Line(null, lineStr, lineColors(lineStr));
} }
else if (tag.equals("Walk") || tag.equals("Transfer") || tag.equals("GisRoute")) else if (tag.equals("Walk") || tag.equals("Transfer") || tag.equals("GisRoute"))
{ {

View file

@ -420,7 +420,7 @@ public final class BahnProvider extends AbstractHafasProvider
if (mDetFine.group(2) != null) if (mDetFine.group(2) != null)
{ {
final String lineStr = normalizeLine(ParserUtils.resolveEntities(mDetFine.group(2))); final String lineStr = normalizeLine(ParserUtils.resolveEntities(mDetFine.group(2)));
final Line line = new Line(lineStr, lineColors(lineStr)); final Line line = new Line(null, lineStr, lineColors(lineStr));
final Calendar departureTime = new GregorianCalendar(timeZone()); final Calendar departureTime = new GregorianCalendar(timeZone());
departureTime.clear(); departureTime.clear();

View file

@ -321,8 +321,8 @@ public final class BvgProvider extends AbstractHafasProvider
final String destination = ParserUtils.resolveEntities(mDepFine.group(4)); final String destination = ParserUtils.resolveEntities(mDepFine.group(4));
final Departure dep = new Departure(plannedTime, predictedTime, line, line != null ? lineColors(line) : null, null, position, final Departure dep = new Departure(plannedTime, predictedTime, new Line(null, line, line != null ? lineColors(line) : null),
destinationId, destination, null, messages.get(line)); position, destinationId, destination, null, messages.get(line));
if (!departures.contains(dep)) if (!departures.contains(dep))
departures.add(dep); departures.add(dep);
} }
@ -391,8 +391,8 @@ public final class BvgProvider extends AbstractHafasProvider
final String destination = ParserUtils.resolveEntities(mDepFine.group(5)); final String destination = ParserUtils.resolveEntities(mDepFine.group(5));
final Departure dep = new Departure(plannedTime, null, line, line != null ? lineColors(line) : null, null, position, final Departure dep = new Departure(plannedTime, null, new Line(null, line, line != null ? lineColors(line) : null),
destinationId, destination, null, null); position, destinationId, destination, null, null);
if (!departures.contains(dep)) if (!departures.contains(dep))
departures.add(dep); departures.add(dep);
} }
@ -831,7 +831,7 @@ public final class BvgProvider extends AbstractHafasProvider
: null; : null;
final String lineStr = normalizeLine(ParserUtils.resolveEntities(tDep[3])); final String lineStr = normalizeLine(ParserUtils.resolveEntities(tDep[3]));
final Line line = new Line(lineStr, lineColors(lineStr)); final Line line = new Line(null, lineStr, lineColors(lineStr));
final Location destination; final Location destination;
if (mDetails.group(3) != null) if (mDetails.group(3) != null)

View file

@ -29,6 +29,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import de.schildbach.pte.dto.Departure; import de.schildbach.pte.dto.Departure;
import de.schildbach.pte.dto.Line;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyStationsResult; import de.schildbach.pte.dto.NearbyStationsResult;
@ -234,8 +235,8 @@ public class InvgProvider extends AbstractHafasProvider
final String position = mDepFine.group(7) != null ? "Gl. " + ParserUtils.resolveEntities(mDepFine.group(7)) : null; final String position = mDepFine.group(7) != null ? "Gl. " + ParserUtils.resolveEntities(mDepFine.group(7)) : null;
final Departure dep = new Departure(plannedTime.getTime(), predictedTime != null ? predictedTime.getTime() : null, line, final Departure dep = new Departure(plannedTime.getTime(), predictedTime != null ? predictedTime.getTime() : null, new Line(
line != null ? lineColors(line) : null, null, position, destinationId, destination, null, null); null, line, line != null ? lineColors(line) : null), position, destinationId, destination, null, null);
if (!departures.contains(dep)) if (!departures.contains(dep))
departures.add(dep); departures.add(dep);

View file

@ -27,6 +27,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import de.schildbach.pte.dto.Departure; import de.schildbach.pte.dto.Departure;
import de.schildbach.pte.dto.Line;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyStationsResult; import de.schildbach.pte.dto.NearbyStationsResult;
@ -211,8 +212,8 @@ public class NasaProvider extends AbstractHafasProvider
final String position = mDepFine.group(7) != null ? "Gl. " + ParserUtils.resolveEntities(mDepFine.group(7)) : null; final String position = mDepFine.group(7) != null ? "Gl. " + ParserUtils.resolveEntities(mDepFine.group(7)) : null;
final Departure dep = new Departure(plannedTime.getTime(), predictedTime != null ? predictedTime.getTime() : null, line, final Departure dep = new Departure(plannedTime.getTime(), predictedTime != null ? predictedTime.getTime() : null, new Line(
line != null ? lineColors(line) : null, null, position, destinationId, destination, null, null); null, line, line != null ? lineColors(line) : null), position, destinationId, destination, null, null);
if (!departures.contains(dep)) if (!departures.contains(dep))
departures.add(dep); departures.add(dep);

View file

@ -26,6 +26,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import de.schildbach.pte.dto.Departure; import de.schildbach.pte.dto.Departure;
import de.schildbach.pte.dto.Line;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyStationsResult; import de.schildbach.pte.dto.NearbyStationsResult;
@ -164,7 +165,8 @@ public class NsProvider extends AbstractHafasProvider
mDepFine.group(4); // TODO delay mDepFine.group(4); // TODO delay
final Departure dep = new Departure(parsedTime.getTime(), line, line != null ? lineColors(line) : null, null, 0, destination); final Departure dep = new Departure(parsedTime.getTime(), null, new Line(null, line, line != null ? lineColors(line) : null),
null, 0, destination, null, null);
if (!departures.contains(dep)) if (!departures.contains(dep))
departures.add(dep); departures.add(dep);

View file

@ -443,7 +443,7 @@ public class OebbProvider extends AbstractHafasProvider
final String departurePosition = mDetFine.group(5) != null ? ParserUtils.resolveEntities(mDetFine.group(5)) : null; final String departurePosition = mDetFine.group(5) != null ? ParserUtils.resolveEntities(mDetFine.group(5)) : null;
final String lineStr = 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)); final Line line = new Line(null, lineStr, lineColors(lineStr));
if (arrivalId == 0) if (arrivalId == 0)
throw new IllegalStateException("arrivalId"); throw new IllegalStateException("arrivalId");

View file

@ -26,6 +26,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import de.schildbach.pte.dto.Departure; import de.schildbach.pte.dto.Departure;
import de.schildbach.pte.dto.Line;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyStationsResult; import de.schildbach.pte.dto.NearbyStationsResult;
@ -219,8 +220,8 @@ public class RmvProvider extends AbstractHafasProvider
final String position = ParserUtils.resolveEntities(ParserUtils.selectNotNull(mDepFine.group(5), mDepFine.group(6))); final String position = ParserUtils.resolveEntities(ParserUtils.selectNotNull(mDepFine.group(5), mDepFine.group(6)));
final Departure dep = new Departure(plannedTime.getTime(), predictedTime != null ? predictedTime.getTime() : null, line, final Departure dep = new Departure(plannedTime.getTime(), predictedTime != null ? predictedTime.getTime() : null, new Line(
line != null ? lineColors(line) : null, null, position, 0, destination, null, null); null, line, line != null ? lineColors(line) : null), position, 0, destination, null, null);
if (!departures.contains(dep)) if (!departures.contains(dep))
departures.add(dep); departures.add(dep);

View file

@ -28,6 +28,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import de.schildbach.pte.dto.Departure; import de.schildbach.pte.dto.Departure;
import de.schildbach.pte.dto.Line;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyStationsResult; import de.schildbach.pte.dto.NearbyStationsResult;
@ -231,8 +232,8 @@ public class SeptaProvider extends AbstractHafasProvider
final String position = mDepFine.group(7) != null ? "Gl. " + ParserUtils.resolveEntities(mDepFine.group(7)) : null; final String position = mDepFine.group(7) != null ? "Gl. " + ParserUtils.resolveEntities(mDepFine.group(7)) : null;
final Departure dep = new Departure(plannedTime.getTime(), predictedTime != null ? predictedTime.getTime() : null, line, final Departure dep = new Departure(plannedTime.getTime(), predictedTime != null ? predictedTime.getTime() : null, new Line(null,
line != null ? lineColors(line) : null, null, position, destinationId, destination, null, null); line, line != null ? lineColors(line) : null), position, destinationId, destination, null, null);
if (!departures.contains(dep)) if (!departures.contains(dep))
departures.add(dep); departures.add(dep);

View file

@ -27,6 +27,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import de.schildbach.pte.dto.Departure; import de.schildbach.pte.dto.Departure;
import de.schildbach.pte.dto.Line;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyStationsResult; import de.schildbach.pte.dto.NearbyStationsResult;
@ -210,8 +211,8 @@ public class ShProvider extends AbstractHafasProvider
final String position = mDepFine.group(7) != null ? "Gl. " + ParserUtils.resolveEntities(mDepFine.group(7)) : null; final String position = mDepFine.group(7) != null ? "Gl. " + ParserUtils.resolveEntities(mDepFine.group(7)) : null;
final Departure dep = new Departure(plannedTime.getTime(), predictedTime != null ? predictedTime.getTime() : null, line, final Departure dep = new Departure(plannedTime.getTime(), predictedTime != null ? predictedTime.getTime() : null, new Line(
line != null ? lineColors(line) : null, null, position, destinationId, destination, null, null); null, line, line != null ? lineColors(line) : null), position, destinationId, destination, null, null);
if (!departures.contains(dep)) if (!departures.contains(dep))
departures.add(dep); departures.add(dep);

View file

@ -26,6 +26,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import de.schildbach.pte.dto.Departure; import de.schildbach.pte.dto.Departure;
import de.schildbach.pte.dto.Line;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyStationsResult; import de.schildbach.pte.dto.NearbyStationsResult;
@ -168,8 +169,8 @@ public class SncbProvider extends AbstractHafasProvider
final String position = mDepFine.group(5); final String position = mDepFine.group(5);
final Departure dep = new Departure(parsedTime.getTime(), line, line != null ? lineColors(line) : null, position, 0, final Departure dep = new Departure(parsedTime.getTime(), null, new Line(null, line, line != null ? lineColors(line) : null),
destination); position, 0, destination, null, null);
if (!departures.contains(dep)) if (!departures.contains(dep))
departures.add(dep); departures.add(dep);

View file

@ -27,6 +27,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import de.schildbach.pte.dto.Departure; import de.schildbach.pte.dto.Departure;
import de.schildbach.pte.dto.Line;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyStationsResult; import de.schildbach.pte.dto.NearbyStationsResult;
@ -222,8 +223,8 @@ public class VgsProvider extends AbstractHafasProvider
final String position = mDepFine.group(7) != null ? "Gl. " + ParserUtils.resolveEntities(mDepFine.group(7)) : null; final String position = mDepFine.group(7) != null ? "Gl. " + ParserUtils.resolveEntities(mDepFine.group(7)) : null;
final Departure dep = new Departure(plannedTime.getTime(), predictedTime != null ? predictedTime.getTime() : null, line, final Departure dep = new Departure(plannedTime.getTime(), predictedTime != null ? predictedTime.getTime() : null, new Line(
line != null ? lineColors(line) : null, null, position, destinationId, destination, null, null); null, line, line != null ? lineColors(line) : null), position, destinationId, destination, null, null);
if (!departures.contains(dep)) if (!departures.contains(dep))
departures.add(dep); departures.add(dep);

View file

@ -26,23 +26,19 @@ public final class Departure
{ {
final public Date plannedTime; final public Date plannedTime;
final public Date predictedTime; final public Date predictedTime;
final public String line; final public Line line;
final public int[] lineColors;
final public String lineLink;
final public String position; final public String position;
final public int destinationId; final public int destinationId;
final public String destination; final public String destination;
final public int[] capacity; final public int[] capacity;
final public String message; final public String message;
public Departure(final Date plannedTime, final Date predictedTime, final String line, final int[] lineColors, final String lineLink, public Departure(final Date plannedTime, final Date predictedTime, final Line line, final String position, final int destinationId,
final String position, final int destinationId, final String destination, final int[] capacity, final String message) final String destination, final int[] capacity, final String message)
{ {
this.plannedTime = plannedTime; this.plannedTime = plannedTime;
this.predictedTime = predictedTime; this.predictedTime = predictedTime;
this.line = line; this.line = line;
this.lineColors = lineColors;
this.lineLink = lineLink;
this.position = position; this.position = position;
this.destinationId = destinationId; this.destinationId = destinationId;
this.destination = destination; this.destination = destination;
@ -50,21 +46,6 @@ public final class Departure
this.message = message; this.message = message;
} }
public Departure(final Date plannedTime, final String line, final int[] lineColors, final String position, final int destinationId,
final String destination)
{
this.plannedTime = plannedTime;
this.predictedTime = null;
this.line = line;
this.lineColors = lineColors;
this.lineLink = null;
this.position = position;
this.destinationId = destinationId;
this.destination = destination;
this.capacity = null;
this.message = null;
}
@Override @Override
public String toString() public String toString()
{ {

View file

@ -24,11 +24,15 @@ import java.io.Serializable;
*/ */
public final class Line implements Serializable public final class Line implements Serializable
{ {
private static final long serialVersionUID = -5642533805998375070L;
final public String id;
final public String label; final public String label;
final public int[] colors; final public int[] colors;
public Line(final String label, final int[] colors) public Line(final String id, final String label, final int[] colors)
{ {
this.id = id;
this.label = label; this.label = label;
this.colors = colors; this.colors = colors;
} }

View file

@ -22,15 +22,13 @@ package de.schildbach.pte.dto;
*/ */
public final class LineDestination public final class LineDestination
{ {
final public String line; final public Line line;
final public int[] lineColors;
final public int destinationId; final public int destinationId;
final public String destination; final public String destination;
public LineDestination(final String line, final int[] lineColors, final int destinationId, final String destination) public LineDestination(final Line line, final int destinationId, final String destination)
{ {
this.line = line; this.line = line;
this.lineColors = lineColors;
this.destinationId = destinationId; this.destinationId = destinationId;
this.destination = destination; this.destination = destination;
} }
@ -38,7 +36,7 @@ public final class LineDestination
@Override @Override
public String toString() public String toString()
{ {
StringBuilder builder = new StringBuilder("Line("); StringBuilder builder = new StringBuilder("LineDestination(");
builder.append(line != null ? line : "null"); builder.append(line != null ? line : "null");
builder.append(","); builder.append(",");
builder.append(destinationId); builder.append(destinationId);