changeset 3474:4b8b9b2ac873

Doc added, uses static map in converter. flys-client/trunk@5168 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 08 Aug 2012 07:00:52 +0000
parents 60bf22a14ed8
children 9b29facddbd1
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/server/meta/Converter.java
diffstat 2 files changed, 21 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Mon Jul 30 09:17:35 2012 +0000
+++ b/flys-client/ChangeLog	Wed Aug 08 07:00:52 2012 +0000
@@ -1,3 +1,9 @@
+2012-08-08	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/server/meta/Converter.java:
+	  Documentation added, use static map instead of population in
+	  constructor.
+
 2012-07-30	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/client/ui/fixation/FixQSelectPanel.java,
--- a/flys-client/src/main/java/de/intevation/flys/client/server/meta/Converter.java	Mon Jul 30 09:17:35 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/meta/Converter.java	Wed Aug 08 07:00:52 2012 +0000
@@ -19,6 +19,10 @@
 
 import de.intevation.artifacts.common.utils.XMLUtils;
 
+/**
+ * Converts document parts (meta-data xml) to datacagenodes/trees,
+ * which are shown in datacage widgets.
+ */
 public class Converter
 {
     private static final Logger logger = Logger.getLogger(Converter.class);
@@ -58,7 +62,7 @@
         }
     } // I18NConverter
 
-    protected Map<String, NodeConverter> converters;
+    private static Map<String, NodeConverter> converters;
 
     protected void convertChildren(DataCageNode parent, Element sub) {
         //System.err.println("convertChildren called");
@@ -78,26 +82,25 @@
         } // for all children
     }
 
-    public Converter() {
-        converters = new HashMap<String, NodeConverter>();
-        registerConverters();
-    }
-
     public static final NodeConverter NAME_CONVERTER = new NameConverter();
     public static final NodeConverter I18N_CONVERTER = new I18NConverter();
 
-    protected void registerConverters() {
-        logger.debug("register converters called");
+    static {
         converters.put("river",      NAME_CONVERTER);
         converters.put("gauge",      NAME_CONVERTER);
         converters.put("historical", NAME_CONVERTER);
         converters.put("column",     NAME_CONVERTER);
     }
 
+    public Converter() {
+        converters = new HashMap<String, NodeConverter>();
+    }
+
     public DataCageTree convert(Document document) {
         logger.debug("convert called");
         //System.err.println(XMLUtils.toString(document));
 
+        // TODO Fetch descriptions/tooltips if any...
         ArrayList<DataCageNode> roots = new ArrayList<DataCageNode>();
         NodeList nodes = document.getChildNodes();
         for (int i = 0, N = nodes.getLength(); i < N; ++i) {
@@ -116,6 +119,10 @@
             : new DataCageTree(roots.get(0));
     }
 
+    
+    /**
+     * Creates key/value pairs from Nodes Attributes.
+     */
     public static AttrList toAttrList(NamedNodeMap nodeMap) {
         if (nodeMap == null) {
             return null;

http://dive4elements.wald.intevation.org