Search in sources :

Example 1 with PropertyNotFoundException

use of javax.el.PropertyNotFoundException in project tomcat70 by apache.

the class AstValue method getValue.

@Override
public Object getValue(EvaluationContext ctx) throws ELException {
    Object base = this.children[0].getValue(ctx);
    int propCount = this.jjtGetNumChildren();
    int i = 1;
    Object suffix = null;
    ELResolver resolver = ctx.getELResolver();
    while (base != null && i < propCount) {
        suffix = this.children[i].getValue(ctx);
        if (i + 1 < propCount && (this.children[i + 1] instanceof AstMethodParameters)) {
            AstMethodParameters mps = (AstMethodParameters) this.children[i + 1];
            // This is a method
            Object[] paramValues = mps.getParameters(ctx);
            base = resolver.invoke(ctx, base, suffix, getTypesFromValues(paramValues), paramValues);
            i += 2;
        } else {
            // This is a property
            if (suffix == null) {
                return null;
            }
            ctx.setPropertyResolved(false);
            base = resolver.getValue(ctx, base, suffix);
            i++;
        }
    }
    if (!ctx.isPropertyResolved()) {
        throw new PropertyNotFoundException(MessageFactory.get("error.resolver.unhandled", base, suffix));
    }
    return base;
}
Also used : ELResolver(javax.el.ELResolver) PropertyNotFoundException(javax.el.PropertyNotFoundException)

Example 2 with PropertyNotFoundException

use of javax.el.PropertyNotFoundException in project tomcat70 by apache.

the class AstIdentifier method getType.

@Override
public Class<?> getType(EvaluationContext ctx) throws ELException {
    VariableMapper varMapper = ctx.getVariableMapper();
    if (varMapper != null) {
        ValueExpression expr = varMapper.resolveVariable(this.image);
        if (expr != null) {
            return expr.getType(ctx.getELContext());
        }
    }
    ctx.setPropertyResolved(false);
    Class<?> result = ctx.getELResolver().getType(ctx, null, this.image);
    if (!ctx.isPropertyResolved()) {
        throw new PropertyNotFoundException(MessageFactory.get("error.resolver.unhandled.null", this.image));
    }
    return result;
}
Also used : PropertyNotFoundException(javax.el.PropertyNotFoundException) VariableMapper(javax.el.VariableMapper) ValueExpression(javax.el.ValueExpression)

Example 3 with PropertyNotFoundException

use of javax.el.PropertyNotFoundException in project tomcat70 by apache.

the class AstIdentifier method setValue.

@Override
public void setValue(EvaluationContext ctx, Object value) throws ELException {
    VariableMapper varMapper = ctx.getVariableMapper();
    if (varMapper != null) {
        ValueExpression expr = varMapper.resolveVariable(this.image);
        if (expr != null) {
            expr.setValue(ctx.getELContext(), value);
            return;
        }
    }
    ctx.setPropertyResolved(false);
    ctx.getELResolver().setValue(ctx, null, this.image, value);
    if (!ctx.isPropertyResolved()) {
        throw new PropertyNotFoundException(MessageFactory.get("error.resolver.unhandled.null", this.image));
    }
}
Also used : PropertyNotFoundException(javax.el.PropertyNotFoundException) VariableMapper(javax.el.VariableMapper) ValueExpression(javax.el.ValueExpression)

Example 4 with PropertyNotFoundException

use of javax.el.PropertyNotFoundException in project tomcat70 by apache.

the class AstValue method setValue.

@Override
public void setValue(EvaluationContext ctx, Object value) throws ELException {
    Target t = getTarget(ctx);
    ctx.setPropertyResolved(false);
    ELResolver resolver = ctx.getELResolver();
    // coerce to the expected type
    Class<?> targetClass = resolver.getType(ctx, t.base, t.property);
    if (COERCE_TO_ZERO == true || !isAssignable(value, targetClass)) {
        resolver.setValue(ctx, t.base, t.property, ELSupport.coerceToType(value, targetClass));
    } else {
        resolver.setValue(ctx, t.base, t.property, value);
    }
    if (!ctx.isPropertyResolved()) {
        throw new PropertyNotFoundException(MessageFactory.get("error.resolver.unhandled", t.base, t.property));
    }
}
Also used : ELResolver(javax.el.ELResolver) PropertyNotFoundException(javax.el.PropertyNotFoundException)

Example 5 with PropertyNotFoundException

use of javax.el.PropertyNotFoundException in project tomcat70 by apache.

the class AstValue method getTarget.

private final Target getTarget(EvaluationContext ctx) throws ELException {
    // evaluate expr-a to value-a
    Object base = this.children[0].getValue(ctx);
    // if our base is null (we know there are more properties to evaluate)
    if (base == null) {
        throw new PropertyNotFoundException(MessageFactory.get("error.unreachable.base", this.children[0].getImage()));
    }
    // set up our start/end
    Object property = null;
    int propCount = this.jjtGetNumChildren();
    int i = 1;
    // Evaluate any properties or methods before our target
    ELResolver resolver = ctx.getELResolver();
    while (i < propCount) {
        if (i + 2 < propCount && this.children[i + 1] instanceof AstMethodParameters) {
            // Method call not at end of expression
            base = resolver.invoke(ctx, base, this.children[i].getValue(ctx), null, ((AstMethodParameters) this.children[i + 1]).getParameters(ctx));
            i += 2;
        } else if (i + 2 == propCount && this.children[i + 1] instanceof AstMethodParameters) {
            // Method call at end of expression
            ctx.setPropertyResolved(false);
            property = this.children[i].getValue(ctx);
            i += 2;
            if (property == null) {
                throw new PropertyNotFoundException(MessageFactory.get("error.unreachable.property", property));
            }
        } else if (i + 1 < propCount) {
            // Object with property not at end of expression
            property = this.children[i].getValue(ctx);
            ctx.setPropertyResolved(false);
            base = resolver.getValue(ctx, base, property);
            i++;
        } else {
            // Object with property at end of expression
            ctx.setPropertyResolved(false);
            property = this.children[i].getValue(ctx);
            i++;
            if (property == null) {
                throw new PropertyNotFoundException(MessageFactory.get("error.unreachable.property", property));
            }
        }
        if (base == null) {
            throw new PropertyNotFoundException(MessageFactory.get("error.unreachable.property", property));
        }
    }
    Target t = new Target();
    t.base = base;
    t.property = property;
    return t;
}
Also used : PropertyNotFoundException(javax.el.PropertyNotFoundException) ELResolver(javax.el.ELResolver)

Aggregations

PropertyNotFoundException (javax.el.PropertyNotFoundException)9 ValueExpression (javax.el.ValueExpression)4 VariableMapper (javax.el.VariableMapper)4 ELResolver (javax.el.ELResolver)3 Map (java.util.Map)1 MethodNotFoundException (javax.el.MethodNotFoundException)1 ActivitiException (org.activiti.engine.ActivitiException)1 ExpressionGetInvocation (org.activiti.engine.impl.delegate.invocation.ExpressionGetInvocation)1 UtilObject (org.apache.ofbiz.base.util.UtilObject)1