1 package org.jbpm.bpel.data.exe; 2 3 import javax.xml.namespace.QName ; 4 5 import org.w3c.dom.Node ; 6 7 import org.jbpm.bpel.data.def.VariableDefinition; 8 import org.jbpm.bpel.wsdl.def.PropertyAlias; 9 import org.jbpm.bpel.xml.util.NodeUtil; 10 11 15 public abstract class VariableInstance { 16 17 private VariableDefinition definition; 18 19 protected VariableInstance() { 20 } 21 22 public VariableDefinition getDefinition() { 23 return definition; 24 } 25 26 public void setDefinition(VariableDefinition definition) { 27 this.definition = definition; 28 } 29 30 public abstract Object getValue(); 31 32 public abstract void setValue(Object value); 33 34 public abstract Object getOrCreateValue(); 35 36 public Object getProperty(QName propertyName) { 37 PropertyAlias alias = definition.getTypeInfo().getPropertyAlias(propertyName); 38 if (alias == null) { 39 throw new RuntimeException ("Selection failure (property does not appear in variable's type):" + 40 " variable=" + definition.getName() + ", property=" + propertyName); 41 } 42 Object value = alias.getQuery().getScript().evaluate(getValue()); 43 if (value instanceof Node ) { 44 value = NodeUtil.getValue((Node ) value); 45 } 46 return value; 47 } 48 49 public void setProperty(QName propertyName, Object value) { 50 PropertyAlias alias = definition.getTypeInfo().getPropertyAlias(propertyName); 51 if (alias == null) { 52 throw new RuntimeException ("Selection failure (property does not appear in variable's type):" + 53 " variable=" + definition.getName() + ", property=" + propertyName); 54 } 55 alias.getQuery().getScript().assign(getOrCreateValue(), value); 56 } 57 } 58 | Popular Tags |