01: /* ELFactory.java
02:
03: {{IS_NOTE
04: Purpose:
05:
06: Description:
07:
08: History:
09: Fri Aug 31 17:00:40 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.ExpressionFactory;
23: import org.zkoss.xel.XelContext;
24: import org.zkoss.xel.XelException;
25:
26: import org.zkforge.apache.commons.el.ExpressionEvaluatorImpl;
27:
28: /**
29: * An implementation based on ZK Commons EL (zcommons-el.jar:
30: * org.zkforge.apache.commons.el.ExpressionEvaluatorImpl).
31: * ZK commons-EL is a peformance enhancement version of Apache Commons EL.
32: * It is also independent of JSP 2.0.
33: *
34: * @author tomyeh
35: * @since 3.0.0
36: */
37: public class ELFactory implements ExpressionFactory {
38: private final ExpressionEvaluatorImpl _eval;
39:
40: public ELFactory() {
41: _eval = new ExpressionEvaluatorImpl();
42: }
43:
44: //ExpressionFactory//
45: public boolean isSupported(int feature) {
46: return feature == FEATURE_FUNCTION;
47: }
48:
49: public Expression parseExpression(XelContext xelc,
50: String expression, Class expectedType) throws XelException {
51: return new ELXelExpression(_eval.parseExpression(expression,
52: expectedType, xelc != null ? xelc.getFunctionMapper()
53: : null));
54: }
55:
56: public Object evaluate(XelContext xelc, String expression,
57: Class expectedType) throws XelException {
58: return _eval.evaluate(expression, expectedType,
59: xelc != null ? xelc.getVariableResolver() : null,
60: xelc != null ? xelc.getFunctionMapper() : null);
61: }
62: }
|