Mercurial > dive4elements > river
view flys-artifacts/src/main/java/de/intevation/flys/artifacts/transitions/TransitionFactory.java @ 124:b7a9557957d1
Appende the static data to the static node of the DESCRIBE document.
flys-artifacts/trunk@1452 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 10 Mar 2011 13:31:36 +0000 |
parents | a228b39494a9 |
children | 542f280d72c3 |
line wrap: on
line source
package de.intevation.flys.artifacts.transitions; import javax.xml.xpath.XPathConstants; import org.apache.log4j.Logger; import org.w3c.dom.Node; import de.intevation.artifactdatabase.transition.Transition; import de.intevation.artifacts.common.utils.XMLUtils; /** * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> */ public class TransitionFactory { /** The logger used in this class */ private static Logger logger = Logger.getLogger(TransitionFactory.class); /** The XPath to the classname of the transition */ public static final String XPATH_TRANSITION = "@transition"; /** The XPath to the current state ID */ public static final String XPATH_CURRENT_STATE = "from/@state"; /** The XPath to the target state ID */ public static final String XPATH_TARGET_STATE = "to/@state"; /** * Creates a new Transition based on the configured class provided by * <code>transitionConf</code>. * * @param transitionConf The configuration of the transition. * * @return a Transition. */ public static Transition createTransition(Node transitionConf) { String clazz = (String) XMLUtils.xpath( transitionConf, XPATH_TRANSITION, XPathConstants.STRING); Transition transition = null; try { transition = (Transition) Class.forName(clazz).newInstance(); String from = (String) XMLUtils.xpath( transitionConf, XPATH_CURRENT_STATE, XPathConstants.STRING); String to = (String) XMLUtils.xpath( transitionConf, XPATH_TARGET_STATE, XPathConstants.STRING); transition.setFrom(from); transition.setTo(to); } catch (InstantiationException ie) { logger.error(ie, ie); } catch (IllegalAccessException iae) { logger.error(iae, iae); } catch (ClassNotFoundException cnfe) { logger.error(cnfe, cnfe); } return transition; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :