changeset 3484:83845aa322ea

XMLFileFeatures: Cosmetics. flys-client/trunk@5181 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 09 Aug 2012 08:22:04 +0000
parents b21840188264
children 71ba3cf3ec5e
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/server/features/XMLFileFeatures.java
diffstat 2 files changed, 26 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Thu Aug 09 08:05:51 2012 +0000
+++ b/flys-client/ChangeLog	Thu Aug 09 08:22:04 2012 +0000
@@ -1,4 +1,9 @@
-2012-07-30	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+2012-08-09	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/server/features/XMLFileFeatures.java:
+	  Used HashMap instead of Hashtable. Limit to 80 chars per line.
+
+2012-08-09	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/server/meta/Converter.java:
 	  Removed trailing whitespace.
--- a/flys-client/src/main/java/de/intevation/flys/client/server/features/XMLFileFeatures.java	Thu Aug 09 08:05:51 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/features/XMLFileFeatures.java	Thu Aug 09 08:22:04 2012 +0000
@@ -4,9 +4,10 @@
 import java.io.IOException;
 
 import java.util.ArrayList;
-import java.util.Hashtable;
+import java.util.HashMap;
+import java.util.LinkedList;
 import java.util.List;
-import java.util.LinkedList;
+import java.util.Map;
 
 import javax.xml.xpath.XPathConstants;
 
@@ -21,9 +22,11 @@
 
 public class XMLFileFeatures implements Features {
 
-    private static final Logger logger = Logger.getLogger(XMLFileFeatures.class);
+    private static final Logger logger =
+        Logger.getLogger(XMLFileFeatures.class);
 
-    private Hashtable<String, List<String>> featuremap = new Hashtable<String, List<String>>();
+    private Map<String, List<String>> featuremap =
+        new HashMap<String, List<String>>();
 
     private final static String XPATH_FEATURES = "ftr:feature/child::text()";
     private final static String XPATH_ROLES    = "/ftr:features/ftr:role";
@@ -40,11 +43,11 @@
                 XPathConstants.NODESET,
                 FeaturesNamespaceContext.INSTANCE);
 
-            for(int i=0, m = roles.getLength(); i < m; i++) {
+            for(int i = 0, m = roles.getLength(); i < m; i++) {
                 Element rolenode = (Element)roles.item(i);
 
                 String name = rolenode.getAttributeNS(
-                        FeaturesNamespaceContext.NAMESPACE_URI, "name");
+                    FeaturesNamespaceContext.NAMESPACE_URI, "name");
 
                 logger.debug("Found role: " + name);
 
@@ -54,9 +57,15 @@
                     XPathConstants.NODESET,
                     FeaturesNamespaceContext.INSTANCE);
 
-                if (features.getLength() > 0) {
-                    List<String> allowed = new ArrayList<String>(features.getLength());
-                    for (int j=0, l = features.getLength(); j < l; j++) {
+                if (features == null) {
+                    continue;
+                }
+
+                int N = features.getLength();
+
+                if (N > 0) {
+                    List<String> allowed = new ArrayList<String>(N);
+                    for (int j = 0; j < N; j++) {
                         Node featurenode = features.item(j);
                         String featurename = featurenode.getNodeValue();
 
@@ -76,11 +85,11 @@
 
     @Override
     public List<String> getFeatures(List<String> roles) {
-        List<String> features = new LinkedList<String>();
+        List<String> features = new ArrayList<String>();
 
         for (String role: roles) {
             List<String> allowed = this.featuremap.get(role);
-            if (!allowed.isEmpty()) {
+            if (allowed != null) {
                 features.addAll(allowed);
             }
         }

http://dive4elements.wald.intevation.org