01: /* ExpressionFactory.java
02:
03: {{IS_NOTE
04: Purpose:
05:
06: Description:
07:
08: History:
09: Thu Aug 30 10:29:09 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;
20:
21: /**
22: * Used to prepare expressions ({@link Expression}).
23: *
24: * @author tomyeh
25: * @since 3.0.0
26: */
27: public interface ExpressionFactory {
28: /** Used with {@link #isSupported} to know whether the factory
29: * supports {@link FunctionMapper#resolveFunction}
30: */
31: public static final int FEATURE_FUNCTION = 0x0001;
32: /** Used with {@link #isSupported} to know whether the factory
33: * supports {@link FunctionMapper#resolveClass}
34: */
35: public static final int FEATURE_CLASS = 0x0002;
36:
37: /** Returns whether an feature is supported.
38: *
39: * @param feature which feature to query.
40: * It can be a combination of {@link #FEATURE_FUNCTION}
41: * and {@link #FEATURE_CLASS}.
42: */
43: public boolean isSupported(int feature);
44:
45: /** Prepares (aka., compiles) an expression.
46: *
47: * @param ctx the context infomation to prepare the expression.
48: * It can be null, in which case no functions are supported for this
49: * invocation.
50: * @param expression the expression to be evaluated.
51: * @param expectedType the expected type of the result of the evaluation
52: */
53: public Expression parseExpression(XelContext ctx,
54: String expression, Class expectedType) throws XelException;
55:
56: /** Evaluates an expression.
57: *
58: * @param ctx the context information to evaluate an expression.
59: * It can be null, in which case no functions are supported for this
60: * invocation.
61: * @param expression the expression to be evaluated.
62: * Note: the expression is enclosed
63: * with ${ and }, regardingless what implemetnation is used.
64: * @param expectedType the expected type of the result of the evaluation
65: */
66: public Object evaluate(XelContext ctx, String expression,
67: Class expectedType) throws XelException;
68: }
|