diff src/java/de/intevation/mxd/writer/MapScriptWriter.java @ 189:0965f8af70fa

Replace german umlauts and trim strings.
author raimund renkert <raimund.renkert@intevation.de>
date Wed, 20 Jul 2011 15:55:43 +0200
parents 1391f911ee39
children c640fb351f66
line wrap: on
line diff
--- a/src/java/de/intevation/mxd/writer/MapScriptWriter.java	Wed Jul 20 12:40:11 2011 +0200
+++ b/src/java/de/intevation/mxd/writer/MapScriptWriter.java	Wed Jul 20 15:55:43 2011 +0200
@@ -194,11 +194,12 @@
             //The layer name.
             String lname = layerElement.getAttribute("name");
             lname = lname.replaceAll(" ", "");
-            layer.setName(lname);
+            layer.setName(validateString(lname));
             layer.setUnits(units.swigValue());
-            layer.setMetaData("wms_title", layerElement.getAttribute("name"));
+            layer.setMetaData("wms_title", validateString(lname));
             if(layerElement.hasAttribute("group")) {
-                layer.setGroup(layerElement.getAttribute("group"));
+		String group = layerElement.getAttribute("group");
+                layer.setGroup(validateString(group));
             }
 
             //The layer status.
@@ -332,8 +333,10 @@
             Element classElement = (Element)list.item(i);
             classObj co = new classObj(layer);
             String name = classElement.getAttribute("label");
+	    name = validateString(name);
             if (name.equals("")) {
                 name = layerElement.getAttribute("name");
+		name = validateString(name);
                 if (list.getLength() > 1) {
                     name += "-" + i;
                 }
@@ -558,4 +561,21 @@
         }
         return expression;
     }
+
+    /**
+     * Replaces german umlauts and removes leading and trailing whitespaces.
+     *
+     * @param s String
+     */
+    private String validateString (String s) {
+        if (s.equals("")) {
+            return "";
+        }
+        String tmp = s.trim();
+        tmp = tmp.replace ("ö", "oe");
+        tmp = tmp.replace ("ä", "ae");
+        tmp = tmp.replace ("ü", "ue");
+        tmp = tmp.replace ("ß", "ss");
+        return tmp;
+    }
 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)