apacheelfactory.java

来自「ZK 基础介绍 功能操作 模块 结合数据库操作」· Java 代码 · 共 83 行

JAVA
83
字号
/* ApacheELFactory.java{{IS_NOTE	Purpose:			Description:			History:		Fri Aug 31 17:00:40     2007, Created by tomyeh}}IS_NOTECopyright (C) 2007 Potix Corporation. All Rights Reserved.{{IS_RIGHT	This program is distributed under GPL Version 2.0 in the hope that	it will be useful, but WITHOUT ANY WARRANTY.}}IS_RIGHT*/package org.zkoss.zkmax.xel.el;import org.zkoss.xel.Expression;import org.zkoss.xel.ExpressionFactory;import org.zkoss.xel.XelContext;import org.zkoss.xel.XelException;import javax.servlet.jsp.el.ExpressionEvaluator;import javax.servlet.jsp.el.ELException;/** * An implemetation that is based on Apache commons-el: * org.apache.commons.el.ExpressionEvaluatorImpl. * * <p>The org.zkoss.xel.el.ELFactory class is recommended since the * implementation it encapsulates has the better performance. * * @author tomyeh * @since 3.0.0 */public class ApacheELFactory implements ExpressionFactory {	private final ExpressionEvaluator _eval;	public ApacheELFactory() {		_eval = newExpressionEvaluator();	}	//ExpressionFactory//	public boolean isSupported(int feature) {		return feature == FEATURE_FUNCTION;	}	public Expression parseExpression(XelContext xelc, String expression,	Class expectedType)	throws XelException {		try {			return new ELXelExpression(				_eval.parseExpression(expression, expectedType,					xelc != null ? new XelELMapper(xelc.getFunctionMapper()): null));		} catch (ELException ex) {			throw new XelException("Failed to parse "+expression, ex);		}	}	public Object evaluate(XelContext xelc, String expression,	Class expectedType)	throws XelException {		try {			return _eval.evaluate(expression, expectedType,				xelc != null ?					new XelELResolver(xelc.getVariableResolver()): null,				xelc != null ?					new XelELMapper(xelc.getFunctionMapper()): null);		} catch (ELException ex) {			throw new XelException("Failed to evaluate "+expression, ex);		}	}	/** Returns the EL expression factory.	 * <p>Default: Use org.apache.commons.el.ExpressionEvaluatorImpl.	 * <p>You might override it to use a different implementation.	 */	protected ExpressionEvaluator newExpressionEvaluator() {		return new org.apache.commons.el.ExpressionEvaluatorImpl();	}}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?