evals.java

来自「非常接近C/S操作方式的Java Ajax框架-ZK 用ZK框架使你的B/S应」· Java 代码 · 共 57 行

JAVA
57
字号
/* Evals.java{{IS_NOTE	Purpose:			Description:			History:		Wed Oct 27 17:47:03     2004, Created by tomyeh}}IS_NOTECopyright (C) 2004 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.el;import javax.servlet.jsp.el.ExpressionEvaluator;import javax.servlet.jsp.el.VariableResolver;import javax.servlet.jsp.el.FunctionMapper;import javax.servlet.jsp.el.ELException;import org.zkoss.lang.Classes;/** * Utilities to wrap the real implementation of Expression Language evaluators. * * @author tomyeh */public class Evals {	protected Evals() {}//prevent from instantiate	/** Evaluates the expression with the specified resolver and 	 * mapper, and the expected class is Object.class.	 *	 * <p>Unlike ExpressionEvaluator, null is returned if expr is null.	 *	 * @param expr the expression, which might contain zero, one or	 * multiple ${...}.	 */	public static Object evaluate(String expr, Class expectedType,	VariableResolver resolv, FunctionMapper funcs)	throws ELException {		if (expr == null || expr.length() == 0 || expr.indexOf("${") < 0) {				if (expectedType == Object.class || expectedType == String.class)				return expr;			return Classes.coerce(expectedType, expr);		}    	return new EvaluatorImpl().evaluate(expr, expectedType, resolv, funcs);	}	}

⌨️ 快捷键说明

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