[PATCH] Allow comma separated names in "names" attribute in out generators to allow registering for more than one name. Old "name" attribute is removed
Wald Commits
scm-commit at wald.intevation.org
Fri Sep 20 15:42:25 CEST 2013
# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1379684541 -7200
# Branch generator-refactoring
# Node ID beb9e94f04d3a8aa3bdd5d146e24ce4a4c31d7fa
# Parent 4e597d4353987a102e7f0bf84d0c6d7d88a09b5d
Allow comma separated names in "names" attribute in out generators to allow registering for more than one name. Old "name" attribute is removed.
diff -r 4e597d435398 -r beb9e94f04d3 artifacts/src/main/java/org/dive4elements/river/artifacts/context/RiverContextFactory.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/context/RiverContextFactory.java Fri Sep 20 15:29:02 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/context/RiverContextFactory.java Fri Sep 20 15:42:21 2013 +0200
@@ -332,23 +332,31 @@
for (int i = 0; i < num; i++) {
Element item = (Element)outGenerators.item(i);
- String name = item.getAttribute("name");
+ String name = item.getAttribute("names");
String clazz = item.getAttribute("class");
if (name.isEmpty() || clazz.isEmpty()) {
continue;
}
+ Class<OutGenerator> generatorClass = null;
+
try {
- generators.put(
- name,
- new Pair<Class<OutGenerator>, Element>(
- (Class<OutGenerator>)Class.forName(clazz), item));
-
- idx++;
+ generatorClass = (Class<OutGenerator>)Class.forName(clazz);
}
catch (ClassNotFoundException cnfe) {
logger.warn(cnfe, cnfe);
+ continue;
+ }
+
+ Pair<Class<OutGenerator>, Element> pair =
+ new Pair<Class<OutGenerator>, Element>(generatorClass, item);
+
+ for (String key: name.split("[\\s,]")) {
+ if (!(key = key.trim()).isEmpty()) {
+ generators.put(key, pair);
+ idx++;
+ }
}
}
More information about the Dive4elements-commits
mailing list