| 1 package org.sapia.soto.state.util; 2 3 import org.apache.commons.lang.ClassUtils; 4 5 import org.sapia.soto.state.Result; 6 import org.sapia.soto.state.Scope; 7 import org.sapia.soto.state.Step; 8 9 10 19 public class VarStep implements Step { 20 private String _key; 21 private String _value; 22 private String _scope; 23 24 public void setKey(String key) { 25 _key = key; 26 } 27 28 public void setValue(String value) { 29 _value = value; 30 } 31 32 public void setScope(String scope) { 33 _scope = scope; 34 } 35 36 39 public String getName() { 40 return ClassUtils.getShortClassName(getClass()); 41 } 42 43 46 public void execute(Result st) { 47 if (_key == null) { 48 throw new IllegalStateException ("Variable key not specified"); 49 } 50 51 if (_scope == null) { 52 throw new IllegalStateException ("Variable scope not specified"); 53 } 54 55 if (_value == null) { 56 throw new IllegalStateException ("Variable value not specified"); 57 } 58 59 Scope scope = (Scope) st.getContext().getScopes().get(_scope); 60 61 if (scope == null) { 62 throw new IllegalArgumentException ("Scope not found: " + _scope); 63 } 64 65 scope.putVal(_key, _value); 66 } 67 } 68 | Popular Tags |