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