comparison flys-artifacts/src/main/java/org/dive4elements/river/themes/DefaultThemeField.java @ 5831:bd047b71ab37

Repaired internal references
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 25 Apr 2013 12:06:39 +0200
parents flys-artifacts/src/main/java/de/intevation/flys/themes/DefaultThemeField.java@e32b822f3cfa
children
comparison
equal deleted inserted replaced
5830:160f53ee0870 5831:bd047b71ab37
1 package org.dive4elements.river.themes;
2
3 import java.util.HashMap;
4 import java.util.Map;
5
6 import org.w3c.dom.Document;
7 import org.w3c.dom.Element;
8
9 import org.dive4elements.artifacts.common.utils.XMLUtils;
10 import org.dive4elements.artifacts.common.utils.XMLUtils.ElementCreator;
11
12
13 /**
14 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
15 */
16 public class DefaultThemeField implements ThemeField {
17
18 protected String name;
19
20 protected Map<String, Object> attr;
21
22
23 public DefaultThemeField(String name) {
24 this.name = name;
25 this.attr = new HashMap<String, Object>();
26 }
27
28
29 public String getName() {
30 return name;
31 }
32
33
34 public String getType() {
35 return (String) getAttribute("type");
36 }
37
38
39 public Object getValue() {
40 return getAttribute("value");
41 }
42
43
44 public void setValue(Object value) {
45 setAttribute("value", value);
46 }
47
48
49 public Object getAttribute(String name) {
50 return attr.get(name);
51 }
52
53
54 public void setAttribute(String name, Object value) {
55 if (name == null || value == null) {
56 return;
57 }
58
59 attr.put(name, value);
60 }
61
62
63 public Document toXML() {
64 Document doc = XMLUtils.newDocument();
65
66 ElementCreator cr = new ElementCreator(doc, null, null);
67
68 Element field = cr.create("field");
69
70 for (Map.Entry<String, Object> entry: attr.entrySet()) {
71 cr.addAttr(field, entry.getKey(), (String)entry.getValue());
72 }
73
74 doc.appendChild(field);
75
76 return doc;
77 }
78 }
79 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org