annotate artifacts-common/src/main/java/org/dive4elements/artifacts/common/utils/CreationFilter.java @ 472:783cc1b6b615

Moved directories to org.dive4elements
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 25 Apr 2013 10:53:15 +0200
parents artifacts-common/src/main/java/de/intevation/artifacts/common/utils/CreationFilter.java@4022ea69d1cb
children 415df0fc4fa1
rev   line source
325
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1 package de.intevation.artifacts.common.utils;
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
2
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
3 import java.util.List;
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
4 import java.util.Map;
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
5 import java.util.HashMap;
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
6
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
7 import org.w3c.dom.Element;
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
8
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
9 public class CreationFilter
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
10 {
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
11 public static class Facet {
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
12
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
13 protected String name;
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
14 protected String index;
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
15
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
16 public Facet() {
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
17 }
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
18
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
19 public Facet(String name, String index) {
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
20 this.name = name;
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
21 this.index = index;
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
22 }
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
23
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
24 public String getName() {
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
25 return name;
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
26 }
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
27
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28 public String getIndex() {
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
29 return index;
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
30 }
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
31 }
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
32
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
33 protected Map<String, List<Facet>> outs;
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
34
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
35 public CreationFilter() {
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
36 outs = new HashMap<String, List<Facet>>();
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
37 }
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
38
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
39 public void add(String out, List<Facet> facets) {
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
40 outs.put(out, facets);
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
41 }
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
42
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
43 public Element toXML(XMLUtils.ElementCreator ec) {
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
44 Element filter = ec.create("filter");
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
45
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
46 for (Map.Entry<String, List<Facet>> entry: outs.entrySet()) {
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
47 Element out = ec.create("out");
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
48 out.setAttribute("name", entry.getKey());
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
49 for (Facet facet: entry.getValue()) {
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
50 Element f = ec.create("facet");
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
51 f.setAttribute("name", facet.getName());
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
52 f.setAttribute("index", facet.getIndex());
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
53 out.appendChild(f);
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
54 }
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
55 filter.appendChild(out);
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
56 }
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
57
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
58 return filter;
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
59 }
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
60 }
4022ea69d1cb Write filters to create document if they are given.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
61 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org