1 package org.jbpm.bpel.data.exe; 2 3 import javax.xml.namespace.QName ; 4 5 import org.w3c.dom.Document ; 6 import org.w3c.dom.Element ; 7 8 import org.jbpm.bpel.xml.util.NodeUtil; 9 10 14 public class ElementVariableInstance extends VariableInstance { 15 16 private Element element; 17 18 public Object getValue() { 19 return getElement(); 20 } 21 22 public void setValue(Object value) { 23 NodeUtil.setValue(getOrCreateElement(), value); 24 } 25 26 public Object getOrCreateValue() { 27 return getOrCreateElement(); 28 } 29 30 public Element getElement() { 31 if (element == null) { 32 throw new RuntimeException ("Uninitialized variable: variable=" + getDefinition().getName()); 33 } 34 return element; 35 } 36 37 public Element getOrCreateElement() { 38 if (element == null) { 39 QName type = getDefinition().getTypeInfo().getName(); 40 Document doc = NodeUtil.createDocument(); 41 element = doc.createElementNS(type.getNamespaceURI(), type.getLocalPart()); 42 doc.appendChild(element); 43 } 44 return element; 45 } 46 47 public void setElement(Element element) { 48 this.element = element; 49 } 50 } 51 | Popular Tags |