01: /**
02: *
03: * Copyright 2004 Hiram Chirino
04: *
05: * Licensed under the Apache License, Version 2.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: **/package org.activemq.filter.mockrunner;
18:
19: /**
20: * Alwin Ibba: Changed package
21: *
22: * An expression which performs an operation on two expression values.
23: *
24: * @version $Revision: 1.3 $
25: */
26: abstract public class BinaryExpression implements Expression {
27: protected Expression left;
28: protected Expression right;
29:
30: public BinaryExpression(Expression left, Expression right) {
31: this .left = left;
32: this .right = right;
33: }
34:
35: public Expression getLeft() {
36: return left;
37: }
38:
39: public Expression getRight() {
40: return right;
41: }
42:
43: /**
44: * @see java.lang.Object#toString()
45: */
46: public String toString() {
47: return "(" + left.toString() + " " + getExpressionSymbol()
48: + " " + right.toString() + ")";
49: }
50:
51: /**
52: * TODO: more efficient hashCode()
53: *
54: * @see java.lang.Object#hashCode()
55: */
56: public int hashCode() {
57: return toString().hashCode();
58: }
59:
60: /**
61: * TODO: more efficient hashCode()
62: *
63: * @see java.lang.Object#equals(java.lang.Object)
64: */
65: public boolean equals(Object o) {
66:
67: if (o == null || !this .getClass().equals(o.getClass())) {
68: return false;
69: }
70: return toString().equals(o.toString());
71:
72: }
73:
74: /**
75: * Returns the symbol that represents this binary expression. For example, addition is
76: * represented by "+"
77: *
78: * @return
79: */
80: abstract public String getExpressionSymbol();
81:
82: /**
83: * @param expression
84: */
85: public void setRight(Expression expression) {
86: right = expression;
87: }
88:
89: /**
90: * @param expression
91: */
92: public void setLeft(Expression expression) {
93: left = expression;
94: }
95:
96: }
|