Mercurial > dive4elements > framework
diff 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 |
line wrap: on
line diff
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/state/AbstractState.java Fri Feb 04 08:55:17 2011 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/state/AbstractState.java Fri Feb 04 10:50:53 2011 +0000 @@ -10,11 +10,15 @@ import java.util.HashMap; import java.util.Map; +import javax.xml.xpath.XPathConstants; + import org.w3c.dom.Document; import org.w3c.dom.Node; import de.intevation.artifacts.CallContext; +import de.intevation.artifacts.common.utils.XMLUtils; + import de.intevation.artifactdatabase.data.StateData; @@ -26,6 +30,15 @@ */ public abstract class AbstractState implements State { + /** The XPath to the ID of the state relative to the state node in the + * configuration. */ + public static final String XPATH_ID = "@id"; + + /** The XPath to the description of the state relative to the state node in + * the configuration. */ + public static final String XPATH_DESCRIPTION = "@description"; + + /** The ID of the state. */ protected String id; @@ -115,12 +128,16 @@ /** - * Initialize the state based on the state node in the configuration. This - * method needs to be implemented by concrete subclasses. + * Initialize the state based on the state node in the configuration. * * @param config The state configuration node. */ - public abstract void setup(Node config); + public void setup(Node config) { + id = (String) XMLUtils.xpath(config, XPATH_ID, XPathConstants.STRING); + + description = (String) XMLUtils.xpath( + config, XPATH_DESCRIPTION, XPathConstants.STRING); + } /**