From 3e5e9333420ede74d998556c1bbd5888e8ff75ae Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 19 May 2015 10:09:22 -0700 Subject: altoslib: Expose locale and non-locale floating point parsing functions UI bits use locale-specific floating point formats, so parsing those needs to use the locale. Network-based data, like .kml bits need to use non-locale-specific parsing code, so now we've got both APIs available, and each used as appropriate. Signed-off-by: Keith Packard --- altoslib/AltosUnits.java | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'altoslib/AltosUnits.java') diff --git a/altoslib/AltosUnits.java b/altoslib/AltosUnits.java index f6e34e77..e266b243 100644 --- a/altoslib/AltosUnits.java +++ b/altoslib/AltosUnits.java @@ -17,6 +17,8 @@ package org.altusmetrum.altoslib_6; +import java.text.*; + public abstract class AltosUnits { public abstract double value(double v, boolean imperial_units); @@ -29,13 +31,22 @@ public abstract class AltosUnits { public abstract int show_fraction(int width, boolean imperial_units); - public double parse(String s, boolean imperial_units) throws NumberFormatException { - double v = Double.parseDouble(s); + public double parse_locale(String s, boolean imperial_units) throws ParseException { + double v = AltosParse.parse_double_locale(s); + return inverse(v, imperial_units); + } + + public double parse_net(String s, boolean imperial_units) throws ParseException { + double v = AltosParse.parse_double_net(s); return inverse(v, imperial_units); } - public double parse(String s) throws NumberFormatException { - return parse(s, AltosConvert.imperial_units); + public double parse_locale(String s) throws ParseException { + return parse_locale(s, AltosConvert.imperial_units); + } + + public double parse_net(String s) throws ParseException { + return parse_net(s, AltosConvert.imperial_units); } public double value(double v) { @@ -105,4 +116,4 @@ public abstract class AltosUnits { public String say_units(double v) { return say_units(v, AltosConvert.imperial_units); } -} \ No newline at end of file +} -- cgit v1.2.3