Java tutorial
/* * Copyright 2010-2015 the original author or authors. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package de.schildbach.pte; import static com.google.common.base.Preconditions.checkNotNull; import java.io.IOException; import java.util.Date; import java.util.EnumSet; import java.util.Set; import javax.annotation.Nullable; import com.google.common.base.Strings; import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.NearbyLocationsResult; import de.schildbach.pte.dto.Product; import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryTripsContext; import de.schildbach.pte.dto.QueryTripsResult; import de.schildbach.pte.dto.SuggestLocationsResult; import okhttp3.HttpUrl; /** * @author Andreas Schildbach */ public class StvProvider extends AbstractEfaProvider { private static final HttpUrl API_BASE = HttpUrl.parse("http://appefa10.verbundlinie.at/android/"); public StvProvider() { super(NetworkId.STV, API_BASE); setIncludeRegionId(false); } @Override public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location, final int maxDistance, final int maxLocations) throws IOException { if (location.hasLocation()) return mobileCoordRequest(types, location.lat, location.lon, maxDistance, maxLocations); if (location.type != LocationType.STATION) throw new IllegalArgumentException("cannot handle: " + location.type); throw new IllegalArgumentException("station"); // TODO } @Override public QueryDeparturesResult queryDepartures(final String stationId, final @Nullable Date time, final int maxDepartures, final boolean equivs) throws IOException { checkNotNull(Strings.emptyToNull(stationId)); return queryDeparturesMobile(stationId, time, maxDepartures, equivs); } @Override public SuggestLocationsResult suggestLocations(final CharSequence constraint) throws IOException { return mobileStopfinderRequest(new Location(LocationType.ANY, null, null, constraint.toString())); } @Override 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 Optimize optimize, final @Nullable WalkSpeed walkSpeed, final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException { return queryTripsMobile(from, via, to, date, dep, products, optimize, walkSpeed, accessibility, options); } @Override public QueryTripsResult queryMoreTrips(final QueryTripsContext contextObj, final boolean later) throws IOException { return queryMoreTripsMobile(contextObj, later); } }