Mercurial > dive4elements > framework
diff artifacts-common/src/main/java/de/intevation/artifacts/common/utils/CreationFilter.java @ 325:4022ea69d1cb
Write filters to create document if they are given.
artifacts/trunk@2567 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 24 Aug 2011 14:35:27 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts-common/src/main/java/de/intevation/artifacts/common/utils/CreationFilter.java Wed Aug 24 14:35:27 2011 +0000 @@ -0,0 +1,61 @@ +package de.intevation.artifacts.common.utils; + +import java.util.List; +import java.util.Map; +import java.util.HashMap; + +import org.w3c.dom.Element; + +public class CreationFilter +{ + public static class Facet { + + protected String name; + protected String index; + + public Facet() { + } + + public Facet(String name, String index) { + this.name = name; + this.index = index; + } + + public String getName() { + return name; + } + + public String getIndex() { + return index; + } + } + + protected Map<String, List<Facet>> outs; + + public CreationFilter() { + outs = new HashMap<String, List<Facet>>(); + } + + public void add(String out, List<Facet> facets) { + outs.put(out, facets); + } + + public Element toXML(XMLUtils.ElementCreator ec) { + Element filter = ec.create("filter"); + + for (Map.Entry<String, List<Facet>> entry: outs.entrySet()) { + Element out = ec.create("out"); + out.setAttribute("name", entry.getKey()); + for (Facet facet: entry.getValue()) { + Element f = ec.create("facet"); + f.setAttribute("name", facet.getName()); + f.setAttribute("index", facet.getIndex()); + out.appendChild(f); + } + filter.appendChild(out); + } + + return filter; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :