01: /**
02: * MVEL (The MVFLEX Expression Language)
03: *
04: * Copyright (C) 2007 Christopher Brock, MVFLEX/Valhalla Project and the Codehaus
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: *
18: */package org.mvel.ast;
19:
20: import org.mvel.MVEL;
21: import org.mvel.compiler.ExecutableStatement;
22: import org.mvel.integration.VariableResolverFactory;
23: import static org.mvel.util.ParseTools.subCompileExpression;
24:
25: public class Substatement extends ASTNode {
26: private ExecutableStatement statement;
27:
28: public Substatement(char[] expr, int fields) {
29: this .name = expr;
30:
31: if (((this .fields = fields) & COMPILE_IMMEDIATE) != 0) {
32: this .statement = (ExecutableStatement) subCompileExpression(this .name);
33: this .egressType = this .statement.getKnownEgressType();
34: }
35: }
36:
37: public Object getReducedValueAccelerated(Object ctx,
38: Object this Value, VariableResolverFactory factory) {
39: return statement.getValue(ctx, this Value, factory);
40: }
41:
42: public Object getReducedValue(Object ctx, Object this Value,
43: VariableResolverFactory factory) {
44: return (MVEL.eval(this .name, ctx, factory));
45: }
46:
47: public ExecutableStatement getStatement() {
48: return statement;
49: }
50: }
|