Search in sources :

Example 1 with ValueExpression

use of org.camunda.bpm.engine.impl.javax.el.ValueExpression in project camunda-bpm-platform by camunda.

the class AstIdentifier method setValue.

public void setValue(Bindings bindings, ELContext context, Object value) {
    ValueExpression expression = bindings.getVariable(index);
    if (expression != null) {
        expression.setValue(context, value);
        return;
    }
    context.setPropertyResolved(false);
    context.getELResolver().setValue(context, null, name, value);
    if (!context.isPropertyResolved()) {
        throw new PropertyNotFoundException(LocalMessages.get("error.identifier.property.notfound", name));
    }
}
Also used : PropertyNotFoundException(org.camunda.bpm.engine.impl.javax.el.PropertyNotFoundException) ValueExpression(org.camunda.bpm.engine.impl.javax.el.ValueExpression)

Example 2 with ValueExpression

use of org.camunda.bpm.engine.impl.javax.el.ValueExpression in project camunda-bpm-platform by camunda.

the class AstIdentifier method eval.

@Override
public Object eval(Bindings bindings, ELContext context) {
    ValueExpression expression = bindings.getVariable(index);
    if (expression != null) {
        return expression.getValue(context);
    }
    context.setPropertyResolved(false);
    Object result = context.getELResolver().getValue(context, null, name);
    if (!context.isPropertyResolved()) {
        throw new PropertyNotFoundException(LocalMessages.get("error.identifier.property.notfound", name));
    }
    return result;
}
Also used : PropertyNotFoundException(org.camunda.bpm.engine.impl.javax.el.PropertyNotFoundException) ValueExpression(org.camunda.bpm.engine.impl.javax.el.ValueExpression)

Example 3 with ValueExpression

use of org.camunda.bpm.engine.impl.javax.el.ValueExpression in project camunda-bpm-platform by camunda.

the class AstIdentifier method isReadOnly.

public boolean isReadOnly(Bindings bindings, ELContext context) {
    ValueExpression expression = bindings.getVariable(index);
    if (expression != null) {
        return expression.isReadOnly(context);
    }
    context.setPropertyResolved(false);
    boolean result = context.getELResolver().isReadOnly(context, null, name);
    if (!context.isPropertyResolved()) {
        throw new PropertyNotFoundException(LocalMessages.get("error.identifier.property.notfound", name));
    }
    return result;
}
Also used : PropertyNotFoundException(org.camunda.bpm.engine.impl.javax.el.PropertyNotFoundException) ValueExpression(org.camunda.bpm.engine.impl.javax.el.ValueExpression)

Example 4 with ValueExpression

use of org.camunda.bpm.engine.impl.javax.el.ValueExpression in project camunda-bpm-platform by camunda.

the class AstIdentifier method getType.

public Class<?> getType(Bindings bindings, ELContext context) {
    ValueExpression expression = bindings.getVariable(index);
    if (expression != null) {
        return expression.getType(context);
    }
    context.setPropertyResolved(false);
    Class<?> result = context.getELResolver().getType(context, null, name);
    if (!context.isPropertyResolved()) {
        throw new PropertyNotFoundException(LocalMessages.get("error.identifier.property.notfound", name));
    }
    return result;
}
Also used : PropertyNotFoundException(org.camunda.bpm.engine.impl.javax.el.PropertyNotFoundException) ValueExpression(org.camunda.bpm.engine.impl.javax.el.ValueExpression)

Example 5 with ValueExpression

use of org.camunda.bpm.engine.impl.javax.el.ValueExpression in project camunda-bpm-platform by camunda.

the class Tree method bind.

/**
 * Create a bindings.
 * @param fnMapper the function mapper to use
 * @param varMapper the variable mapper to use
 * @param converter custom type converter
 * @return tree bindings
 */
public Bindings bind(FunctionMapper fnMapper, VariableMapper varMapper, TypeConverter converter) {
    Method[] methods = null;
    if (!functions.isEmpty()) {
        if (fnMapper == null) {
            throw new ELException(LocalMessages.get("error.function.nomapper"));
        }
        methods = new Method[functions.size()];
        for (FunctionNode node : functions) {
            String image = node.getName();
            Method method = null;
            int colon = image.indexOf(':');
            if (colon < 0) {
                method = fnMapper.resolveFunction("", image);
            } else {
                method = fnMapper.resolveFunction(image.substring(0, colon), image.substring(colon + 1));
            }
            if (method == null) {
                throw new ELException(LocalMessages.get("error.function.notfound", image));
            }
            if (node.isVarArgs() && method.isVarArgs()) {
                if (method.getParameterTypes().length > node.getParamCount() + 1) {
                    throw new ELException(LocalMessages.get("error.function.params", image));
                }
            } else {
                if (method.getParameterTypes().length != node.getParamCount()) {
                    throw new ELException(LocalMessages.get("error.function.params", image));
                }
            }
            methods[node.getIndex()] = method;
        }
    }
    ValueExpression[] expressions = null;
    if (identifiers.size() > 0) {
        expressions = new ValueExpression[identifiers.size()];
        for (IdentifierNode node : identifiers) {
            ValueExpression expression = null;
            if (varMapper != null) {
                expression = varMapper.resolveVariable(node.getName());
            }
            expressions[node.getIndex()] = expression;
        }
    }
    return new Bindings(methods, expressions, converter);
}
Also used : ValueExpression(org.camunda.bpm.engine.impl.javax.el.ValueExpression) Method(java.lang.reflect.Method) ELException(org.camunda.bpm.engine.impl.javax.el.ELException)

Aggregations

ValueExpression (org.camunda.bpm.engine.impl.javax.el.ValueExpression)5 PropertyNotFoundException (org.camunda.bpm.engine.impl.javax.el.PropertyNotFoundException)4 Method (java.lang.reflect.Method)1 ELException (org.camunda.bpm.engine.impl.javax.el.ELException)1