1 17 package org.apache.jasper.el; 18 19 import javax.el.ELContext; 20 import javax.el.ExpressionFactory; 21 import javax.el.ValueExpression; 22 import javax.servlet.jsp.el.ELException ; 23 import javax.servlet.jsp.el.ELParseException ; 24 import javax.servlet.jsp.el.Expression ; 25 import javax.servlet.jsp.el.ExpressionEvaluator ; 26 import javax.servlet.jsp.el.FunctionMapper ; 27 import javax.servlet.jsp.el.VariableResolver ; 28 29 30 public final class ExpressionEvaluatorImpl extends ExpressionEvaluator { 31 32 private final ExpressionFactory factory; 33 34 public ExpressionEvaluatorImpl(ExpressionFactory factory) { 35 this.factory = factory; 36 } 37 38 public Expression parseExpression(String expression, Class expectedType, 39 FunctionMapper fMapper) throws ELException { 40 try { 41 ELContextImpl ctx = new ELContextImpl(ELResolverImpl.DefaultResolver); 42 if (fMapper != null) { 43 ctx.setFunctionMapper(new FunctionMapperImpl(fMapper)); 44 } 45 ValueExpression ve = this.factory.createValueExpression(ctx, expression, expectedType); 46 return new ExpressionImpl(ve); 47 } catch (javax.el.ELException e) { 48 throw new ELParseException (e.getMessage()); 49 } 50 } 51 52 public Object evaluate(String expression, Class expectedType, 53 VariableResolver vResolver, FunctionMapper fMapper) 54 throws ELException { 55 return this.parseExpression(expression, expectedType, fMapper).evaluate(vResolver); 56 } 57 58 } 59 | Popular Tags |