Search in sources :

Example 1 with VariableResolver

use of org.mvel2.integration.VariableResolver in project mvel by mikebrock.

the class IndexedOperativeAssign method getReducedValueAccelerated.

public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) {
    VariableResolver resolver = factory.getIndexedVariableResolver(register);
    resolver.setValue(ctx = MathProcessor.doOperations(resolver.getValue(), operation, statement.getValue(ctx, thisValue, factory)));
    return ctx;
}
Also used : VariableResolver(org.mvel2.integration.VariableResolver)

Example 2 with VariableResolver

use of org.mvel2.integration.VariableResolver in project mvel by mikebrock.

the class DefaultLocalVariableResolverFactory method createVariable.

public VariableResolver createVariable(String name, Object value, Class<?> type) {
    if (indexedVariableNames == null)
        return super.createVariable(name, value, type);
    VariableResolver vr;
    boolean newVar = false;
    try {
        int idx;
        if ((idx = variableIndexOf(name)) != -1) {
            vr = new SimpleValueResolver(value);
            if (indexedVariableResolvers[idx] == null) {
                indexedVariableResolvers[idx] = vr;
            }
            variableResolvers.put(indexedVariableNames[idx], vr);
            vr = indexedVariableResolvers[idx];
            newVar = true;
        } else {
            return super.createVariable(name, value, type);
        }
    } catch (UnresolveablePropertyException e) {
        vr = null;
    }
    if (!newVar && vr != null && vr.getType() != null) {
        throw new RuntimeException("variable already defined within scope: " + vr.getType() + " " + name);
    } else {
        addResolver(name, vr = new MapVariableResolver(variables, name, type)).setValue(value);
        return vr;
    }
}
Also used : UnresolveablePropertyException(org.mvel2.UnresolveablePropertyException) VariableResolver(org.mvel2.integration.VariableResolver)

Example 3 with VariableResolver

use of org.mvel2.integration.VariableResolver in project mvel by mikebrock.

the class IndexedPostFixIncNode method getReducedValueAccelerated.

public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) {
    VariableResolver vResolver = factory.getIndexedVariableResolver(register);
    vResolver.setValue(MathProcessor.doOperations(ctx = vResolver.getValue(), Operator.ADD, DataTypes.INTEGER, 1));
    return ctx;
}
Also used : VariableResolver(org.mvel2.integration.VariableResolver)

Example 4 with VariableResolver

use of org.mvel2.integration.VariableResolver in project mvel by mikebrock.

the class IndexedPreFixDecNode method getReducedValueAccelerated.

public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) {
    VariableResolver vResolver = factory.getIndexedVariableResolver(register);
    vResolver.setValue(ctx = MathProcessor.doOperations(vResolver.getValue(), Operator.SUB, DataTypes.INTEGER, 1));
    return ctx;
}
Also used : VariableResolver(org.mvel2.integration.VariableResolver)

Example 5 with VariableResolver

use of org.mvel2.integration.VariableResolver in project mvel by mikebrock.

the class PostFixDecNode method getReducedValueAccelerated.

public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) {
    VariableResolver vResolver = factory.getVariableResolver(name);
    vResolver.setValue(MathProcessor.doOperations(ctx = vResolver.getValue(), Operator.SUB, DataTypes.INTEGER, 1));
    return ctx;
}
Also used : VariableResolver(org.mvel2.integration.VariableResolver)

Aggregations

VariableResolver (org.mvel2.integration.VariableResolver)18 HashMap (java.util.HashMap)1 AgendaItem (org.drools.core.common.AgendaItem)1 Declaration (org.drools.core.rule.Declaration)1 UnresolveablePropertyException (org.mvel2.UnresolveablePropertyException)1 VariableResolverFactory (org.mvel2.integration.VariableResolverFactory)1 DefaultLocalVariableResolverFactory (org.mvel2.integration.impl.DefaultLocalVariableResolverFactory)1 FunctionVariableResolverFactory (org.mvel2.integration.impl.FunctionVariableResolverFactory)1