KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > bpel > data > def > Snippet


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 /**
15  * Expressions extract and combine data from the process variables in interesting
16  * ways to control the behavior of the process.
17  * @see "WS-BPEL 2.0 §9.1, 14.3"
18  * @author Alejandro Guízar
19  * @version $Revision: 1.6 $ $Date: 2005/06/16 19:15:44 $
20  */

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   /**
34    * Gets the lexical representation of this expression.
35    * @return the text form
36    */

37   public String getText() {
38     return text;
39   }
40   
41   /**
42    * Sets the lexical representation of this expression.
43    * @param text the text form
44    */

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     /**
94      * Use as expression for general purposes.
95      * @see "WS-BPEL 2.0 §9.2.5"
96      */

97     public static Use EXPRESSION = new Use("expression");
98     
99     /**
100      * Use as query for general purposes.
101      * @see "WS-BPEL 2.0 §9.2.5"
102      */

103     public static Use QUERY = new Use("query");
104     
105     /**
106      * Use as expression for join condition. A join condition is a boolean
107      * expression used to specify requirements about concurrent paths reaching
108      * at an activity. It behaves just like general expressions except for the
109      * fact it accesses link status, not process variables.
110      * @see "WS-BPEL 2.0 §9.2.7"
111      * @see "WS-BPEL 2.0 §12.5.1"
112      */

113     public static Use JOIN_CONDITION = new Use("joinCondition");
114     
115     /**
116      * Use as query for property alias.
117      * @see "WS-BPEL 2.0 §9.2.6"
118      */

119     public static Use PROPERTY_ALIAS = new Use("propertyAlias");
120
121     /**
122      * Enumeration constructor.
123      * @param name the desired textual representation.
124      */

125     private Use(String name) {
126       super(name);
127     }
128     
129     /**
130      * Returns the enumeration element identified by the given literal.
131      * @param literal a string that identifies one element.
132      * @return the appropiate enumeration element
133      */

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