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.zkmax.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 javax.servlet.jsp.el.ELException;
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 javax.servlet.jsp.el.Expression _expr;
36:
37: /**
38: * @param expr the expression. It cannot be null.
39: */
40: public ELXelExpression(javax.servlet.jsp.el.Expression expr) {
41: if (expr == null)
42: throw new IllegalArgumentException();
43: _expr = expr;
44: }
45:
46: public Object evaluate(XelContext ctx) {
47: try {
48: final VariableResolver resolver = ctx.getVariableResolver();
49: return _expr.evaluate(resolver != null ? new XelELResolver(
50: resolver) : null);
51: } catch (ELException ex) {
52: throw new XelException(ex);
53: }
54: }
55:
56: //Object//
57: public boolean equals(Object o) {
58: return o instanceof ELXelExpression
59: && ((ELXelExpression) o)._expr.equals(_expr);
60: }
61:
62: public int hashCode() {
63: return _expr.hashCode();
64: }
65:
66: public String toString() {
67: return _expr.toString();
68: }
69: }
|