Revision 43984 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/impl/expressionevaluator/DefaultExpressionEvaluator.java
DefaultExpressionEvaluator.java | ||
---|---|---|
8 | 8 |
import org.gvsig.expressionevaluator.Interpreter; |
9 | 9 |
import org.gvsig.expressionevaluator.SymbolTable; |
10 | 10 |
import org.gvsig.expressionevaluator.Compiler; |
11 |
import org.gvsig.expressionevaluator.Expression; |
|
11 | 12 |
import org.gvsig.expressionevaluator.ExpressionEvaluatorLocator; |
12 | 13 |
import org.gvsig.expressionevaluator.ExpressionEvaluatorManager; |
13 | 14 |
import org.gvsig.expressionevaluator.Function; |
... | ... | |
76 | 77 |
private Compiler compiler; |
77 | 78 |
private Interpreter interpreter; |
78 | 79 |
private Code code; |
79 |
private String source;
|
|
80 |
private Expression expression;
|
|
80 | 81 |
private Description[] availableOperators; |
81 | 82 |
private Description[] availableFunctions; |
82 | 83 |
|
83 | 84 |
public DefaultExpressionEvaluator(String source) { |
84 | 85 |
this.featureSymbolTable = new DefaultFeatureSymbolTable(); |
85 |
this.source = source; |
|
86 |
this.expression = ExpressionEvaluatorLocator.getManager().createExpression(); |
|
87 |
this.expression.setPhrase(source); |
|
86 | 88 |
} |
87 | 89 |
|
90 |
public DefaultExpressionEvaluator(Expression expression) { |
|
91 |
this.expression = expression; |
|
92 |
this.featureSymbolTable = new DefaultFeatureSymbolTable( |
|
93 |
expression.getUserScript(), |
|
94 |
expression.getScripts() |
|
95 |
); |
|
96 |
} |
|
97 |
|
|
88 | 98 |
private void compile() { |
89 |
this.code = this.compiler.compileExpression(source);
|
|
99 |
this.code = this.compiler.compileExpression(expression.getPhrase());
|
|
90 | 100 |
} |
91 | 101 |
|
92 | 102 |
@Override |
... | ... | |
175 | 185 |
public Evaluator clone() throws CloneNotSupportedException { |
176 | 186 |
DefaultExpressionEvaluator other = (DefaultExpressionEvaluator) super.clone(); |
177 | 187 |
other.code = this.code; |
178 |
other.source = this.source;
|
|
188 |
other.expression = this.expression.clone();
|
|
179 | 189 |
other.availableFunctions = null; |
180 | 190 |
other.availableOperators = null; |
181 | 191 |
|
182 | 192 |
if (this.featureSymbolTable != null) { |
183 |
// evaluatorData don't support clone. |
|
184 | 193 |
other.featureSymbolTable = this.featureSymbolTable.clone(); |
185 | 194 |
} |
186 | 195 |
if (this.compiler != null) { |
Also available in: Unified diff