| 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 Export implements Step { 20 private String _from; 21 private String _to; 22 private String _key; 23 private String _expKey; 24 25 28 public String getName() { 29 return ClassUtils.getShortClassName(getClass()); 30 } 31 32 public void setFrom(String from) { 33 _from = from; 34 } 35 36 public void setTo(String to) { 37 _to = to; 38 } 39 40 public void setKey(String key) { 41 _key = key; 42 } 43 44 public void setExportKey(String expKey) { 45 _expKey = expKey; 46 } 47 48 51 public void execute(Result st) { 52 if (_from == null) { 53 throw new IllegalStateException ("'from' not specified"); 54 } 55 56 if (_to == null) { 57 throw new IllegalStateException ("'to' not specified"); 58 } 59 60 if (_key == null) { 61 throw new IllegalStateException ("'key' not specified"); 62 } 63 64 Object toExport = st.getContext().get(_key, _from); 65 66 if (toExport != null) { 67 Scope scope = (Scope) st.getContext().getScopes().get(_to); 68 69 if (scope != null) { 70 if (_expKey == null) { 71 scope.putVal(_key, toExport); 72 } else { 73 scope.putVal(_expKey, toExport); 74 } 75 } 76 } 77 } 78 } 79 | Popular Tags |