01: /* ELXelExpression.java
02:
03: {{IS_NOTE
04: Purpose:
05:
06: Description:
07:
08: History:
09: Fri Aug 31 17:12:56 2007, Created by tomyeh
10: }}IS_NOTE
11:
12: Copyright (C) 2007 Potix Corporation. All Rights Reserved.
13:
14: {{IS_RIGHT
15: This program is distributed under GPL Version 2.0 in the hope that
16: it will be useful, but WITHOUT ANY WARRANTY.
17: }}IS_RIGHT
18: */
19: package org.zkoss.xel.el;
20:
21: import org.zkoss.xel.Expression;
22: import org.zkoss.xel.XelContext;
23: import org.zkoss.xel.VariableResolver;
24: import org.zkoss.xel.XelException;
25:
26: import org.zkforge.apache.commons.el.ExpressionApi;
27:
28: /**
29: * A XEL expression that is based on a EL expression.
30: *
31: * @author tomyeh
32: * @since 3.0.0
33: */
34: public class ELXelExpression implements Expression {
35: private final ExpressionApi _expr;
36:
37: /**
38: * @param expr the expression. It cannot be null.
39: */
40: public ELXelExpression(ExpressionApi expr) {
41: if (expr == null)
42: throw new IllegalArgumentException();
43: _expr = expr;
44: }
45:
46: public Object evaluate(XelContext ctx) {
47: return _expr.evaluate(ctx.getVariableResolver());
48: }
49:
50: //Object//
51: public boolean equals(Object o) {
52: return o instanceof ELXelExpression
53: && ((ELXelExpression) o)._expr.equals(_expr);
54: }
55:
56: public int hashCode() {
57: return _expr.hashCode();
58: }
59:
60: public String toString() {
61: return _expr.toString();
62: }
63: }
|