Mercurial > dive4elements > framework
comparison 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 |
comparison
equal
deleted
inserted
replaced
324:ee6e1b2f137a | 325:4022ea69d1cb |
---|---|
1 package de.intevation.artifacts.common.utils; | |
2 | |
3 import java.util.List; | |
4 import java.util.Map; | |
5 import java.util.HashMap; | |
6 | |
7 import org.w3c.dom.Element; | |
8 | |
9 public class CreationFilter | |
10 { | |
11 public static class Facet { | |
12 | |
13 protected String name; | |
14 protected String index; | |
15 | |
16 public Facet() { | |
17 } | |
18 | |
19 public Facet(String name, String index) { | |
20 this.name = name; | |
21 this.index = index; | |
22 } | |
23 | |
24 public String getName() { | |
25 return name; | |
26 } | |
27 | |
28 public String getIndex() { | |
29 return index; | |
30 } | |
31 } | |
32 | |
33 protected Map<String, List<Facet>> outs; | |
34 | |
35 public CreationFilter() { | |
36 outs = new HashMap<String, List<Facet>>(); | |
37 } | |
38 | |
39 public void add(String out, List<Facet> facets) { | |
40 outs.put(out, facets); | |
41 } | |
42 | |
43 public Element toXML(XMLUtils.ElementCreator ec) { | |
44 Element filter = ec.create("filter"); | |
45 | |
46 for (Map.Entry<String, List<Facet>> entry: outs.entrySet()) { | |
47 Element out = ec.create("out"); | |
48 out.setAttribute("name", entry.getKey()); | |
49 for (Facet facet: entry.getValue()) { | |
50 Element f = ec.create("facet"); | |
51 f.setAttribute("name", facet.getName()); | |
52 f.setAttribute("index", facet.getIndex()); | |
53 out.appendChild(f); | |
54 } | |
55 filter.appendChild(out); | |
56 } | |
57 | |
58 return filter; | |
59 } | |
60 } | |
61 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |