mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-07 15:48:49 +00:00
ParserUtils: extract hardcoded EUR currency into constant
This commit is contained in:
parent
c6b63ce257
commit
de2a0a614f
3 changed files with 9 additions and 7 deletions
|
@ -23,7 +23,6 @@ import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Currency;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -497,9 +496,9 @@ public class NegentweeProvider extends AbstractNetworkProvider {
|
||||||
List<Fare> tripFares = null;
|
List<Fare> tripFares = null;
|
||||||
if (fareInfo.getBoolean("complete")) {
|
if (fareInfo.getBoolean("complete")) {
|
||||||
tripFares = Arrays.asList(
|
tripFares = Arrays.asList(
|
||||||
new Fare("Full-price", Fare.Type.ADULT, Currency.getInstance("EUR"),
|
new Fare("Full-price", Fare.Type.ADULT, ParserUtils.CURRENCY_EUR,
|
||||||
fareInfo.getInt("fullPriceCents") / 100, null, null),
|
fareInfo.getInt("fullPriceCents") / 100, null, null),
|
||||||
new Fare("Reduced-price", Fare.Type.ADULT, Currency.getInstance("EUR"),
|
new Fare("Reduced-price", Fare.Type.ADULT, ParserUtils.CURRENCY_EUR,
|
||||||
fareInfo.getInt("reducedPriceCents") / 100, null, null));
|
fareInfo.getInt("reducedPriceCents") / 100, null, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -531,7 +530,7 @@ public class NegentweeProvider extends AbstractNetworkProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Fare(fareLeg.getString("operatorString"), Fare.Type.ADULT, Currency.getInstance("EUR"), farePrice,
|
return new Fare(fareLeg.getString("operatorString"), Fare.Type.ADULT, ParserUtils.CURRENCY_EUR, farePrice,
|
||||||
null, null);
|
null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,6 @@ import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Currency;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
|
@ -41,6 +40,7 @@ import java.util.regex.Pattern;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import de.schildbach.pte.util.ParserUtils;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
@ -865,11 +865,11 @@ public class VrsProvider extends AbstractNetworkProvider {
|
||||||
// "4"
|
// "4"
|
||||||
|
|
||||||
if (name != null && price != 0.0 && level != null) {
|
if (name != null && price != 0.0 && level != null) {
|
||||||
fares.add(new Fare(name, Fare.Type.ADULT, Currency.getInstance("EUR"), price, level, null /* units */));
|
fares.add(new Fare(name, Fare.Type.ADULT, ParserUtils.CURRENCY_EUR, price, level, null /* units */));
|
||||||
} else if (name != null && name.equals("NRW-Tarif") && text != null) {
|
} else if (name != null && name.equals("NRW-Tarif") && text != null) {
|
||||||
Matcher matcher = nrwTarifPattern.matcher(text);
|
Matcher matcher = nrwTarifPattern.matcher(text);
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
fares.add(new Fare(name, Fare.Type.ADULT, Currency.getInstance("EUR"),
|
fares.add(new Fare(name, Fare.Type.ADULT, ParserUtils.CURRENCY_EUR,
|
||||||
Float.parseFloat(matcher.group(0).replace(",", ".")), null /* level */, null /* units */));
|
Float.parseFloat(matcher.group(0).replace(",", ".")), null /* level */, null /* units */));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import java.net.URLDecoder;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Currency;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
|
@ -40,6 +41,8 @@ public final class ParserUtils {
|
||||||
private static final Pattern P_HTML_BREAKS = Pattern.compile("(<br\\s*/>)+",
|
private static final Pattern P_HTML_BREAKS = Pattern.compile("(<br\\s*/>)+",
|
||||||
Pattern.DOTALL | Pattern.CASE_INSENSITIVE);
|
Pattern.DOTALL | Pattern.CASE_INSENSITIVE);
|
||||||
|
|
||||||
|
public static final Currency CURRENCY_EUR = Currency.getInstance("EUR");
|
||||||
|
|
||||||
public static String formatHtml(final CharSequence html) {
|
public static String formatHtml(final CharSequence html) {
|
||||||
if (html == null)
|
if (html == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue