Search in sources :

Example 1 with EvaluationContext

use of org.apache.el.lang.EvaluationContext in project tomcat70 by apache.

the class MethodExpressionImpl method getMethodInfo.

/**
 * Evaluates the expression relative to the provided context, and returns
 * information about the actual referenced method.
 *
 * @param context
 *            The context of this evaluation
 * @return an instance of <code>MethodInfo</code> containing information
 *         about the method the expression evaluated to.
 * @throws NullPointerException
 *             if context is <code>null</code> or the base object is
 *             <code>null</code> on the last resolution.
 * @throws PropertyNotFoundException
 *             if one of the property resolutions failed because a specified
 *             variable or property does not exist or is not readable.
 * @throws MethodNotFoundException
 *             if no suitable method can be found.
 * @throws ELException
 *             if an exception was thrown while performing property or
 *             variable resolution. The thrown exception must be included as
 *             the cause property of this exception, if available.
 * @see javax.el.MethodExpression#getMethodInfo(javax.el.ELContext)
 */
@Override
public MethodInfo getMethodInfo(ELContext context) throws PropertyNotFoundException, MethodNotFoundException, ELException {
    Node n = this.getNode();
    EvaluationContext ctx = new EvaluationContext(context, this.fnMapper, this.varMapper);
    return n.getMethodInfo(ctx, this.paramTypes);
}
Also used : Node(org.apache.el.parser.Node) EvaluationContext(org.apache.el.lang.EvaluationContext)

Example 2 with EvaluationContext

use of org.apache.el.lang.EvaluationContext in project tomcat by apache.

the class MethodExpressionImpl method invoke.

/**
 * Evaluates the expression relative to the provided context, invokes the
 * method that was found using the supplied parameters, and returns the
 * result of the method invocation.
 *
 * @param context
 *            The context of this evaluation.
 * @param params
 *            The parameters to pass to the method, or <code>null</code>
 *            if no parameters.
 * @return the result of the method invocation (<code>null</code> if the
 *         method has a <code>void</code> return type).
 * @throws NullPointerException
 *             if context is <code>null</code> or the base object is
 *             <code>null</code> on the last resolution.
 * @throws PropertyNotFoundException
 *             if one of the property resolutions failed because a specified
 *             variable or property does not exist or is not readable.
 * @throws MethodNotFoundException
 *             if no suitable method can be found.
 * @throws ELException
 *             if an exception was thrown while performing property or
 *             variable resolution. The thrown exception must be included as
 *             the cause property of this exception, if available. If the
 *             exception thrown is an <code>InvocationTargetException</code>,
 *             extract its <code>cause</code> and pass it to the
 *             <code>ELException</code> constructor.
 * @see jakarta.el.MethodExpression#invoke(jakarta.el.ELContext,
 *      java.lang.Object[])
 */
@Override
public Object invoke(ELContext context, Object[] params) throws PropertyNotFoundException, MethodNotFoundException, ELException {
    EvaluationContext ctx = new EvaluationContext(context, this.fnMapper, this.varMapper);
    ctx.notifyBeforeEvaluation(getExpressionString());
    Object result = this.getNode().invoke(ctx, this.paramTypes, params);
    ctx.notifyAfterEvaluation(getExpressionString());
    return result;
}
Also used : EvaluationContext(org.apache.el.lang.EvaluationContext)

Example 3 with EvaluationContext

use of org.apache.el.lang.EvaluationContext in project tomcat by apache.

the class MethodExpressionImpl method getMethodReference.

@Override
public MethodReference getMethodReference(ELContext context) {
    EvaluationContext ctx = new EvaluationContext(context, this.fnMapper, this.varMapper);
    ctx.notifyBeforeEvaluation(getExpressionString());
    MethodReference methodReference = this.getNode().getMethodReference(ctx);
    ctx.notifyAfterEvaluation(getExpressionString());
    return methodReference;
}
Also used : MethodReference(jakarta.el.MethodReference) EvaluationContext(org.apache.el.lang.EvaluationContext)

Example 4 with EvaluationContext

use of org.apache.el.lang.EvaluationContext in project tomcat by apache.

the class ValueExpressionImpl method getValue.

/*
     * (non-Javadoc)
     *
     * @see jakarta.el.ValueExpression#getValue(jakarta.el.ELContext)
     */
@SuppressWarnings("unchecked")
@Override
public <T> T getValue(ELContext context) throws PropertyNotFoundException, ELException {
    EvaluationContext ctx = new EvaluationContext(context, this.fnMapper, this.varMapper);
    context.notifyBeforeEvaluation(getExpressionString());
    Object value = this.getNode().getValue(ctx);
    if (this.expectedType != null) {
        value = context.convertToType(value, this.expectedType);
    }
    context.notifyAfterEvaluation(getExpressionString());
    return (T) value;
}
Also used : EvaluationContext(org.apache.el.lang.EvaluationContext)

Example 5 with EvaluationContext

use of org.apache.el.lang.EvaluationContext in project tomcat by apache.

the class ValueExpressionImpl method getType.

/*
     * (non-Javadoc)
     *
     * @see jakarta.el.ValueExpression#getType(jakarta.el.ELContext)
     */
@Override
public Class<?> getType(ELContext context) throws PropertyNotFoundException, ELException {
    EvaluationContext ctx = new EvaluationContext(context, this.fnMapper, this.varMapper);
    context.notifyBeforeEvaluation(getExpressionString());
    Class<?> result = this.getNode().getType(ctx);
    context.notifyAfterEvaluation(getExpressionString());
    return result;
}
Also used : EvaluationContext(org.apache.el.lang.EvaluationContext)

Aggregations

EvaluationContext (org.apache.el.lang.EvaluationContext)11 Node (org.apache.el.parser.Node)2 MethodInfo (jakarta.el.MethodInfo)1 MethodReference (jakarta.el.MethodReference)1 ValueReference (jakarta.el.ValueReference)1