Mercurial > dive4elements > gnv-client
comparison gnv/src/main/java/de/intevation/gnv/action/sessionmodel/DiagrammOptions.java @ 967:c7f8a9b4b006
Improved parsing i18n values of chart/histogram options (issue289).
gnv/trunk@1129 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 26 May 2010 17:03:29 +0000 |
parents | 3549253ecd7b |
children | 28a0628b11b0 |
comparison
equal
deleted
inserted
replaced
966:13de46229f63 | 967:c7f8a9b4b006 |
---|---|
1 package de.intevation.gnv.action.sessionmodel; | 1 package de.intevation.gnv.action.sessionmodel; |
2 | 2 |
3 import java.text.NumberFormat; | |
4 | |
3 import java.util.HashMap; | 5 import java.util.HashMap; |
6 import java.util.Locale; | |
4 import java.util.Map; | 7 import java.util.Map; |
5 | 8 |
6 /** | 9 /** |
7 * Stores key-value pairs used to save user input for changing diagram | 10 * Stores key-value pairs used to save user input for changing diagram |
8 * attributes. | 11 * attributes. |
9 * | 12 * |
10 * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a> | 13 * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a> |
11 */ | 14 */ |
12 public class DiagrammOptions { | 15 public class DiagrammOptions { |
13 | 16 |
14 private Map<String, String> values = new HashMap<String, String>(); | 17 private Map<String, Object> values = new HashMap<String, Object>(); |
15 | 18 |
16 /** | 19 /** |
17 * Constructor | 20 * Constructor |
18 */ | 21 */ |
19 public DiagrammOptions() { | 22 public DiagrammOptions() { |
23 /** | 26 /** |
24 * Returns the Value to a given Key | 27 * Returns the Value to a given Key |
25 * @param key The key of the value that should be returned. | 28 * @param key The key of the value that should be returned. |
26 * @return the value. | 29 * @return the value. |
27 */ | 30 */ |
28 public String getValue(String key) { | 31 public Object getValue(String key) { |
29 return this.values.get(key); | 32 return this.values.get(key); |
30 } | 33 } |
31 | 34 |
35 | |
36 /** | |
37 * Returns the value as string. | |
38 * @param key The key of the value that should be returned. | |
39 * @param locale A locale object used to format numbers. | |
40 * @return the value as string. | |
41 */ | |
42 public String getValue(String key, Locale locale) { | |
43 Object obj = values.get(key); | |
44 | |
45 if (obj instanceof Double && locale != null) { | |
46 Double value = (Double) obj; | |
47 NumberFormat format = NumberFormat.getNumberInstance(locale); | |
48 | |
49 return format.format(value); | |
50 } | |
51 | |
52 return (String) obj; | |
53 } | |
32 | 54 |
33 /** | 55 /** |
34 * Set a value with the given key. | 56 * Set a value with the given key. |
35 * | 57 * |
36 * @param key The given key. | 58 * @param key The given key. |
37 * @param value The value to be stored. | 59 * @param value The value to be stored. |
38 */ | 60 */ |
39 public void setValue(String key, String value) { | 61 public void setValue(String key, Object value) { |
40 this.values.put(key, value); | 62 values.put(key, value); |
41 } | 63 } |
42 } | 64 } |
43 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : | 65 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |