Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/utils/Formatter.java @ 2290:6f4a1f513e89
Calculation error report: i18n the km of the error report.
flys-artifacts/trunk@3954 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 08 Feb 2012 09:33:06 +0000 |
parents | ea173e4c07c7 |
children | ff558d0332e2 |
comparison
equal
deleted
inserted
replaced
2289:fe3ea0f16098 | 2290:6f4a1f513e89 |
---|---|
3 import java.text.DateFormat; | 3 import java.text.DateFormat; |
4 import java.text.NumberFormat; | 4 import java.text.NumberFormat; |
5 import java.util.Locale; | 5 import java.util.Locale; |
6 | 6 |
7 import de.intevation.artifacts.CallContext; | 7 import de.intevation.artifacts.CallContext; |
8 import de.intevation.artifacts.CallMeta; | |
8 | 9 |
9 import de.intevation.flys.artifacts.resources.Resources; | 10 import de.intevation.flys.artifacts.resources.Resources; |
10 | 11 |
11 | 12 |
12 public final class Formatter { | 13 public final class Formatter { |
14 | |
15 // KMS IN ERROR REPORTS. | |
16 public static final int CALCULATION_REPORT_KM_MIN_DIGITS = 0; | |
17 public static final int CALCULATION_REPORT_KM_MAX_DIGITS = 3; | |
13 | 18 |
14 // WATERLEVEL FORMATTER CONSTANTS | 19 // WATERLEVEL FORMATTER CONSTANTS |
15 public static final int WATERLEVEL_KM_MIN_DIGITS = 3; | 20 public static final int WATERLEVEL_KM_MIN_DIGITS = 3; |
16 public static final int WATERLEVEL_KM_MAX_DIGITS = 3; | 21 public static final int WATERLEVEL_KM_MAX_DIGITS = 3; |
17 public static final int WATERLEVEL_W_MIN_DIGITS = 0; | 22 public static final int WATERLEVEL_W_MIN_DIGITS = 0; |
41 public static final int DURATION_Q_MAX_DIGITS = 1; | 46 public static final int DURATION_Q_MAX_DIGITS = 1; |
42 public static final int DURATION_D_MIN_DIGITS = 0; | 47 public static final int DURATION_D_MIN_DIGITS = 0; |
43 public static final int DURATION_D_MAX_DIGITS = 0; | 48 public static final int DURATION_D_MAX_DIGITS = 0; |
44 | 49 |
45 | 50 |
46 public static NumberFormat getFormatter(CallContext c, int min, int max){ | 51 public static NumberFormat getFormatter(CallMeta m, int min, int max){ |
47 Locale locale = Resources.getLocale(c.getMeta()); | 52 Locale locale = Resources.getLocale(m); |
48 NumberFormat nf = NumberFormat.getInstance(locale); | 53 NumberFormat nf = NumberFormat.getInstance(locale); |
49 | 54 |
50 nf.setMaximumFractionDigits(max); | 55 nf.setMaximumFractionDigits(max); |
51 nf.setMinimumFractionDigits(min); | 56 nf.setMinimumFractionDigits(min); |
52 | 57 |
53 return nf; | 58 return nf; |
59 } | |
60 | |
61 public static NumberFormat getFormatter(CallContext c, int min, int max){ | |
62 return getFormatter(c.getMeta(), min, max); | |
54 } | 63 } |
55 | 64 |
56 | 65 |
57 /** | 66 /** |
58 * Returns a number formatter with no max or min digits set. | 67 * Returns a number formatter with no max or min digits set. |
206 return getFormatter( | 215 return getFormatter( |
207 context, | 216 context, |
208 DURATION_D_MIN_DIGITS, | 217 DURATION_D_MIN_DIGITS, |
209 DURATION_D_MAX_DIGITS); | 218 DURATION_D_MAX_DIGITS); |
210 } | 219 } |
220 | |
221 public static NumberFormat getCalculationKm(CallMeta meta) { | |
222 return getFormatter( | |
223 meta, | |
224 CALCULATION_REPORT_KM_MIN_DIGITS, | |
225 CALCULATION_REPORT_KM_MAX_DIGITS); | |
226 } | |
211 } | 227 } |
212 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 228 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |