KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > context > def > VariableAccess


1 package org.jbpm.context.def;
2
3 import java.io.Serializable JavaDoc;
4
5 /**
6  * specifies access to a variable.
7  * Variable access is used in 3 situations:
8  * 1) process-state
9  * 2) script
10  * 3) task controllers
11  */

12 public class VariableAccess implements Serializable JavaDoc {
13
14   private static final long serialVersionUID = 1L;
15   
16   long id = 0;
17   protected String JavaDoc variableName = null;
18   protected String JavaDoc access = null;
19   protected String JavaDoc mappedName = null;
20
21   // constructors /////////////////////////////////////////////////////////////
22

23   public VariableAccess() {
24   }
25
26   public VariableAccess(String JavaDoc variableName, String JavaDoc access, String JavaDoc mappedName) {
27     this.variableName = variableName;
28     if (access!=null) access = access.toLowerCase();
29     this.access = access;
30     this.mappedName = mappedName;
31   }
32
33   // getters and setters //////////////////////////////////////////////////////
34

35   /**
36    * the mapped name. The mappedName defaults to the variableName in case
37    * no mapped name is specified.
38    */

39   public String JavaDoc getMappedName() {
40     if (mappedName==null) {
41       return variableName;
42     }
43     return mappedName;
44   }
45
46   /**
47    * specifies a comma separated list of access literals {read, write, required}.
48    */

49   public String JavaDoc getAccess() {
50     return access;
51   }
52   public String JavaDoc getVariableName() {
53     return variableName;
54   }
55   
56   public boolean isReadable() {
57     return hasAccess("read");
58   }
59
60   public boolean isWritable() {
61     return hasAccess("write");
62   }
63
64   public boolean isRequired() {
65     return hasAccess("required");
66   }
67
68   /**
69    * verifies if the given accessLiteral is included in the access text.
70    */

71   public boolean hasAccess(String JavaDoc accessLiteral) {
72     if (access==null) return false;
73     return (access.indexOf(accessLiteral.toLowerCase())!=-1);
74   }
75 }
76
Popular Tags