01: package org.drools.base.mvel;
02:
03: import java.io.Serializable;
04:
05: import org.mvel.integration.VariableResolver;
06:
07: public class DroolsMVELGlobalVariable implements VariableResolver,
08: Serializable {
09:
10: private String name;
11: private Class knownType;
12: private DroolsMVELFactory factory;
13:
14: public DroolsMVELGlobalVariable(final String identifier,
15: final Class knownType, final DroolsMVELFactory factory) {
16: this .name = identifier;
17: this .factory = factory;
18: this .knownType = knownType;
19: }
20:
21: public String getName() {
22: return this .name;
23: }
24:
25: public Class getKnownType() {
26: return this .knownType;
27: }
28:
29: public Object getValue() {
30: return this .factory.getValue(this .name);
31: }
32:
33: public void setValue(final Object value) {
34: throw new UnsupportedOperationException(
35: "External Variable identifer='" + getName()
36: + "' type='" + getKnownType()
37: + "' is final, it cannot be set");
38: }
39:
40: public int getFlags() {
41: return 0;
42: }
43:
44: /**
45: * Not used in drools.
46: */
47: public Class getType() {
48: return this .knownType;
49: }
50:
51: /**
52: * Not used in drools.
53: */
54: public void setStaticType(Class arg0) {
55: }
56:
57: }
|