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 DroolsMVELPreviousDeclarationVariable implements
10: VariableResolver, Serializable {
11:
12: private Declaration declaration;
13: private DroolsMVELFactory factory;
14:
15: public DroolsMVELPreviousDeclarationVariable(
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
34: .getValue(this .declaration));
35: }
36:
37: public void setValue(final Object value) {
38: throw new UnsupportedOperationException(
39: "External Variable identifer='" + getName()
40: + "' type='" + getKnownType()
41: + "' is final, it cannot be set");
42: }
43:
44: public int getFlags() {
45: return 0;
46: }
47:
48: /**
49: * Not used in drools.
50: */
51: public Class getType() {
52: return this .declaration.getExtractor().getExtractToClass();
53: }
54:
55: /**
56: * Not used in drools.
57: */
58: public void setStaticType(Class arg0) {
59: }
60:
61: }
|