changeset 669:23fced04ffdb

#103 PART 1: The numbers which are written into the static DESCRIBE part are i18n formatted now. flys-artifacts/trunk@2087 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 08 Jun 2011 13:57:43 +0000
parents 5523f5b889a8
children 8124ca1ecaaa
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DefaultState.java
diffstat 2 files changed, 26 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Wed Jun 08 13:32:56 2011 +0000
+++ b/flys-artifacts/ChangeLog	Wed Jun 08 13:57:43 2011 +0000
@@ -1,3 +1,11 @@
+2011-06-08  Ingo Weinzierl <ingo@intevation.de>
+
+	  flys/issue103 PART 1 (WINFO: Wasserspiegellagenberechnung / Layout-Inkonsistenz)
+
+	* src/main/java/de/intevation/flys/artifacts/states/DefaultState.java:
+	  Selected values are formatted with the current locale. The static part
+	  of the DESCRIBE document will now contain i18n formatted numbers.
+
 2011-06-08  Ingo Weinzierl <ingo@intevation.de>
 
 	  flys/issue93 (WINFO: Benennung der Berechnungsart korrigieren)
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DefaultState.java	Wed Jun 08 13:32:56 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DefaultState.java	Wed Jun 08 13:57:43 2011 +0000
@@ -1,6 +1,8 @@
 package de.intevation.flys.artifacts.states;
 
+import java.text.NumberFormat;
 import java.util.Iterator;
+import java.util.Locale;
 import java.util.Map;
 
 import org.apache.log4j.Logger;
@@ -84,11 +86,22 @@
 
             Element itemElement = creator.create("item");
             creator.addAttr(itemElement, "value", value, true);
-            creator.addAttr(
-                itemElement,
-                "label",
-                Resources.getMsg(meta, value, value),
-                true);
+
+            String attrValue = "";
+            try {
+                // XXX A better way to format the output would be to use the
+                // 'type' value if the data objects.
+                double doubleVal = Double.valueOf(value);
+                Locale         l = Resources.getLocale(meta);
+                NumberFormat  nf = NumberFormat.getInstance(l);
+
+                attrValue = nf.format(doubleVal);
+            }
+            catch (NumberFormatException nfe) {
+                attrValue = Resources.getMsg(meta, value, value);
+            }
+
+            creator.addAttr(itemElement, "label", attrValue, true);
 
             dataElement.appendChild(itemElement);
             ui.appendChild(dataElement);

http://dive4elements.wald.intevation.org