KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > bpel > data > xpath > ScopeVariables


1 package org.jbpm.bpel.data.xpath;
2
3 import org.jaxen.UnresolvableException;
4 import org.jaxen.VariableContext;
5
6 import org.jbpm.context.exe.ContextInstance;
7 import org.jbpm.graph.exe.Token;
8
9 import org.jbpm.bpel.data.exe.VariableInstance;
10
11 /**
12  * @author Alejandro Guízar
13  * @version $Revision: 1.1 $ $Date: 2005/05/04 19:46:11 $
14  */

15 public class ScopeVariables implements VariableContext {
16   
17   private Token token;
18
19   public ScopeVariables(Token token) {
20     this.token = token;
21   }
22   
23   public VariableInstance getVariable(String JavaDoc name) {
24     ContextInstance context = token.getProcessInstance().getContextInstance();
25     return (VariableInstance) context.getVariable(name, token);
26   }
27   
28   public Object JavaDoc getVariableValue(String JavaDoc namespaceURI, String JavaDoc prefix,
29       String JavaDoc localName) throws UnresolvableException {
30     if (namespaceURI != null) {
31       throw new UnresolvableException("No such variable: " + prefix + ':' + localName);
32     }
33     VariableInstance instance = getVariable(localName);
34     if (instance == null) {
35       throw new UnresolvableException("No such variable: " + localName);
36     }
37     return instance.getValue();
38   }
39 }
40
Popular Tags