1 package org.jbpm.bpel.data.def; 2 3 import java.io.Serializable; 4 import java.util.Map; 5 6 import org.apache.commons.lang.enum.Enum; 7 8 import org.jbpm.bpel.data.spi.Script; 9 import org.jbpm.bpel.data.spi.ScriptFactory; 10 import org.jbpm.bpel.data.xpath.XPathFactory; 11 import org.jbpm.bpel.xml.BpelException; 12 import org.jbpm.bpel.xml.BpelConstants; 13 14 21 public class Snippet implements Serializable { 22 23 long id; 24 private String text; 25 private String language; 26 private Map namespaces; 27 28 private Use use; 29 private transient Script script; 30 31 private static final long serialVersionUID = 1L; 32 33 37 public String getText() { 38 return text; 39 } 40 41 45 public void setText(String text) { 46 this.text = text; 47 } 48 49 public String getLanguage() { 50 return language; 51 } 52 53 public void setLanguage(String language) { 54 this.language = language; 55 } 56 57 public Map getNamespaces() { 58 return namespaces; 59 } 60 61 public void setNamespaces(Map namespaceDeclarations) { 62 this.namespaces = namespaceDeclarations; 63 } 64 65 public Use getUse() { 66 return use; 67 } 68 69 public void setUse(Use use) { 70 this.use = use; 71 } 72 73 public Script getScript() { 74 if (script == null) { 75 parseScript(); 76 } 77 return script; 78 } 79 80 public void parseScript() { 81 String lang = language != null ? language : BpelConstants.URN_XPATH_1_0; 82 ScriptFactory factory = ScriptFactory.getInstance(lang); 83 if (factory == null) { 84 throw new BpelException("unsupported language: " + lang); 85 } 86 script = factory.createScript(this); 87 } 88 89 public static class Use extends Enum { 90 91 private static final long serialVersionUID = 1L; 92 93 97 public static Use EXPRESSION = new Use("expression"); 98 99 103 public static Use QUERY = new Use("query"); 104 105 113 public static Use JOIN_CONDITION = new Use("joinCondition"); 114 115 119 public static Use PROPERTY_ALIAS = new Use("propertyAlias"); 120 121 125 private Use(String name) { 126 super(name); 127 } 128 129 134 public static Use valueOf(String literal) { 135 return (Use) getEnum(Use.class, literal); 136 } 137 } 138 139 static { 140 ScriptFactory.registerInstance(BpelConstants.URN_XPATH_1_0, new XPathFactory()); 141 } 142 } 143 | Popular Tags |