1 package org.smartcomps.twister.deployer.priv;
2
3 import org.dom4j.Element;
4 import org.smartcomps.twister.deployer.exception.DeploymentException;
5 import org.smartcomps.twister.engine.priv.core.definition.Activity;
6 import org.smartcomps.twister.engine.priv.core.definition.Switch;
7
8 import java.util.Iterator;
9
10 /*
11 <switch standard-attributes>
12 standard-elements
13 <case condition="bool-expr">+
14 activity
15 </case>
16 <otherwise>?
17 activity
18 </otherwise>
19 </switch>
20 */
21 // TODO implements the Switch activity
22
23 public class SwitchDeployer extends ActivityDeployer {
24
25
26 protected void processSpecificElements(Element element, Activity activity) throws DeploymentException {
27 Switch aSwitch = (Switch) activity;
28 for (Iterator i = element.elementIterator("case"); i.hasNext();) {
29 Element caseElement = (Element) i.next();
30 String s = caseElement.valueOf("@condition");
31 log.debug("<case " +s +">");
32 Element activityElement = getActivityElement(caseElement);
33 log.debug("<" + activityElement.getName() + ">");
34 ActivityDeployer ad = ActivityDeployerFactory.getActivityDeployer(activityElement.getName());
35 aSwitch.addCondition(s, ad.deploy(activityElement, aSwitch));
36 log.debug("</" + activityElement.getName() + ">");
37 log.debug("</case>");
38 }
39 log.debug("<otherwise>");
40 Element otherwiseElement = element.element("otherwise");
41 Element activityElement = getActivityElement(otherwiseElement);
42 log.debug("<" + activityElement.getName() + ">");
43 ActivityDeployer ad = ActivityDeployerFactory.getActivityDeployer(activityElement.getName());
44 aSwitch.setOtherwise(ad.deploy(activityElement, aSwitch));
45 log.debug("</" + activityElement.getName() + ">");
46 log.debug("</otherwise>");
47 processChildren = false;
48 }
49
50 protected void processSpecificAttributes(Element element, Activity activity) throws DeploymentException {
51
52 }
53
54 protected Class getActivityClass() {
55 return Switch.class;
56 }
57
58 }
This page was automatically generated by Maven