comparison flys-artifacts/src/main/java/org/dive4elements/river/exports/TypeSection.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/exports/TypeSection.java@cbe2febe30cc
children
comparison
equal deleted inserted replaced
5830:160f53ee0870 5831:bd047b71ab37
1 package org.dive4elements.river.exports;
2
3 import org.apache.log4j.Logger;
4
5 import org.dive4elements.artifactdatabase.state.Attribute;
6 import org.dive4elements.artifactdatabase.state.DefaultSection;
7
8
9 /**
10 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
11 */
12 public class TypeSection extends DefaultSection {
13
14 private static final Logger logger = Logger.getLogger(TypeSection.class);
15
16 public TypeSection(String key) {
17 super(key);
18 }
19
20
21 /** Set a string value for a attribute with additional (choice) type. */
22 public void setChoiceStringValue(String key, String value, String choiceType) {
23 if (value == null || value.length() == 0) {
24 return;
25 }
26
27 Attribute attr = getAttribute(key);
28 if (attr == null) {
29 attr = new ChoiceStringAttribute(key, value, true, choiceType);
30 addAttribute(key, attr);
31 }
32 else {
33 attr.setValue(value);
34 }
35 }
36
37
38 public void setStringValue(String key, String value) {
39 if (value == null || value.length() == 0) {
40 return;
41 }
42
43 Attribute attr = getAttribute(key);
44 if (attr == null) {
45 attr = new StringAttribute(key, value, true);
46 addAttribute(key, attr);
47 }
48 else {
49 attr.setValue(value);
50 }
51 }
52
53
54 public String getStringValue(String key) {
55 Attribute attr = getAttribute(key);
56
57 if (attr instanceof StringAttribute) {
58 return (String) attr.getValue();
59 }
60
61 logger.debug("attribute " + key + " not found in typesection.getString");
62
63 return null;
64 }
65
66
67 public void setIntegerValue(String key, int value) {
68 Attribute attr = getAttribute(key);
69 if (attr == null) {
70 attr = new IntegerAttribute(key, value, true);
71 addAttribute(key, attr);
72 }
73 else {
74 attr.setValue(value);
75 }
76 }
77
78
79 public Integer getIntegerValue(String key) {
80 Attribute attr = getAttribute(key);
81
82 if (attr instanceof IntegerAttribute) {
83 return (Integer) attr.getValue();
84 }
85
86 return null;
87 }
88
89
90
91 public void setDoubleValue(String key, double value) {
92 Attribute attr = getAttribute(key);
93 if (attr == null) {
94 attr = new DoubleAttribute(key, value, true);
95 addAttribute(key, attr);
96 }
97 else {
98 attr.setValue(value);
99 }
100 }
101
102
103 public Double getDoubleValue(String key) {
104 Attribute attr = getAttribute(key);
105
106 if (attr instanceof DoubleAttribute) {
107 return (Double) attr.getValue();
108 }
109
110 return null;
111 }
112
113
114 public void setBooleanValue(String key, boolean value) {
115 Attribute attr = getAttribute(key);
116 if (attr == null) {
117 attr = new BooleanAttribute(key, value, true);
118 addAttribute(key, attr);
119 }
120 else {
121 attr.setValue(value);
122 }
123 }
124
125
126 public Boolean getBooleanValue(String key) {
127 Attribute attr = getAttribute(key);
128
129 if (attr instanceof BooleanAttribute) {
130 return (Boolean) attr.getValue();
131 }
132
133 return null;
134 }
135 }
136 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org