Mercurial > dive4elements > framework
comparison artifact-database/src/main/java/de/intevation/artifactdatabase/state/AbstractState.java @ 106:ece0fdb07975
Implementations to initialize and retrieve states.
artifacts/trunk@1291 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 04 Feb 2011 10:50:53 +0000 |
parents | 265f150f4f7f |
children | 2a9591f76270 |
comparison
equal
deleted
inserted
replaced
105:265f150f4f7f | 106:ece0fdb07975 |
---|---|
8 package de.intevation.artifactdatabase.state; | 8 package de.intevation.artifactdatabase.state; |
9 | 9 |
10 import java.util.HashMap; | 10 import java.util.HashMap; |
11 import java.util.Map; | 11 import java.util.Map; |
12 | 12 |
13 import javax.xml.xpath.XPathConstants; | |
14 | |
13 import org.w3c.dom.Document; | 15 import org.w3c.dom.Document; |
14 import org.w3c.dom.Node; | 16 import org.w3c.dom.Node; |
15 | 17 |
16 import de.intevation.artifacts.CallContext; | 18 import de.intevation.artifacts.CallContext; |
19 | |
20 import de.intevation.artifacts.common.utils.XMLUtils; | |
17 | 21 |
18 import de.intevation.artifactdatabase.data.StateData; | 22 import de.intevation.artifactdatabase.data.StateData; |
19 | 23 |
20 | 24 |
21 /** | 25 /** |
23 * methods that return the id, description and data. The methods | 27 * methods that return the id, description and data. The methods |
24 * <code>describe()</code> and <code>setup()</code> depend on the concrete class | 28 * <code>describe()</code> and <code>setup()</code> depend on the concrete class |
25 * and need to be implemented by those. | 29 * and need to be implemented by those. |
26 */ | 30 */ |
27 public abstract class AbstractState implements State { | 31 public abstract class AbstractState implements State { |
32 | |
33 /** The XPath to the ID of the state relative to the state node in the | |
34 * configuration. */ | |
35 public static final String XPATH_ID = "@id"; | |
36 | |
37 /** The XPath to the description of the state relative to the state node in | |
38 * the configuration. */ | |
39 public static final String XPATH_DESCRIPTION = "@description"; | |
40 | |
28 | 41 |
29 /** The ID of the state. */ | 42 /** The ID of the state. */ |
30 protected String id; | 43 protected String id; |
31 | 44 |
32 /** The description of the state. */ | 45 /** The description of the state. */ |
113 this.data.put(name, data); | 126 this.data.put(name, data); |
114 } | 127 } |
115 | 128 |
116 | 129 |
117 /** | 130 /** |
118 * Initialize the state based on the state node in the configuration. This | 131 * Initialize the state based on the state node in the configuration. |
119 * method needs to be implemented by concrete subclasses. | |
120 * | 132 * |
121 * @param config The state configuration node. | 133 * @param config The state configuration node. |
122 */ | 134 */ |
123 public abstract void setup(Node config); | 135 public void setup(Node config) { |
136 id = (String) XMLUtils.xpath(config, XPATH_ID, XPathConstants.STRING); | |
137 | |
138 description = (String) XMLUtils.xpath( | |
139 config, XPATH_DESCRIPTION, XPathConstants.STRING); | |
140 } | |
124 | 141 |
125 | 142 |
126 /** | 143 /** |
127 * Describes the UI of the state. This method needs to be implemented by | 144 * Describes the UI of the state. This method needs to be implemented by |
128 * concrete subclasses. | 145 * concrete subclasses. |