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.integration.VariableResolverFactory;
21: import static org.mvel.util.ParseTools.doOperations;
22:
23: public class BinaryOperation extends ASTNode {
24: private int operation;
25: private ASTNode left;
26: private ASTNode right;
27:
28: public BinaryOperation(int operation, ASTNode left, ASTNode right) {
29: this .operation = operation;
30: this .left = left;
31: this .right = right;
32: }
33:
34: public Object getReducedValueAccelerated(Object ctx,
35: Object this Value, VariableResolverFactory factory) {
36: return doOperations(left.getReducedValueAccelerated(ctx,
37: this Value, factory), operation, right
38: .getReducedValueAccelerated(ctx, this Value, factory));
39:
40: }
41:
42: public Object getReducedValue(Object ctx, Object this Value,
43: VariableResolverFactory factory) {
44: throw new RuntimeException("unsupported AST operation");
45: }
46:
47: public int getOperation() {
48: return operation;
49: }
50:
51: public void setOperation(int operation) {
52: this .operation = operation;
53: }
54:
55: public ASTNode getLeft() {
56: return left;
57: }
58:
59: public void setLeft(ASTNode left) {
60: this .left = left;
61: }
62:
63: public ASTNode getRight() {
64: return right;
65: }
66:
67: public void setRight(ASTNode right) {
68: this.right = right;
69: }
70: }
|