/** * Get the <code>ExpressionEvaluator</code>, with lazy initialization. * * @return Log The log being used. */ private ExpressionEvaluator getEvaluator() { if (ee == null) { ee = new ExpressionEvaluatorImpl(); } return ee; }
public Object evaluate( VariableResolver vResolver ) throws ELException { return evaluator.evaluate(this.expression, this.expectedType, vResolver, this.fMapper); } }
/** * this method is for design time expression evaluation. Currently it only * handles * * @param expression * @param pageVars * @param jspFile * @param options * XXX: not used today. In the future, we may support things like * locale in options * @return */ public Object evaluateExpression(String expression, Class expectedClass, Map options) throws ELException { expression = JSFELParserHelper.toJspElExpression(expression); ExpressionEvaluatorImpl evaluator = new ExpressionEvaluatorImpl(); FunctionMapper mapper = new EmptyFunctionMapper(); return evaluator.evaluate(expression, expectedClass, resolver, mapper); }
Object parsedValue = parseExpressionString (pExpressionString); return convertStaticValueToExpectedType (strValue, pExpectedType, pLogger); functions, pLogger); return convertToExpectedType (value, pExpectedType, pLogger); functions, pLogger); return convertToExpectedType (strValue, pExpectedType, pLogger);
parseExpressionString(expression);
break; encounteredBuf.append (addEscapes (tok.image)); tok = tok.next;
/** * * Parses the given expression string, then converts it back to a * String in its canonical form. This is used to test parsing. **/ public String parseAndRender (String pExpressionString) throws ELException { Object val = parseExpressionString (pExpressionString); if (val instanceof String) { return (String) val; } else if (val instanceof Expression) { return "${" + ((Expression) val).getExpressionString () + "}"; } else if (val instanceof ExpressionString) { return ((ExpressionString) val).getExpressionString (); } else { return ""; } }
/** * Constructor. */ public ELEvaluator() { ee = new ExpressionEvaluatorImpl(); }
/** * * Evaluates the given expression String * * @param pExpressionString The expression to be evaluated. * @param pExpectedType The expected type of the result of the evaluation * @param pResolver A VariableResolver instance that can be used at * runtime to resolve the name of implicit objects into Objects. * @param functions A FunctionMapper to resolve functions found in * the expression. It can be null, in which case no functions * are supported for this invocation. * @return the expression String evaluated to the given expected * type **/ public Object evaluate (String pExpressionString, Class pExpectedType, VariableResolver pResolver, FunctionMapper functions) throws ELException { return evaluate (pExpressionString, pExpectedType, pResolver, functions, sLogger); }
throws Exception { try { Object exprString = evaluator.parseExpressionString(expr); if (exprString instanceof ExpressionString) { for (Object element : ((ExpressionString)exprString).getElements()) {
/** 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(); } }
/** * Evaluate an EL expression. <p> * * @param <T> the return type of the expression * @param expr EL expression to evaluate. * @param clazz return type of the EL expression. * @return the object the EL expression evaluated to. * @throws Exception thrown if an EL function failed due to a transient error or EL expression could not be * evaluated. */ @SuppressWarnings({"unchecked", "deprecation"}) public <T> T evaluate(String expr, Class<T> clazz) throws Exception { ELEvaluator existing = current.get(); try { current.set(this); return (T) evaluator.evaluate(expr, clazz, context, context); } catch (ELException ex) { if (ex.getRootCause() instanceof Exception) { throw (Exception) ex.getRootCause(); } else { throw ex; } } finally { current.set(existing); } }
throws Exception { try { Object exprString = evaluator.parseExpressionString(expr); if (exprString instanceof ExpressionString) { for (Object element : ((ExpressionString)exprString).getElements()) {
/** * Constructor for EL evaluator that supports user-defined functions. * * @param fnMapper The function mapper for this Evaluator. * @see javax.servlet.jsp.el.FunctionMapper */ public ELEvaluator(final FunctionMapper fnMapper) { ee = new ExpressionEvaluatorImpl(); this.fnMapper = fnMapper; }
/** * Evaluate an EL expression. <p> * * @param <T> the return type of the expression * @param expr EL expression to evaluate. * @param clazz return type of the EL expression. * @return the object the EL expression evaluated to. * @throws Exception thrown if an EL function failed due to a transient error or EL expression could not be * evaluated. */ @SuppressWarnings({"unchecked", "deprecation"}) public <T> T evaluate(String expr, Class<T> clazz) throws Exception { ELEvaluator existing = current.get(); try { current.set(this); return (T) evaluator.evaluate(expr, clazz, context, context); } catch (ELException ex) { if (ex.getRootCause() instanceof Exception) { throw (Exception) ex.getRootCause(); } else { throw ex; } } finally { current.set(existing); } }
public void handle(String data, ContentHandler handler) { ExpressionEvaluator evaluator = new ExpressionEvaluatorImpl(); Object value; try { value = evaluator.evaluate(data, Object.class, resolver, mapper); if (value != null) { char[] result = value.toString().toCharArray(); handler.characters(result, 0, result.length); } else { log.debug("Failed to resolve " + data); } } catch (ELException ele) { log.error("Failed to handle EL expression.", ele); } catch (SAXException saxe) { log.error("Failed to generate content.", saxe); } }
public MockPageContext(ServletRequest servletRequest) { // TODO: should the constructor invoke initialize(...) instead? this.request = servletRequest; this.response = new MockHttpServletResponse(); this.session = new MockHttpSession(); this.pageScopeAttributes = new HashMap(); this.applicationScopeAttributes = new HashMap(); this.servletContext = new MockServletContext(); this.servletConfig = new MockServletConfig(servletContext); this.expressionEvaluator = new ExpressionEvaluatorImpl(); }
public MockPageContext(ServletRequest servletRequest) { // TODO: should the constructor invoke initialize(...) instead? this.request = servletRequest; this.response = new MockHttpServletResponse(); this.session = new MockHttpSession(); this.pageScopeAttributes = new HashMap(); this.applicationScopeAttributes = new HashMap(); this.servletContext = new MockServletContext(); this.servletConfig = new MockServletConfig(servletContext); this.expressionEvaluator = new ExpressionEvaluatorImpl(); }
public void setExpression(String expression) throws ConversionException { if (expressionEvaluator == null) { expressionEvaluator = new ExpressionEvaluatorImpl(); } Class type = String.class; if (getType() != null) { type = getType(); } try { this.expression = expressionEvaluator.parseExpression(expression, type, null); } catch (ELException e) { throw new ConversionException("Failed to compile expression [" + expression + "]", e); } }