01: /*
02: * Created on Oct 16, 2003
03: *
04: * To change the template for this generated file go to
05: * Window>Preferences>Java>Code Generation>Code and Comments
06: */
07: package org.xdev.base.xssl.bpm.compare;
08:
09: import java.util.ArrayList;
10: import java.util.HashMap;
11:
12: import org.xdev.base.xssl.XSSLReturn;
13: import org.xdev.base.xssl.XSSLAction;
14: import org.xdev.base.xssl.XSSLActionIterator;
15:
16: /**
17: * @author AYegorov
18: *
19: * To change the template for this generated type comment go to
20: * Window>Preferences>Java>Code Generation>Code and Comments
21: */
22: public class SwitchComparison extends XSSLActionIterator {
23: private Object switchObj = null;
24:
25: private Object returnObject = null;
26:
27: /**
28: * @param id
29: */
30: public SwitchComparison(String id) {
31: super (id);
32: // TODO Auto-generated constructor stub
33: }
34:
35: /**
36: * @param id
37: * @param properties
38: */
39: public SwitchComparison(String id, HashMap properties) {
40: super (id, properties);
41: // TODO Auto-generated constructor stub
42: }
43:
44: /* (non-Javadoc)
45: * @see org.xdev.base.transaction.TemplateElementIterator#invoke(org.xdev.base.transaction.TemplateComponent)
46: */
47: protected void invoke(XSSLAction choice) throws Exception {
48:
49: if (this .switchObj.equals(choice.getProperty("choice"))) {
50: choice.execute(this );
51:
52: if (choice instanceof XSSLReturn) {
53: this .returnObject = ((XSSLReturn) choice)
54: .getObjectValue();
55: } else {
56: this .returnObject = "";
57: }
58:
59: if (!choice.hasProperty("break")
60: || this .getBooleanProperty("break")) {
61: this .breakIteration();
62: }
63: }
64:
65: }
66:
67: protected void set() throws Exception {
68: XSSLReturn elm = (XSSLReturn) this .getElement(0);
69: if (!elm.execute(this )) {
70: throw new Exception(
71: "Switch expression initialized with errors. Switch statement cannot be evaluated!");
72: }
73:
74: this .switchObj = elm.getObjectValue();
75:
76: if (this .switchObj == null) {
77: this .switchObj = "";
78: }
79: }
80:
81: public int setIterationIndex() {
82: return (this .iterationIndex = 1);
83: }
84:
85: public Object getObjectValue() {
86: return this .returnObject;
87: }
88:
89: public void reset() {
90: super.reset();
91:
92: this.switchObj = null;
93: }
94: }
|