# HG changeset patch # User Sascha L. Teichmann # Date 1344500524 0 # Node ID 83845aa322ea07be48d0a7d2c70e702b5b0c024a # Parent b21840188264c8fda56e4c30c40c629fa56b296e XMLFileFeatures: Cosmetics. flys-client/trunk@5181 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r b21840188264 -r 83845aa322ea flys-client/ChangeLog --- 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 +2012-08-09 Sascha L. Teichmann + + * 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 * src/main/java/de/intevation/flys/client/server/meta/Converter.java: Removed trailing whitespace. diff -r b21840188264 -r 83845aa322ea flys-client/src/main/java/de/intevation/flys/client/server/features/XMLFileFeatures.java --- 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> featuremap = new Hashtable>(); + private Map> featuremap = + new HashMap>(); 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 allowed = new ArrayList(features.getLength()); - for (int j=0, l = features.getLength(); j < l; j++) { + if (features == null) { + continue; + } + + int N = features.getLength(); + + if (N > 0) { + List allowed = new ArrayList(N); + for (int j = 0; j < N; j++) { Node featurenode = features.item(j); String featurename = featurenode.getNodeValue(); @@ -76,11 +85,11 @@ @Override public List getFeatures(List roles) { - List features = new LinkedList(); + List features = new ArrayList(); for (String role: roles) { List allowed = this.featuremap.get(role); - if (!allowed.isEmpty()) { + if (allowed != null) { features.addAll(allowed); } }