mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-16 17:39:49 +00:00
Apply @Nullable annotation to NetworkProvider methods and DTOs.
This commit is contained in:
parent
883015177e
commit
5b3ceed733
45 changed files with 339 additions and 205 deletions
|
@ -23,6 +23,13 @@
|
|||
<version>18.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- javax.annotation.* -->
|
||||
<dependency>
|
||||
<groupId>com.google.code.findbugs</groupId>
|
||||
<artifactId>jsr305</artifactId>
|
||||
<version>3.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package de.schildbach.pte;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -40,6 +41,8 @@ import java.util.concurrent.atomic.AtomicReference;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
@ -93,14 +96,14 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
|||
private final String coordEndpoint;
|
||||
|
||||
private String language = "de";
|
||||
private String additionalQueryParameter = null;
|
||||
private @Nullable String additionalQueryParameter = null;
|
||||
private boolean useRealtime = true;
|
||||
private boolean needsSpEncId = false;
|
||||
private boolean includeRegionId = true;
|
||||
private boolean useProxFootSearch = true;
|
||||
private Charset requestUrlEncoding = Charsets.ISO_8859_1;
|
||||
private String httpReferer = null;
|
||||
private String httpRefererTrip = null;
|
||||
private @Nullable String httpReferer = null;
|
||||
private @Nullable String httpRefererTrip = null;
|
||||
private boolean httpPost = false;
|
||||
private boolean useRouteIndexAsTripId = true;
|
||||
private boolean useLineRestriction = true;
|
||||
|
@ -999,8 +1002,8 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
|||
private static final Pattern P_LINE_S_DB = Pattern.compile("(S\\d+) \\((?:DB Regio AG)\\)");
|
||||
private static final Pattern P_LINE_NUMBER = Pattern.compile("\\d+");
|
||||
|
||||
protected Line parseLine(final String id, final String mot, String symbol, final String name, final String longName, final String trainType,
|
||||
final String trainNum, final String trainName)
|
||||
protected Line parseLine(final @Nullable String id, final @Nullable String mot, @Nullable String symbol, final @Nullable String name,
|
||||
final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName)
|
||||
{
|
||||
if (mot == null)
|
||||
{
|
||||
|
@ -1370,7 +1373,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
|||
return new Line(id, Product.BUS, "SEV" + trainNumStr);
|
||||
if ("Bus replacement".equals(trainName)) // GB
|
||||
return new Line(id, Product.BUS, "BR");
|
||||
if ("BR".equals(trainType) && trainName.startsWith("Bus")) // GB
|
||||
if ("BR".equals(trainType) && trainName != null && trainName.startsWith("Bus")) // GB
|
||||
return new Line(id, Product.BUS, "BR" + trainNum);
|
||||
|
||||
if ("GB".equals(trainType)) // Gondelbahn
|
||||
|
@ -1440,13 +1443,13 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
|||
+ "' trainType='" + trainType + "' trainNum='" + trainNum + "' trainName='" + trainName + "'");
|
||||
}
|
||||
|
||||
public QueryDeparturesResult queryDepartures(final String stationId, final Date time, final int maxDepartures, final boolean equivs)
|
||||
public QueryDeparturesResult queryDepartures(final String stationId, final @Nullable Date time, final int maxDepartures, final boolean equivs)
|
||||
throws IOException
|
||||
{
|
||||
return xsltDepartureMonitorRequest(stationId, time, maxDepartures, equivs);
|
||||
}
|
||||
|
||||
protected StringBuilder xsltDepartureMonitorRequestParameters(final String stationId, final Date time, final int maxDepartures,
|
||||
protected StringBuilder xsltDepartureMonitorRequestParameters(final String stationId, final @Nullable Date time, final int maxDepartures,
|
||||
final boolean equivs)
|
||||
{
|
||||
final StringBuilder parameters = new StringBuilder();
|
||||
|
@ -1482,8 +1485,8 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
|||
uri.append("&itdTime=").append(ParserUtils.urlEncode(String.format(Locale.ENGLISH, "%02d%02d", hour, minute)));
|
||||
}
|
||||
|
||||
private QueryDeparturesResult xsltDepartureMonitorRequest(final String stationId, final Date time, final int maxDepartures, final boolean equivs)
|
||||
throws IOException
|
||||
private QueryDeparturesResult xsltDepartureMonitorRequest(final String stationId, final @Nullable Date time, final int maxDepartures,
|
||||
final boolean equivs) throws IOException
|
||||
{
|
||||
final StringBuilder parameters = xsltDepartureMonitorRequestParameters(stationId, time, maxDepartures, equivs);
|
||||
|
||||
|
@ -1562,8 +1565,9 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
|||
assignedStationDepartures = new StationDepartures(new Location(LocationType.STATION, assignedStopId),
|
||||
new LinkedList<Departure>(), new LinkedList<LineDestination>());
|
||||
|
||||
if (!assignedStationDepartures.lines.contains(line))
|
||||
assignedStationDepartures.lines.add(line);
|
||||
final List<LineDestination> assignedStationDeparturesLines = checkNotNull(assignedStationDepartures.lines);
|
||||
if (!assignedStationDeparturesLines.contains(line))
|
||||
assignedStationDeparturesLines.add(line);
|
||||
}
|
||||
XmlPullUtil.skipExit(pp, "itdServingLines");
|
||||
}
|
||||
|
@ -1646,8 +1650,8 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
|||
}
|
||||
}
|
||||
|
||||
protected QueryDeparturesResult queryDeparturesMobile(final String stationId, final Date time, final int maxDepartures, final boolean equivs)
|
||||
throws IOException
|
||||
protected QueryDeparturesResult queryDeparturesMobile(final String stationId, final @Nullable Date time, final int maxDepartures,
|
||||
final boolean equivs) throws IOException
|
||||
{
|
||||
final StringBuilder parameters = xsltDepartureMonitorRequestParameters(stationId, time, maxDepartures, equivs);
|
||||
|
||||
|
@ -1850,7 +1854,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
|||
private StationDepartures findStationDepartures(final List<StationDepartures> stationDepartures, final String id)
|
||||
{
|
||||
for (final StationDepartures stationDeparture : stationDepartures)
|
||||
if (stationDeparture.location.id.equals(id))
|
||||
if (id.equals(stationDeparture.location.id))
|
||||
return stationDeparture;
|
||||
|
||||
return null;
|
||||
|
@ -1994,8 +1998,9 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
|||
return (double) value / 1000000;
|
||||
}
|
||||
|
||||
protected String xsltTripRequestParameters(final Location from, final Location via, final Location to, final Date time, final boolean dep,
|
||||
final Collection<Product> products, final WalkSpeed walkSpeed, final Accessibility accessibility, final Set<Option> options)
|
||||
protected String xsltTripRequestParameters(final Location from, final @Nullable Location via, final Location to, final Date time,
|
||||
final boolean dep, final @Nullable Collection<Product> products, final @Nullable WalkSpeed walkSpeed,
|
||||
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options)
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder();
|
||||
appendCommonRequestParams(uri, "XML");
|
||||
|
@ -2099,8 +2104,9 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
|||
uri.append("&coordListOutputFormat=STRING");
|
||||
}
|
||||
|
||||
public QueryTripsResult queryTrips(final Location from, final Location via, final Location to, final Date date, final boolean dep,
|
||||
final Set<Product> products, final WalkSpeed walkSpeed, final Accessibility accessibility, final Set<Option> options) throws IOException
|
||||
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to, final Date date, final boolean dep,
|
||||
final @Nullable Set<Product> products, final @Nullable WalkSpeed walkSpeed, final @Nullable Accessibility accessibility,
|
||||
final @Nullable Set<Option> options) throws IOException
|
||||
{
|
||||
|
||||
final String parameters = xsltTripRequestParameters(from, via, to, date, dep, products, walkSpeed, accessibility, options);
|
||||
|
@ -2137,9 +2143,9 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
|||
}
|
||||
}
|
||||
|
||||
protected QueryTripsResult queryTripsMobile(final Location from, final Location via, final Location to, final Date date, final boolean dep,
|
||||
final Collection<Product> products, final WalkSpeed walkSpeed, final Accessibility accessibility, final Set<Option> options)
|
||||
throws IOException
|
||||
protected QueryTripsResult queryTripsMobile(final Location from, final @Nullable Location via, final Location to, final Date date,
|
||||
final boolean dep, final @Nullable Collection<Product> products, final @Nullable WalkSpeed walkSpeed,
|
||||
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException
|
||||
{
|
||||
|
||||
final String parameters = xsltTripRequestParameters(from, via, to, date, dep, products, walkSpeed, accessibility, options);
|
||||
|
@ -2645,11 +2651,11 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
|||
final int size = intermediateStops.size();
|
||||
if (size >= 2)
|
||||
{
|
||||
if (!intermediateStops.get(size - 1).location.id.equals(arrivalLocation.id))
|
||||
if (!intermediateStops.get(size - 1).location.equals(arrivalLocation))
|
||||
throw new IllegalStateException();
|
||||
intermediateStops.remove(size - 1);
|
||||
|
||||
if (!intermediateStops.get(0).location.id.equals(departureLocation.id))
|
||||
if (!intermediateStops.get(0).location.equals(departureLocation))
|
||||
throw new IllegalStateException();
|
||||
intermediateStops.remove(0);
|
||||
}
|
||||
|
@ -2786,8 +2792,8 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
|||
return new QueryTripsResult(header, uri, from, via, to, new Context(commandLink((String) context, requestId)), trips);
|
||||
}
|
||||
|
||||
private QueryTripsResult queryTripsMobile(final String uri, final Location from, final Location via, final Location to, final InputStream is)
|
||||
throws XmlPullParserException, IOException
|
||||
private QueryTripsResult queryTripsMobile(final String uri, final Location from, final @Nullable Location via, final Location to,
|
||||
final InputStream is) throws XmlPullParserException, IOException
|
||||
{
|
||||
// System.out.println(uri);
|
||||
|
||||
|
|
|
@ -42,6 +42,8 @@ import java.util.Set;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
@ -53,6 +55,7 @@ import com.google.common.base.Charsets;
|
|||
|
||||
import de.schildbach.pte.dto.Departure;
|
||||
import de.schildbach.pte.dto.Line;
|
||||
import de.schildbach.pte.dto.Line.Attr;
|
||||
import de.schildbach.pte.dto.Location;
|
||||
import de.schildbach.pte.dto.LocationType;
|
||||
import de.schildbach.pte.dto.NearbyLocationsResult;
|
||||
|
@ -88,14 +91,14 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
protected final String getStopEndpoint;
|
||||
protected final String queryEndpoint;
|
||||
private final int numProductBits;
|
||||
private String accessId;
|
||||
private String clientType;
|
||||
private @Nullable String accessId = null;
|
||||
private @Nullable String clientType = null;
|
||||
private Charset jsonGetStopsEncoding;
|
||||
private boolean jsonGetStopsUseWeight = true;
|
||||
private Charset jsonNearbyLocationsEncoding;
|
||||
private boolean dominantPlanStopTime = false;
|
||||
private boolean useIso8601 = false;
|
||||
private String extXmlEndpoint = null;
|
||||
private @Nullable String extXmlEndpoint = null;
|
||||
private boolean stationBoardHasStationTable = true;
|
||||
private boolean stationBoardHasLocation = false;
|
||||
private boolean stationBoardCanDoEquivs = true;
|
||||
|
@ -443,7 +446,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
}
|
||||
}
|
||||
|
||||
public QueryDeparturesResult queryDepartures(final String stationId, final Date time, final int maxDepartures, final boolean equivs)
|
||||
public QueryDeparturesResult queryDepartures(final String stationId, final @Nullable Date time, final int maxDepartures, final boolean equivs)
|
||||
throws IOException
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
|
||||
|
@ -452,8 +455,8 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
return xmlStationBoard(uri.toString(), stationId);
|
||||
}
|
||||
|
||||
protected void appendXmlStationBoardParameters(final StringBuilder uri, final Date time, final String stationId, final int maxDepartures,
|
||||
final boolean equivs, final String styleSheet)
|
||||
protected void appendXmlStationBoardParameters(final StringBuilder uri, final @Nullable Date time, final String stationId,
|
||||
final int maxDepartures, final boolean equivs, final @Nullable String styleSheet)
|
||||
{
|
||||
uri.append("?productsFilter=").append(allProductsString());
|
||||
uri.append("&boardType=dep");
|
||||
|
@ -652,8 +655,9 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
if (product == null)
|
||||
throw new IllegalArgumentException();
|
||||
// could check for type consistency here
|
||||
if (prodLine.attrs != null)
|
||||
line = newLine(product, prodLine.label, null, prodLine.attrs.toArray(new Line.Attr[0]));
|
||||
final Set<Attr> attrs = prodLine.attrs;
|
||||
if (attrs != null)
|
||||
line = newLine(product, prodLine.label, null, attrs.toArray(new Line.Attr[0]));
|
||||
else
|
||||
line = newLine(product, prodLine.label, null);
|
||||
}
|
||||
|
@ -747,8 +751,9 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
{
|
||||
}
|
||||
|
||||
public QueryTripsResult queryTrips(final Location from, final Location via, final Location to, final Date date, final boolean dep,
|
||||
final Set<Product> products, final WalkSpeed walkSpeed, final Accessibility accessibility, final Set<Option> options) throws IOException
|
||||
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to, final Date date, final boolean dep,
|
||||
final @Nullable Set<Product> products, final @Nullable WalkSpeed walkSpeed, final @Nullable Accessibility accessibility,
|
||||
final @Nullable Set<Option> options) throws IOException
|
||||
{
|
||||
return queryTripsBinary(from, via, to, date, dep, products, walkSpeed, accessibility, options);
|
||||
}
|
||||
|
@ -758,9 +763,9 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
return queryMoreTripsBinary(context, later);
|
||||
}
|
||||
|
||||
protected final QueryTripsResult queryTripsXml(Location from, Location via, Location to, final Date date, final boolean dep,
|
||||
final Collection<Product> products, final WalkSpeed walkSpeed, final Accessibility accessibility, final Set<Option> options)
|
||||
throws IOException
|
||||
protected final QueryTripsResult queryTripsXml(Location from, @Nullable Location via, Location to, final Date date, final boolean dep,
|
||||
final @Nullable Collection<Product> products, final @Nullable WalkSpeed walkSpeed, final @Nullable Accessibility accessibility,
|
||||
final @Nullable Set<Option> options) throws IOException
|
||||
{
|
||||
final ResultHeader header = new ResultHeader(SERVER_PRODUCT);
|
||||
|
||||
|
@ -859,7 +864,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
}
|
||||
|
||||
private QueryTripsResult queryTripsXml(final Context previousContext, final boolean later, final CharSequence conReq, final Location from,
|
||||
final Location via, final Location to) throws IOException
|
||||
final @Nullable Location via, final Location to) throws IOException
|
||||
{
|
||||
final String request = wrapReqC(conReq, null);
|
||||
|
||||
|
@ -1187,7 +1192,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
// remove last intermediate
|
||||
if (intermediateStops != null)
|
||||
if (!intermediateStops.isEmpty())
|
||||
if (!intermediateStops.get(intermediateStops.size() - 1).location.id.equals(sectionArrivalLocation.id))
|
||||
if (!intermediateStops.get(intermediateStops.size() - 1).location.equals(sectionArrivalLocation))
|
||||
intermediateStops.remove(intermediateStops.size() - 1);
|
||||
|
||||
XmlPullUtil.skipExit(pp, "ConSection");
|
||||
|
@ -1353,8 +1358,9 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
throw new IllegalArgumentException(location.type.toString());
|
||||
}
|
||||
|
||||
protected void appendQueryTripsBinaryParameters(final StringBuilder uri, final Location from, final Location via, final Location to,
|
||||
final Date date, final boolean dep, final Collection<Product> products, final Accessibility accessibility, final Set<Option> options)
|
||||
protected void appendQueryTripsBinaryParameters(final StringBuilder uri, final Location from, final @Nullable Location via, final Location to,
|
||||
final Date date, final boolean dep, final @Nullable Collection<Product> products, final @Nullable Accessibility accessibility,
|
||||
final @Nullable Set<Option> options)
|
||||
{
|
||||
uri.append("?start=Suchen");
|
||||
|
||||
|
@ -1428,9 +1434,9 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
|
||||
private final static int QUERY_TRIPS_BINARY_BUFFER_SIZE = 384 * 1024;
|
||||
|
||||
protected final QueryTripsResult queryTripsBinary(Location from, Location via, Location to, final Date date, final boolean dep,
|
||||
final Collection<Product> products, final WalkSpeed walkSpeed, final Accessibility accessibility, final Set<Option> options)
|
||||
throws IOException
|
||||
protected final QueryTripsResult queryTripsBinary(Location from, @Nullable Location via, Location to, final Date date, final boolean dep,
|
||||
final @Nullable Collection<Product> products, final @Nullable WalkSpeed walkSpeed, final @Nullable Accessibility accessibility,
|
||||
final @Nullable Set<Option> options) throws IOException
|
||||
{
|
||||
final ResultHeader header = new ResultHeader(SERVER_PRODUCT);
|
||||
|
||||
|
@ -1504,7 +1510,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
}
|
||||
}
|
||||
|
||||
private QueryTripsResult queryTripsBinary(final String uri, final Location from, final Location via, final Location to,
|
||||
private QueryTripsResult queryTripsBinary(final String uri, final Location from, final @Nullable Location via, final Location to,
|
||||
final int expectedBufferSize) throws IOException
|
||||
{
|
||||
/*
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
package de.schildbach.pte;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
@ -30,6 +32,8 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
@ -96,8 +100,8 @@ public abstract class AbstractNavitiaProvider extends AbstractNetworkProvider
|
|||
|
||||
private static class Context implements QueryTripsContext
|
||||
{
|
||||
private Location from;
|
||||
private Location to;
|
||||
private final Location from;
|
||||
private final Location to;
|
||||
private final String prevQueryUri;
|
||||
private final String nextQueryUri;
|
||||
|
||||
|
@ -831,7 +835,7 @@ public abstract class AbstractNavitiaProvider extends AbstractNetworkProvider
|
|||
}
|
||||
}
|
||||
|
||||
public QueryDeparturesResult queryDepartures(final String stationId, final Date time, final int maxDepartures, final boolean equivs)
|
||||
public QueryDeparturesResult queryDepartures(final String stationId, final @Nullable Date time, final int maxDepartures, final boolean equivs)
|
||||
throws IOException
|
||||
{
|
||||
final ResultHeader resultHeader = new ResultHeader(SERVER_PRODUCT, SERVER_VERSION, 0, null);
|
||||
|
@ -885,7 +889,7 @@ public abstract class AbstractNavitiaProvider extends AbstractNetworkProvider
|
|||
final List<LineDestination> lineDestinations = getStationLines(location.id);
|
||||
|
||||
for (LineDestination lineDestination : lineDestinations)
|
||||
stationDepartures.lines.add(lineDestination);
|
||||
checkNotNull(stationDepartures.lines).add(lineDestination);
|
||||
}
|
||||
|
||||
// Build departure date.
|
||||
|
@ -981,8 +985,9 @@ public abstract class AbstractNavitiaProvider extends AbstractNetworkProvider
|
|||
}
|
||||
}
|
||||
|
||||
public QueryTripsResult queryTrips(final Location from, final Location via, final Location to, final Date date, final boolean dep,
|
||||
final Set<Product> products, final WalkSpeed walkSpeed, final Accessibility accessibility, final Set<Option> options) throws IOException
|
||||
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to, final Date date, final boolean dep,
|
||||
final @Nullable Set<Product> products, final @Nullable WalkSpeed walkSpeed, final @Nullable Accessibility accessibility,
|
||||
final @Nullable Set<Option> options) throws IOException
|
||||
{
|
||||
final ResultHeader resultHeader = new ResultHeader(SERVER_PRODUCT, SERVER_VERSION, 0, null);
|
||||
|
||||
|
@ -990,32 +995,34 @@ public abstract class AbstractNavitiaProvider extends AbstractNetworkProvider
|
|||
{
|
||||
if (from != null && from.isIdentified() && to != null && to.isIdentified())
|
||||
{
|
||||
final String fromString = printLocation(from);
|
||||
final String toString = printLocation(to);
|
||||
final String dateString = printDate(date);
|
||||
final String dateTimeRep = dep ? "departure" : "arrival";
|
||||
final StringBuilder queryUri = new StringBuilder(tripUri()).append("journeys");
|
||||
queryUri.append("?from=").append(ParserUtils.urlEncode(printLocation(from)));
|
||||
queryUri.append("&to=").append(ParserUtils.urlEncode(printLocation(to)));
|
||||
queryUri.append("&datetime=").append(printDate(date));
|
||||
queryUri.append("&datetime_represents=").append(dep ? "departure" : "arrival");
|
||||
queryUri.append("&count=").append(this.numTripsRequested);
|
||||
queryUri.append("&depth=0");
|
||||
|
||||
// Set walking speed.
|
||||
final double walkingSpeed;
|
||||
switch (walkSpeed)
|
||||
if (walkSpeed != null)
|
||||
{
|
||||
case SLOW:
|
||||
walkingSpeed = 1.12 * 0.8;
|
||||
break;
|
||||
case NORMAL:
|
||||
walkingSpeed = 1.12;
|
||||
break;
|
||||
case FAST:
|
||||
walkingSpeed = 1.12 * 1.2;
|
||||
break;
|
||||
default:
|
||||
walkingSpeed = 1.12;
|
||||
break;
|
||||
}
|
||||
final double walkingSpeed;
|
||||
switch (walkSpeed)
|
||||
{
|
||||
case SLOW:
|
||||
walkingSpeed = 1.12 * 0.8;
|
||||
break;
|
||||
case FAST:
|
||||
walkingSpeed = 1.12 * 1.2;
|
||||
break;
|
||||
case NORMAL:
|
||||
default:
|
||||
walkingSpeed = 1.12;
|
||||
break;
|
||||
}
|
||||
|
||||
final StringBuilder queryUri = new StringBuilder(tripUri() + "journeys?" + "from=" + ParserUtils.urlEncode(fromString) + "&to="
|
||||
+ ParserUtils.urlEncode(toString) + "&datetime=" + dateString + "&datetime_represents=" + dateTimeRep + "&count="
|
||||
+ this.numTripsRequested + "&walking_speed=" + walkingSpeed + "&depth=0");
|
||||
queryUri.append("&walking_speed=").append(walkingSpeed);
|
||||
}
|
||||
|
||||
if (options != null && options.contains(Option.BIKE))
|
||||
{
|
||||
|
@ -1024,7 +1031,7 @@ public abstract class AbstractNavitiaProvider extends AbstractNetworkProvider
|
|||
}
|
||||
|
||||
// Set forbidden commercial modes.
|
||||
if (!products.equals(Product.ALL))
|
||||
if (products != null && !products.equals(Product.ALL))
|
||||
{
|
||||
if (!products.contains(Product.SUBURBAN_TRAIN))
|
||||
{
|
||||
|
|
|
@ -25,6 +25,8 @@ import java.util.TimeZone;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
import de.schildbach.pte.dto.Point;
|
||||
|
@ -41,8 +43,8 @@ public abstract class AbstractNetworkProvider implements NetworkProvider
|
|||
|
||||
protected TimeZone timeZone = TimeZone.getTimeZone("CET");
|
||||
protected int numTripsRequested = 6;
|
||||
private Map<String, Style> styles = null;
|
||||
protected String sessionCookieName = null;
|
||||
private @Nullable Map<String, Style> styles = null;
|
||||
protected @Nullable String sessionCookieName = null;
|
||||
|
||||
public final boolean hasCapabilities(final Capability... capabilities)
|
||||
{
|
||||
|
@ -82,8 +84,9 @@ public abstract class AbstractNetworkProvider implements NetworkProvider
|
|||
|
||||
private static final char STYLES_SEP = '|';
|
||||
|
||||
public Style lineStyle(final String network, final Product product, final String label)
|
||||
public Style lineStyle(final @Nullable String network, final @Nullable Product product, final @Nullable String label)
|
||||
{
|
||||
final Map<String, Style> styles = this.styles;
|
||||
if (styles != null && product != null)
|
||||
{
|
||||
if (network != null)
|
||||
|
@ -99,7 +102,7 @@ public abstract class AbstractNetworkProvider implements NetworkProvider
|
|||
return productStyle;
|
||||
|
||||
// check for night bus, as that's a common special case
|
||||
if (product == Product.BUS && label.startsWith("N"))
|
||||
if (product == Product.BUS && label != null && label.startsWith("N"))
|
||||
{
|
||||
final Style nightStyle = styles.get(network + STYLES_SEP + "BN");
|
||||
if (nightStyle != null)
|
||||
|
@ -119,7 +122,7 @@ public abstract class AbstractNetworkProvider implements NetworkProvider
|
|||
return productStyle;
|
||||
|
||||
// check for night bus, as that's a common special case
|
||||
if (product == Product.BUS && label.startsWith("N"))
|
||||
if (product == Product.BUS && label != null && label.startsWith("N"))
|
||||
{
|
||||
final Style nightStyle = styles.get("BN");
|
||||
if (nightStyle != null)
|
||||
|
|
|
@ -34,6 +34,8 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
@ -164,7 +166,7 @@ public abstract class AbstractTsiProvider extends AbstractNetworkProvider
|
|||
return (double) value / 1000000;
|
||||
}
|
||||
|
||||
private final String apiKey;
|
||||
private final @Nullable String apiKey;
|
||||
private final String stopFinderEndpoint;
|
||||
private final String tripEndpoint;
|
||||
|
||||
|
@ -604,7 +606,7 @@ public abstract class AbstractTsiProvider extends AbstractNetworkProvider
|
|||
return new Location(locType, id, Point.fromDouble(lat, lon), place, name);
|
||||
}
|
||||
|
||||
public QueryDeparturesResult queryDepartures(final String stationId, final Date time, final int maxDepartures, final boolean equivs)
|
||||
public QueryDeparturesResult queryDepartures(final String stationId, final @Nullable Date time, final int maxDepartures, final boolean equivs)
|
||||
throws IOException
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
|
@ -632,8 +634,9 @@ public abstract class AbstractTsiProvider extends AbstractNetworkProvider
|
|||
return jsonCoordRequest(location.lat, location.lon, maxDistance, maxLocations);
|
||||
}
|
||||
|
||||
public QueryTripsResult queryTrips(final Location from, final Location via, final Location to, final Date date, final boolean dep,
|
||||
final Set<Product> products, final WalkSpeed walkSpeed, final Accessibility accessibility, final Set<Option> options) throws IOException
|
||||
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to, final Date date, final boolean dep,
|
||||
final @Nullable Set<Product> products, final @Nullable WalkSpeed walkSpeed, final @Nullable Accessibility accessibility,
|
||||
final @Nullable Set<Option> options) throws IOException
|
||||
{
|
||||
final List<Location> possibleFroms, possibleTos, possibleVias;
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@ package de.schildbach.pte;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import de.schildbach.pte.dto.Line;
|
||||
import de.schildbach.pte.dto.Product;
|
||||
import de.schildbach.pte.dto.Style;
|
||||
|
@ -46,8 +48,8 @@ public class AvvProvider extends AbstractEfaProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Line parseLine(final String id, final String mot, final String symbol, final String name, final String longName,
|
||||
final String trainType, final String trainNum, final String trainName)
|
||||
protected Line parseLine(final @Nullable String id, final @Nullable String mot, final @Nullable String symbol, final @Nullable String name,
|
||||
final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName)
|
||||
{
|
||||
if ("0".equals(mot))
|
||||
{
|
||||
|
|
|
@ -22,6 +22,8 @@ import java.util.Date;
|
|||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
|
||||
import de.schildbach.pte.dto.Line;
|
||||
|
@ -63,8 +65,8 @@ public class BayernProvider extends AbstractEfaProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Line parseLine(final String id, final String mot, final String symbol, final String name, final String longName,
|
||||
final String trainType, final String trainNum, final String trainName)
|
||||
protected Line parseLine(final @Nullable String id, final @Nullable String mot, final @Nullable String symbol, final @Nullable String name,
|
||||
final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName)
|
||||
{
|
||||
if ("0".equals(mot))
|
||||
{
|
||||
|
@ -117,7 +119,7 @@ public class BayernProvider extends AbstractEfaProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public QueryDeparturesResult queryDepartures(final String stationId, final Date time, final int maxDepartures, final boolean equivs)
|
||||
public QueryDeparturesResult queryDepartures(final String stationId, final @Nullable Date time, final int maxDepartures, final boolean equivs)
|
||||
throws IOException
|
||||
{
|
||||
return queryDeparturesMobile(stationId, time, maxDepartures, equivs);
|
||||
|
@ -130,8 +132,9 @@ public class BayernProvider extends AbstractEfaProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public QueryTripsResult queryTrips(final Location from, final Location via, final Location to, final Date date, final boolean dep,
|
||||
final Set<Product> products, final WalkSpeed walkSpeed, final Accessibility accessibility, final Set<Option> options) throws IOException
|
||||
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to, final Date date, final boolean dep,
|
||||
final @Nullable Set<Product> products, final @Nullable WalkSpeed walkSpeed, final @Nullable Accessibility accessibility,
|
||||
final @Nullable Set<Option> options) throws IOException
|
||||
{
|
||||
return queryTripsMobile(from, via, to, date, dep, products, walkSpeed, accessibility, options);
|
||||
}
|
||||
|
|
|
@ -23,6 +23,8 @@ import java.util.Set;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import de.schildbach.pte.dto.Line;
|
||||
import de.schildbach.pte.dto.Location;
|
||||
import de.schildbach.pte.dto.Product;
|
||||
|
@ -89,8 +91,9 @@ public class EireannProvider extends AbstractHafasProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public QueryTripsResult queryTrips(final Location from, final Location via, final Location to, final Date date, final boolean dep,
|
||||
final Set<Product> products, final WalkSpeed walkSpeed, final Accessibility accessibility, final Set<Option> options) throws IOException
|
||||
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to, final Date date, final boolean dep,
|
||||
final @Nullable Set<Product> products, final @Nullable WalkSpeed walkSpeed, final @Nullable Accessibility accessibility,
|
||||
final @Nullable Set<Option> options) throws IOException
|
||||
{
|
||||
return queryTripsXml(from, via, to, date, dep, products, walkSpeed, accessibility, options);
|
||||
}
|
||||
|
|
|
@ -31,6 +31,8 @@ import java.util.Set;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
|
||||
import de.schildbach.pte.dto.Departure;
|
||||
|
@ -176,7 +178,7 @@ public class InvgProvider extends AbstractHafasProvider
|
|||
, Pattern.DOTALL);
|
||||
|
||||
@Override
|
||||
public QueryDeparturesResult queryDepartures(final String stationId, final Date time, final int maxDepartures, final boolean equivs)
|
||||
public QueryDeparturesResult queryDepartures(final String stationId, final @Nullable Date time, final int maxDepartures, final boolean equivs)
|
||||
throws IOException
|
||||
{
|
||||
final ResultHeader header = new ResultHeader(SERVER_PRODUCT);
|
||||
|
@ -305,8 +307,9 @@ public class InvgProvider extends AbstractHafasProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public QueryTripsResult queryTrips(final Location from, final Location via, final Location to, final Date date, final boolean dep,
|
||||
final Set<Product> products, final WalkSpeed walkSpeed, final Accessibility accessibility, final Set<Option> options) throws IOException
|
||||
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to, final Date date, final boolean dep,
|
||||
final @Nullable Set<Product> products, final @Nullable WalkSpeed walkSpeed, final @Nullable Accessibility accessibility,
|
||||
final @Nullable Set<Option> options) throws IOException
|
||||
{
|
||||
return queryTripsXml(from, via, to, date, dep, products, walkSpeed, accessibility, options);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,8 @@ import java.util.Map;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import de.schildbach.pte.dto.Line;
|
||||
import de.schildbach.pte.dto.Style;
|
||||
import de.schildbach.pte.dto.Style.Shape;
|
||||
|
@ -55,8 +57,8 @@ public class KvvProvider extends AbstractEfaProvider
|
|||
private static final Pattern P_LINE = Pattern.compile("(.*?)\\s+\\([\\w/]+\\)", Pattern.CASE_INSENSITIVE);
|
||||
|
||||
@Override
|
||||
protected Line parseLine(final String id, final String mot, final String symbol, final String name, final String longName,
|
||||
final String trainType, final String trainNum, final String trainName)
|
||||
protected Line parseLine(final @Nullable String id, final @Nullable String mot, final @Nullable String symbol, final @Nullable String name,
|
||||
final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName)
|
||||
{
|
||||
if (name != null)
|
||||
{
|
||||
|
|
|
@ -20,6 +20,8 @@ package de.schildbach.pte;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
import de.schildbach.pte.dto.Line;
|
||||
|
@ -53,8 +55,8 @@ public class MetProvider extends AbstractEfaProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Line parseLine(final String id, final String mot, final String symbol, final String name, final String longName,
|
||||
final String trainType, final String trainNum, final String trainName)
|
||||
protected Line parseLine(final @Nullable String id, final @Nullable String mot, final @Nullable String symbol, final @Nullable String name,
|
||||
final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName)
|
||||
{
|
||||
if ("0".equals(mot))
|
||||
{
|
||||
|
|
|
@ -22,6 +22,8 @@ import java.util.Map;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import de.schildbach.pte.dto.Line;
|
||||
import de.schildbach.pte.dto.Point;
|
||||
import de.schildbach.pte.dto.Position;
|
||||
|
@ -56,8 +58,8 @@ public class MvvProvider extends AbstractEfaProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Line parseLine(final String id, final String mot, final String symbol, final String name, final String longName,
|
||||
final String trainType, final String trainNum, final String trainName)
|
||||
protected Line parseLine(final @Nullable String id, final @Nullable String mot, final @Nullable String symbol, final @Nullable String name,
|
||||
final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName)
|
||||
{
|
||||
if ("0".equals(mot))
|
||||
{
|
||||
|
|
|
@ -22,6 +22,8 @@ import java.util.Date;
|
|||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import de.schildbach.pte.dto.Location;
|
||||
import de.schildbach.pte.dto.LocationType;
|
||||
import de.schildbach.pte.dto.NearbyLocationsResult;
|
||||
|
@ -72,12 +74,13 @@ public interface NetworkProvider
|
|||
boolean hasCapabilities(final Capability... capabilities);
|
||||
|
||||
/**
|
||||
* Find locations near to given location. At least one of lat/lon pair or station id must be present.
|
||||
* Find locations near to given location. At least one of lat/lon pair or station id must be present in that
|
||||
* location.
|
||||
*
|
||||
* @param types
|
||||
* types of locations to find
|
||||
* @param location
|
||||
* location to determine nearby stations (optional)
|
||||
* location to determine nearby stations
|
||||
* @param maxDistance
|
||||
* maximum distance in meters, or {@code 0}
|
||||
* @param maxLocations
|
||||
|
@ -93,7 +96,7 @@ public interface NetworkProvider
|
|||
* @param stationId
|
||||
* id of the station
|
||||
* @param time
|
||||
* desired time for departing, optional
|
||||
* desired time for departing, or {@code null} for the provider default
|
||||
* @param maxDepartures
|
||||
* maximum number of departures to get or {@code 0}
|
||||
* @param equivs
|
||||
|
@ -101,7 +104,7 @@ public interface NetworkProvider
|
|||
* @return result object containing the departures
|
||||
* @throws IOException
|
||||
*/
|
||||
QueryDeparturesResult queryDepartures(String stationId, Date time, int maxDepartures, boolean equivs) throws IOException;
|
||||
QueryDeparturesResult queryDepartures(String stationId, @Nullable Date time, int maxDepartures, boolean equivs) throws IOException;
|
||||
|
||||
/**
|
||||
* Meant for auto-completion of location names, like in an {@link android.widget.AutoCompleteTextView}
|
||||
|
@ -134,18 +137,18 @@ public interface NetworkProvider
|
|||
* @param dep
|
||||
* date is departure date? {@code true} for departure, {@code false} for arrival
|
||||
* @param products
|
||||
* products to take into account
|
||||
* products to take into account, or {@code null} for the provider default
|
||||
* @param walkSpeed
|
||||
* how fast can you walk?
|
||||
* walking ability, or {@code null} for the provider default
|
||||
* @param accessibility
|
||||
* how accessible do you need the route to be?
|
||||
* route accessibility, or {@code null} for the provider default
|
||||
* @param options
|
||||
* additional options
|
||||
* additional options, or {@code null} for the provider default
|
||||
* @return result object that can contain alternatives to clear up ambiguousnesses, or contains possible trips
|
||||
* @throws IOException
|
||||
*/
|
||||
QueryTripsResult queryTrips(Location from, Location via, Location to, Date date, boolean dep, Set<Product> products, WalkSpeed walkSpeed,
|
||||
Accessibility accessibility, Set<Option> options) throws IOException;
|
||||
QueryTripsResult queryTrips(Location from, @Nullable Location via, Location to, Date date, boolean dep, @Nullable Set<Product> products,
|
||||
@Nullable WalkSpeed walkSpeed, @Nullable Accessibility accessibility, @Nullable Set<Option> options) throws IOException;
|
||||
|
||||
/**
|
||||
* Query more trips (e.g. earlier or later)
|
||||
|
@ -163,14 +166,14 @@ public interface NetworkProvider
|
|||
* Get style of line
|
||||
*
|
||||
* @param network
|
||||
* network to disambiguate line
|
||||
* network to disambiguate line, may be {@code null}
|
||||
* @param product
|
||||
* line product to get style of
|
||||
* line product to get style of, may be {@code null}
|
||||
* @param label
|
||||
* line label to get style of, or null
|
||||
* line label to get style of, may be {@code null}
|
||||
* @return object containing background, foreground and optional border colors
|
||||
*/
|
||||
Style lineStyle(String network, Product product, String label);
|
||||
Style lineStyle(@Nullable String network, @Nullable Product product, @Nullable String label);
|
||||
|
||||
/**
|
||||
* Gets the primary covered area of the network
|
||||
|
|
|
@ -21,6 +21,8 @@ import java.io.IOException;
|
|||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
|
||||
import de.schildbach.pte.dto.Location;
|
||||
|
@ -130,8 +132,9 @@ public class NriProvider extends AbstractHafasProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public QueryTripsResult queryTrips(final Location from, final Location via, final Location to, final Date date, final boolean dep,
|
||||
final Set<Product> products, final WalkSpeed walkSpeed, final Accessibility accessibility, final Set<Option> options) throws IOException
|
||||
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to, final Date date, final boolean dep,
|
||||
final @Nullable Set<Product> products, final @Nullable WalkSpeed walkSpeed, final @Nullable Accessibility accessibility,
|
||||
final @Nullable Set<Option> options) throws IOException
|
||||
{
|
||||
return queryTripsXml(from, via, to, date, dep, products, walkSpeed, accessibility, options);
|
||||
}
|
||||
|
|
|
@ -23,6 +23,8 @@ import java.util.Set;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import de.schildbach.pte.dto.Line;
|
||||
import de.schildbach.pte.dto.Location;
|
||||
import de.schildbach.pte.dto.Product;
|
||||
|
@ -58,8 +60,8 @@ public class NvbwProvider extends AbstractEfaProvider
|
|||
private static final Pattern P_LINE_S_AVG_VBK = Pattern.compile("(S\\d+) \\((?:AVG|VBK)\\)");
|
||||
|
||||
@Override
|
||||
protected Line parseLine(final String id, final String mot, final String symbol, final String name, final String longName,
|
||||
final String trainType, final String trainNum, final String trainName)
|
||||
protected Line parseLine(final @Nullable String id, final @Nullable String mot, final @Nullable String symbol, final @Nullable String name,
|
||||
final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName)
|
||||
{
|
||||
if ("0".equals(mot))
|
||||
{
|
||||
|
@ -104,8 +106,9 @@ public class NvbwProvider extends AbstractEfaProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public QueryTripsResult queryTrips(final Location from, final Location via, final Location to, final Date date, final boolean dep,
|
||||
final Set<Product> products, final WalkSpeed walkSpeed, final Accessibility accessibility, final Set<Option> options) throws IOException
|
||||
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to, final Date date, final boolean dep,
|
||||
final @Nullable Set<Product> products, final @Nullable WalkSpeed walkSpeed, final @Nullable Accessibility accessibility,
|
||||
final @Nullable Set<Option> options) throws IOException
|
||||
{
|
||||
return queryTripsMobile(from, via, to, date, dep, products, walkSpeed, accessibility, options);
|
||||
}
|
||||
|
|
|
@ -30,6 +30,8 @@ import java.util.Set;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import de.schildbach.pte.dto.Departure;
|
||||
import de.schildbach.pte.dto.Line;
|
||||
import de.schildbach.pte.dto.Location;
|
||||
|
@ -162,7 +164,7 @@ public class SeptaProvider extends AbstractHafasProvider
|
|||
, Pattern.DOTALL);
|
||||
|
||||
@Override
|
||||
public QueryDeparturesResult queryDepartures(final String stationId, final Date time, final int maxDepartures, final boolean equivs)
|
||||
public QueryDeparturesResult queryDepartures(final String stationId, final @Nullable Date time, final int maxDepartures, final boolean equivs)
|
||||
throws IOException
|
||||
{
|
||||
final ResultHeader header = new ResultHeader(SERVER_PRODUCT);
|
||||
|
@ -282,8 +284,9 @@ public class SeptaProvider extends AbstractHafasProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public QueryTripsResult queryTrips(final Location from, final Location via, final Location to, final Date date, final boolean dep,
|
||||
final Set<Product> products, final WalkSpeed walkSpeed, final Accessibility accessibility, final Set<Option> options) throws IOException
|
||||
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to, final Date date, final boolean dep,
|
||||
final @Nullable Set<Product> products, final @Nullable WalkSpeed walkSpeed, final @Nullable Accessibility accessibility,
|
||||
final @Nullable Set<Option> options) throws IOException
|
||||
{
|
||||
return queryTripsXml(from, via, to, date, dep, products, walkSpeed, accessibility, options);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,8 @@ package de.schildbach.pte;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import de.schildbach.pte.dto.Line;
|
||||
import de.schildbach.pte.dto.Product;
|
||||
import de.schildbach.pte.dto.Style;
|
||||
|
@ -58,8 +60,8 @@ public class SfProvider extends AbstractEfaProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Line parseLine(final String id, final String mot, final String symbol, final String name, final String longName,
|
||||
final String trainType, final String trainNum, final String trainName)
|
||||
protected Line parseLine(final @Nullable String id, final @Nullable String mot, final @Nullable String symbol, final @Nullable String name,
|
||||
final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName)
|
||||
{
|
||||
if ("0".equals(mot))
|
||||
{
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
package de.schildbach.pte;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import de.schildbach.pte.dto.Line;
|
||||
import de.schildbach.pte.dto.Product;
|
||||
|
||||
|
@ -41,8 +43,8 @@ public class StvProvider extends AbstractEfaProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Line parseLine(final String id, final String mot, final String symbol, final String name, final String longName,
|
||||
final String trainType, final String trainNum, final String trainName)
|
||||
protected Line parseLine(final @Nullable String id, final @Nullable String mot, final @Nullable String symbol, final @Nullable String name,
|
||||
final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName)
|
||||
{
|
||||
if ("0".equals(mot))
|
||||
{
|
||||
|
|
|
@ -20,6 +20,8 @@ package de.schildbach.pte;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import de.schildbach.pte.dto.Line;
|
||||
import de.schildbach.pte.dto.Product;
|
||||
import de.schildbach.pte.dto.Style;
|
||||
|
@ -58,8 +60,8 @@ public class SydneyProvider extends AbstractEfaProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Line parseLine(final String id, final String mot, final String symbol, final String name, final String longName,
|
||||
final String trainType, final String trainNum, final String trainName)
|
||||
protected Line parseLine(final @Nullable String id, final @Nullable String mot, final @Nullable String symbol, final @Nullable String name,
|
||||
final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName)
|
||||
{
|
||||
if ("1".equals(mot))
|
||||
{
|
||||
|
|
|
@ -19,6 +19,8 @@ package de.schildbach.pte;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import de.schildbach.pte.dto.Line;
|
||||
import de.schildbach.pte.dto.Product;
|
||||
|
||||
|
@ -50,8 +52,8 @@ public class TfiProvider extends AbstractEfaProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Line parseLine(final String id, final String mot, final String symbol, final String name, final String longName,
|
||||
final String trainType, final String trainNum, final String trainName)
|
||||
protected Line parseLine(final @Nullable String id, final @Nullable String mot, final @Nullable String symbol, final @Nullable String name,
|
||||
final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName)
|
||||
{
|
||||
if ("0".equals(mot))
|
||||
{
|
||||
|
|
|
@ -21,6 +21,8 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import de.schildbach.pte.dto.Line;
|
||||
import de.schildbach.pte.dto.Product;
|
||||
import de.schildbach.pte.dto.Style;
|
||||
|
@ -72,8 +74,8 @@ public class TlemProvider extends AbstractEfaProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Line parseLine(final String id, final String mot, final String symbol, final String name, final String longName,
|
||||
final String trainType, final String trainNum, final String trainName)
|
||||
protected Line parseLine(final @Nullable String id, final @Nullable String mot, final @Nullable String symbol, final @Nullable String name,
|
||||
final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName)
|
||||
{
|
||||
if ("1".equals(mot))
|
||||
{
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
package de.schildbach.pte;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import de.schildbach.pte.dto.Line;
|
||||
import de.schildbach.pte.dto.Product;
|
||||
|
||||
|
@ -41,8 +43,8 @@ public class VblProvider extends AbstractEfaProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Line parseLine(final String id, final String mot, final String symbol, final String name, final String longName,
|
||||
final String trainType, final String trainNum, final String trainName)
|
||||
protected Line parseLine(final @Nullable String id, final @Nullable String mot, final @Nullable String symbol, final @Nullable String name,
|
||||
final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName)
|
||||
{
|
||||
if ("0".equals(mot))
|
||||
{
|
||||
|
|
|
@ -21,6 +21,8 @@ import java.util.Collection;
|
|||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import de.schildbach.pte.dto.Line;
|
||||
import de.schildbach.pte.dto.Location;
|
||||
import de.schildbach.pte.dto.Product;
|
||||
|
@ -45,8 +47,8 @@ public class VgnProvider extends AbstractEfaProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Line parseLine(final String id, final String mot, final String symbol, final String name, final String longName,
|
||||
final String trainType, final String trainNum, final String trainName)
|
||||
protected Line parseLine(final @Nullable String id, final @Nullable String mot, final @Nullable String symbol, final @Nullable String name,
|
||||
final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName)
|
||||
{
|
||||
if ("0".equals(mot))
|
||||
{
|
||||
|
@ -62,8 +64,9 @@ public class VgnProvider extends AbstractEfaProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
protected String xsltTripRequestParameters(final Location from, final Location via, final Location to, final Date date, final boolean dep,
|
||||
final Collection<Product> products, final WalkSpeed walkSpeed, final Accessibility accessibility, final Set<Option> options)
|
||||
protected String xsltTripRequestParameters(final Location from, final @Nullable Location via, final Location to, final Date date,
|
||||
final boolean dep, final @Nullable Collection<Product> products, final @Nullable WalkSpeed walkSpeed,
|
||||
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options)
|
||||
{
|
||||
return super.xsltTripRequestParameters(from, via, to, date, dep, products, walkSpeed, accessibility, options) + "&itdLPxx_showTariffLevel=1";
|
||||
}
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
package de.schildbach.pte;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import de.schildbach.pte.dto.Line;
|
||||
import de.schildbach.pte.dto.Product;
|
||||
|
||||
|
@ -39,8 +41,8 @@ public class VmsProvider extends AbstractEfaProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Line parseLine(final String id, final String mot, final String symbol, final String name, final String longName,
|
||||
final String trainType, final String trainNum, final String trainName)
|
||||
protected Line parseLine(final @Nullable String id, final @Nullable String mot, final @Nullable String symbol, final @Nullable String name,
|
||||
final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName)
|
||||
{
|
||||
if ("0".equals(mot))
|
||||
{
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
package de.schildbach.pte;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import de.schildbach.pte.dto.Line;
|
||||
import de.schildbach.pte.dto.Product;
|
||||
|
||||
|
@ -41,8 +43,8 @@ public class VrnProvider extends AbstractEfaProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Line parseLine(final String id, final String mot, final String symbol, final String name, final String longName,
|
||||
final String trainType, final String trainNum, final String trainName)
|
||||
protected Line parseLine(final @Nullable String id, final @Nullable String mot, final @Nullable String symbol, final @Nullable String name,
|
||||
final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName)
|
||||
{
|
||||
if ("0".equals(mot))
|
||||
{
|
||||
|
|
|
@ -20,6 +20,8 @@ package de.schildbach.pte;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
|
||||
import de.schildbach.pte.dto.Line;
|
||||
|
@ -52,8 +54,8 @@ public class VrrProvider extends AbstractEfaProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Line parseLine(final String id, final String mot, final String symbol, final String name, final String longName,
|
||||
final String trainType, final String trainNum, final String trainName)
|
||||
protected Line parseLine(final @Nullable String id, final @Nullable String mot, final @Nullable String symbol, final @Nullable String name,
|
||||
final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName)
|
||||
{
|
||||
if ("0".equals(mot))
|
||||
{
|
||||
|
@ -190,7 +192,7 @@ public class VrrProvider extends AbstractEfaProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public Style lineStyle(final String network, final Product product, final String label)
|
||||
public Style lineStyle(final @Nullable String network, final @Nullable Product product, final @Nullable String label)
|
||||
{
|
||||
if (product == Product.BUS && label != null && label.startsWith("SB"))
|
||||
return super.lineStyle(network, product, "SB");
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
package de.schildbach.pte;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
|
||||
import de.schildbach.pte.dto.Line;
|
||||
|
@ -49,8 +51,8 @@ public class VvoProvider extends AbstractEfaProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Line parseLine(final String id, final String mot, final String symbol, final String name, final String longName,
|
||||
final String trainType, final String trainNum, final String trainName)
|
||||
protected Line parseLine(final @Nullable String id, final @Nullable String mot, final @Nullable String symbol, final @Nullable String name,
|
||||
final @Nullable String longName, final @Nullable String trainType, final @Nullable String trainNum, final @Nullable String trainName)
|
||||
{
|
||||
if ("0".equals(mot))
|
||||
{
|
||||
|
|
|
@ -25,6 +25,8 @@ import java.util.Comparator;
|
|||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.base.MoreObjects.ToStringHelper;
|
||||
import com.google.common.base.Objects;
|
||||
|
@ -34,13 +36,13 @@ import com.google.common.base.Objects;
|
|||
*/
|
||||
public final class Departure implements Serializable
|
||||
{
|
||||
final public Date plannedTime;
|
||||
final public Date predictedTime;
|
||||
final public @Nullable Date plannedTime;
|
||||
final public @Nullable Date predictedTime;
|
||||
final public Line line;
|
||||
final public Position position;
|
||||
final public Location destination;
|
||||
final public int[] capacity;
|
||||
final public String message;
|
||||
final public @Nullable Position position;
|
||||
final public @Nullable Location destination;
|
||||
final public @Nullable int[] capacity;
|
||||
final public @Nullable String message;
|
||||
|
||||
public Departure(final Date plannedTime, final Date predictedTime, final Line line, final Position position, final Location destination,
|
||||
final int[] capacity, final String message)
|
||||
|
|
|
@ -22,6 +22,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
import java.io.Serializable;
|
||||
import java.util.Currency;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
|
@ -39,8 +41,8 @@ public final class Fare implements Serializable
|
|||
public final Type type;
|
||||
public final Currency currency;
|
||||
public final float fare;
|
||||
public final String unitName;
|
||||
public final String units;
|
||||
public final @Nullable String unitName;
|
||||
public final @Nullable String units;
|
||||
|
||||
public Fare(final String network, final Type type, final Currency currency, final float fare, final String unitName, final String units)
|
||||
{
|
||||
|
|
|
@ -20,6 +20,8 @@ package de.schildbach.pte.dto;
|
|||
import java.io.Serializable;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ComparisonChain;
|
||||
|
@ -37,12 +39,12 @@ public final class Line implements Serializable, Comparable<Line>
|
|||
|
||||
private static final long serialVersionUID = -5642533805998375070L;
|
||||
|
||||
public final String id;
|
||||
public final Product product;
|
||||
public final String label;
|
||||
public final Style style;
|
||||
public final Set<Attr> attrs;
|
||||
public final String message;
|
||||
public final @Nullable String id;
|
||||
public final @Nullable Product product;
|
||||
public final @Nullable String label;
|
||||
public final @Nullable Style style;
|
||||
public final @Nullable Set<Attr> attrs;
|
||||
public final @Nullable String message;
|
||||
|
||||
public static final Line FOOTWAY = new Line(null, null, null);
|
||||
public static final Line TRANSFER = new Line(null, null, null);
|
||||
|
@ -81,11 +83,13 @@ public final class Line implements Serializable, Comparable<Line>
|
|||
|
||||
public char productCode()
|
||||
{
|
||||
final Product product = this.product;
|
||||
return product != null ? product.code : Product.UNKNOWN;
|
||||
}
|
||||
|
||||
public boolean hasAttr(final Attr attr)
|
||||
{
|
||||
final Set<Attr> attrs = this.attrs;
|
||||
return attrs != null && attrs.contains(attr);
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
|
@ -30,7 +32,7 @@ import com.google.common.base.Objects;
|
|||
public final class LineDestination implements Serializable
|
||||
{
|
||||
final public Line line;
|
||||
final public Location destination;
|
||||
final public @Nullable Location destination;
|
||||
|
||||
public LineDestination(final Line line, final Location destination)
|
||||
{
|
||||
|
|
|
@ -23,6 +23,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.base.MoreObjects.ToStringHelper;
|
||||
import com.google.common.base.Objects;
|
||||
|
@ -33,10 +35,10 @@ import com.google.common.base.Objects;
|
|||
public final class Location implements Serializable
|
||||
{
|
||||
public final LocationType type;
|
||||
public final String id;
|
||||
public final @Nullable String id;
|
||||
public final int lat, lon;
|
||||
public final String place;
|
||||
public final String name;
|
||||
public final @Nullable String place;
|
||||
public final @Nullable String name;
|
||||
|
||||
public Location(final LocationType type, final String id, final int lat, final int lon, final String place, final String name)
|
||||
{
|
||||
|
|
|
@ -22,6 +22,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.base.MoreObjects.ToStringHelper;
|
||||
|
||||
|
@ -35,7 +37,7 @@ public final class NearbyLocationsResult implements Serializable
|
|||
OK, INVALID_ID, SERVICE_DOWN
|
||||
}
|
||||
|
||||
public final ResultHeader header;
|
||||
public final @Nullable ResultHeader header;
|
||||
public final Status status;
|
||||
public final List<Location> locations;
|
||||
|
||||
|
|
|
@ -22,6 +22,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
/**
|
||||
|
@ -30,7 +32,7 @@ import com.google.common.base.Objects;
|
|||
public final class Position implements Serializable
|
||||
{
|
||||
public final String name;
|
||||
public final String section;
|
||||
public final @Nullable String section;
|
||||
|
||||
public Position(final String name)
|
||||
{
|
||||
|
|
|
@ -23,6 +23,8 @@ import java.io.Serializable;
|
|||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.base.MoreObjects.ToStringHelper;
|
||||
|
||||
|
@ -36,7 +38,7 @@ public final class QueryDeparturesResult implements Serializable
|
|||
OK, INVALID_STATION, SERVICE_DOWN
|
||||
}
|
||||
|
||||
public final ResultHeader header;
|
||||
public final @Nullable ResultHeader header;
|
||||
public final Status status;
|
||||
public final List<StationDepartures> stationDepartures = new LinkedList<StationDepartures>();
|
||||
|
||||
|
@ -56,7 +58,8 @@ public final class QueryDeparturesResult implements Serializable
|
|||
{
|
||||
for (final StationDepartures departures : stationDepartures)
|
||||
{
|
||||
if (stationId.equals(departures.location.id))
|
||||
final Location location = departures.location;
|
||||
if (location != null && stationId.equals(location.id))
|
||||
return departures;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.base.MoreObjects.ToStringHelper;
|
||||
|
||||
|
@ -35,7 +37,7 @@ public final class QueryTripsResult implements Serializable
|
|||
OK, AMBIGUOUS, TOO_CLOSE, UNKNOWN_FROM, UNKNOWN_VIA, UNKNOWN_TO, UNRESOLVABLE_ADDRESS, NO_TRIPS, INVALID_DATE, SERVICE_DOWN;
|
||||
}
|
||||
|
||||
public final ResultHeader header;
|
||||
public final @Nullable ResultHeader header;
|
||||
public final Status status;
|
||||
|
||||
public final List<Location> ambiguousFrom;
|
||||
|
|
|
@ -21,6 +21,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
|
||||
/**
|
||||
|
@ -29,7 +31,7 @@ import com.google.common.base.MoreObjects;
|
|||
public final class ResultHeader implements Serializable
|
||||
{
|
||||
public final String serverProduct;
|
||||
public final String serverVersion;
|
||||
public final @Nullable String serverVersion;
|
||||
public final long serverTime;
|
||||
public final Object context;
|
||||
|
||||
|
|
|
@ -22,6 +22,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.base.MoreObjects.ToStringHelper;
|
||||
import com.google.common.base.Objects;
|
||||
|
@ -33,7 +35,7 @@ public final class StationDepartures implements Serializable
|
|||
{
|
||||
public final Location location;
|
||||
public final List<Departure> departures;
|
||||
public final List<LineDestination> lines;
|
||||
public final @Nullable List<LineDestination> lines;
|
||||
|
||||
public StationDepartures(final Location location, final List<Departure> departures, final List<LineDestination> lines)
|
||||
{
|
||||
|
|
|
@ -23,6 +23,8 @@ import java.io.Serializable;
|
|||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.base.MoreObjects.ToStringHelper;
|
||||
import com.google.common.base.Objects;
|
||||
|
@ -33,15 +35,15 @@ import com.google.common.base.Objects;
|
|||
public final class Stop implements Serializable
|
||||
{
|
||||
public final Location location;
|
||||
public final Date plannedArrivalTime;
|
||||
public final Date predictedArrivalTime;
|
||||
public final Position plannedArrivalPosition;
|
||||
public final Position predictedArrivalPosition;
|
||||
public final @Nullable Date plannedArrivalTime;
|
||||
public final @Nullable Date predictedArrivalTime;
|
||||
public final @Nullable Position plannedArrivalPosition;
|
||||
public final @Nullable Position predictedArrivalPosition;
|
||||
public final boolean arrivalCancelled;
|
||||
public final Date plannedDepartureTime;
|
||||
public final Date predictedDepartureTime;
|
||||
public final Position plannedDeparturePosition;
|
||||
public final Position predictedDeparturePosition;
|
||||
public final @Nullable Date plannedDepartureTime;
|
||||
public final @Nullable Date predictedDepartureTime;
|
||||
public final @Nullable Position plannedDeparturePosition;
|
||||
public final @Nullable Position predictedDeparturePosition;
|
||||
public final boolean departureCancelled;
|
||||
|
||||
public Stop(final Location location, final Date plannedArrivalTime, final Date predictedArrivalTime, final Position plannedArrivalPosition,
|
||||
|
@ -125,6 +127,8 @@ public final class Stop implements Serializable
|
|||
|
||||
public Long getArrivalDelay()
|
||||
{
|
||||
final Date plannedArrivalTime = this.plannedArrivalTime;
|
||||
final Date predictedArrivalTime = this.predictedArrivalTime;
|
||||
if (plannedArrivalTime != null && predictedArrivalTime != null)
|
||||
return predictedArrivalTime.getTime() - plannedArrivalTime.getTime();
|
||||
else
|
||||
|
@ -163,6 +167,8 @@ public final class Stop implements Serializable
|
|||
|
||||
public Long getDepartureDelay()
|
||||
{
|
||||
final Date plannedDepartureTime = this.plannedDepartureTime;
|
||||
final Date predictedDepartureTime = this.predictedDepartureTime;
|
||||
if (plannedDepartureTime != null && predictedDepartureTime != null)
|
||||
return predictedDepartureTime.getTime() - plannedDepartureTime.getTime();
|
||||
else
|
||||
|
@ -186,6 +192,7 @@ public final class Stop implements Serializable
|
|||
|
||||
public Date getMinTime()
|
||||
{
|
||||
final Date predictedDepartureTime = this.predictedDepartureTime;
|
||||
if (plannedDepartureTime == null || (predictedDepartureTime != null && predictedDepartureTime.before(plannedDepartureTime)))
|
||||
return predictedDepartureTime;
|
||||
else
|
||||
|
@ -194,6 +201,7 @@ public final class Stop implements Serializable
|
|||
|
||||
public Date getMaxTime()
|
||||
{
|
||||
final Date predictedArrivalTime = this.predictedArrivalTime;
|
||||
if (plannedArrivalTime == null || (predictedArrivalTime != null && predictedArrivalTime.after(plannedArrivalTime)))
|
||||
return predictedArrivalTime;
|
||||
else
|
||||
|
|
|
@ -25,6 +25,8 @@ import java.util.Collections;
|
|||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.base.MoreObjects.ToStringHelper;
|
||||
|
||||
|
@ -38,7 +40,7 @@ public final class SuggestLocationsResult implements Serializable
|
|||
OK, SERVICE_DOWN
|
||||
}
|
||||
|
||||
public final ResultHeader header;
|
||||
public final @Nullable ResultHeader header;
|
||||
public final Status status;
|
||||
private final List<SuggestedLocation> suggestedLocations;
|
||||
|
||||
|
|
|
@ -27,6 +27,8 @@ import java.util.List;
|
|||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.base.MoreObjects.ToStringHelper;
|
||||
import com.google.common.base.Objects;
|
||||
|
@ -65,7 +67,7 @@ public final class Trip implements Serializable
|
|||
return legs.get(0).getDepartureTime();
|
||||
}
|
||||
|
||||
public Public getFirstPublicLeg()
|
||||
public @Nullable Public getFirstPublicLeg()
|
||||
{
|
||||
for (final Leg leg : legs)
|
||||
if (leg instanceof Public)
|
||||
|
@ -74,7 +76,7 @@ public final class Trip implements Serializable
|
|||
return null;
|
||||
}
|
||||
|
||||
public Date getFirstPublicLegDepartureTime()
|
||||
public @Nullable Date getFirstPublicLegDepartureTime()
|
||||
{
|
||||
final Public firstPublicLeg = getFirstPublicLeg();
|
||||
if (firstPublicLeg != null)
|
||||
|
@ -88,7 +90,7 @@ public final class Trip implements Serializable
|
|||
return legs.get(legs.size() - 1).getArrivalTime();
|
||||
}
|
||||
|
||||
public Public getLastPublicLeg()
|
||||
public @Nullable Public getLastPublicLeg()
|
||||
{
|
||||
for (int i = legs.size() - 1; i >= 0; i--)
|
||||
{
|
||||
|
@ -100,7 +102,7 @@ public final class Trip implements Serializable
|
|||
return null;
|
||||
}
|
||||
|
||||
public Date getLastPublicLegArrivalTime()
|
||||
public @Nullable Date getLastPublicLegArrivalTime()
|
||||
{
|
||||
final Public lastPublicLeg = getLastPublicLeg();
|
||||
if (lastPublicLeg != null)
|
||||
|
@ -127,7 +129,7 @@ public final class Trip implements Serializable
|
|||
*
|
||||
* @return duration in ms, or null if there are no public legs
|
||||
*/
|
||||
public Long getPublicDuration()
|
||||
public @Nullable Long getPublicDuration()
|
||||
{
|
||||
final Date first = getFirstPublicLegDepartureTime();
|
||||
final Date last = getLastPublicLegArrivalTime();
|
||||
|
@ -217,8 +219,12 @@ public final class Trip implements Serializable
|
|||
else if (leg instanceof Public)
|
||||
{
|
||||
final Public publicLeg = (Public) leg;
|
||||
builder.append(publicLeg.departureStop.plannedDepartureTime.getTime()).append('-');
|
||||
builder.append(publicLeg.arrivalStop.plannedArrivalTime.getTime()).append('-');
|
||||
final Date plannedDepartureTime = publicLeg.departureStop.plannedDepartureTime;
|
||||
if (plannedDepartureTime != null)
|
||||
builder.append(plannedDepartureTime.getTime()).append('-');
|
||||
final Date plannedArrivalTime = publicLeg.arrivalStop.plannedArrivalTime;
|
||||
if (plannedArrivalTime != null)
|
||||
builder.append(plannedArrivalTime.getTime()).append('-');
|
||||
final Line line = publicLeg.line;
|
||||
builder.append(line.productCode());
|
||||
builder.append(line.label);
|
||||
|
@ -294,11 +300,11 @@ public final class Trip implements Serializable
|
|||
private static final long serialVersionUID = 1312066446239817422L;
|
||||
|
||||
public final Line line;
|
||||
public final Location destination;
|
||||
public final @Nullable Location destination;
|
||||
public final Stop departureStop;
|
||||
public final Stop arrivalStop;
|
||||
public final List<Stop> intermediateStops;
|
||||
public final String message;
|
||||
public final @Nullable List<Stop> intermediateStops;
|
||||
public final @Nullable String message;
|
||||
|
||||
public Public(final Line line, final Location destination, final Stop departureStop, final Stop arrivalStop,
|
||||
final List<Stop> intermediateStops, final List<Point> path, final String message)
|
||||
|
|
|
@ -7,6 +7,8 @@ package de.schildbach.pte.util;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
|
@ -131,7 +133,7 @@ public final class XmlPullUtil
|
|||
throw new IllegalStateException("expecting attribute: " + attrName);
|
||||
}
|
||||
|
||||
public static String optAttr(final XmlPullParser pp, final String attrName, final String defaultValue)
|
||||
public static String optAttr(final XmlPullParser pp, final String attrName, final @Nullable String defaultValue)
|
||||
{
|
||||
final String attr = pp.getAttributeValue(null, attrName);
|
||||
|
||||
|
@ -189,8 +191,8 @@ public final class XmlPullUtil
|
|||
return value != null ? value.trim() : null;
|
||||
}
|
||||
|
||||
public static String optValueTag(final XmlPullParser pp, final String tagName, final String defaultValue) throws XmlPullParserException,
|
||||
IOException
|
||||
public static String optValueTag(final XmlPullParser pp, final String tagName, final @Nullable String defaultValue)
|
||||
throws XmlPullParserException, IOException
|
||||
{
|
||||
if (XmlPullUtil.test(pp, tagName))
|
||||
{
|
||||
|
@ -236,9 +238,6 @@ public final class XmlPullUtil
|
|||
|
||||
public static String nextText(final XmlPullParser pp, final String namespace, final String name) throws IOException, XmlPullParserException
|
||||
{
|
||||
if (name == null)
|
||||
throw new XmlPullParserException("name for element can not be null");
|
||||
|
||||
pp.require(XmlPullParser.START_TAG, namespace, name);
|
||||
final String text = pp.nextText();
|
||||
|
||||
|
|
|
@ -24,6 +24,8 @@ import java.util.Date;
|
|||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import de.schildbach.pte.NetworkProvider;
|
||||
import de.schildbach.pte.NetworkProvider.Accessibility;
|
||||
import de.schildbach.pte.NetworkProvider.WalkSpeed;
|
||||
|
@ -126,8 +128,9 @@ public abstract class AbstractProviderLiveTest
|
|||
return provider.suggestLocations(constraint);
|
||||
}
|
||||
|
||||
protected final QueryTripsResult queryTrips(final Location from, final Location via, final Location to, final Date date, final boolean dep,
|
||||
final Set<Product> products, final WalkSpeed walkSpeed, final Accessibility accessibility) throws IOException
|
||||
protected final QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to, final Date date,
|
||||
final boolean dep, final @Nullable Set<Product> products, final @Nullable WalkSpeed walkSpeed, final @Nullable Accessibility accessibility)
|
||||
throws IOException
|
||||
{
|
||||
return provider.queryTrips(from, via, to, date, dep, products, walkSpeed, accessibility, null);
|
||||
}
|
||||
|
|
|
@ -18,17 +18,20 @@
|
|||
package de.schildbach.pte.live;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import de.schildbach.pte.NetworkProvider.Accessibility;
|
||||
import de.schildbach.pte.NetworkProvider.WalkSpeed;
|
||||
import de.schildbach.pte.ParisProvider;
|
||||
import de.schildbach.pte.dto.LineDestination;
|
||||
import de.schildbach.pte.dto.Location;
|
||||
import de.schildbach.pte.dto.LocationType;
|
||||
import de.schildbach.pte.dto.NearbyLocationsResult;
|
||||
|
@ -103,7 +106,9 @@ public class ParisProviderLiveTest extends AbstractProviderLiveTest
|
|||
assertEquals(QueryDeparturesResult.Status.OK, result.status);
|
||||
assertEquals(1, result.stationDepartures.size());
|
||||
assertTrue(result.stationDepartures.get(0).departures.size() <= maxDepartures);
|
||||
assertTrue(result.stationDepartures.get(0).lines.size() >= 1);
|
||||
final List<LineDestination> lines = result.stationDepartures.get(0).lines;
|
||||
assertNotNull(lines);
|
||||
assertTrue(lines.size() >= 1);
|
||||
print(result);
|
||||
}
|
||||
|
||||
|
@ -119,7 +124,9 @@ public class ParisProviderLiveTest extends AbstractProviderLiveTest
|
|||
for (StationDepartures stationDepartures : result.stationDepartures)
|
||||
{
|
||||
nbDepartures += stationDepartures.departures.size();
|
||||
nbLines += stationDepartures.lines.size();
|
||||
final List<LineDestination> lines = stationDepartures.lines;
|
||||
assertNotNull(lines);
|
||||
nbLines += lines.size();
|
||||
}
|
||||
assertTrue(nbDepartures <= maxDepartures);
|
||||
assertTrue(nbLines >= 2);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue