Search in sources :

Example 16 with VariableResolver

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

the class OperativeAssign method getReducedValueAccelerated.

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

Example 17 with VariableResolver

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

the class OperativeAssign method getReducedValue.

public Object getReducedValue(Object ctx, Object thisValue, VariableResolverFactory factory) {
    VariableResolver resolver = factory.getVariableResolver(varName);
    resolver.setValue(ctx = MathProcessor.doOperations(resolver.getValue(), operation, eval(expr, start, offset, ctx, factory)));
    return ctx;
}
Also used : VariableResolver(org.mvel2.integration.VariableResolver)

Example 18 with VariableResolver

use of org.mvel2.integration.VariableResolver in project drools by kiegroup.

the class ActivationPropertyHandler method getProperty.

public Object getProperty(String name, Object obj, VariableResolverFactory variableFactory) {
    AgendaItem item = (AgendaItem) obj;
    if ("rule".equals(name)) {
        return item.getRule();
    } else if ("active".equals(name)) {
        return item.isQueued();
    } else if ("objects".equals(name)) {
        return item.getObjects();
    } else if ("factHandles".equals(name)) {
        return item.getFactHandles();
    } else if ("declarationIds".equals(name)) {
        return item.getDeclarationIds();
    } else if ("this".equals(name)) {
        return item;
    }
    // FIXME hack as MVEL seems to be ignoring indexed variables
    VariableResolver vr = variableFactory.getNextFactory().getVariableResolver(name);
    if (vr != null) {
        return vr.getValue();
    }
    Declaration declr = item.getTerminalNode().getSubRule().getOuterDeclarations().get(name);
    if (declr != null) {
        return declr.getValue(null, item.getTuple().get(declr).getObject());
    } else {
        return item.getRule().getMetaData(name);
    }
}
Also used : Declaration(org.drools.core.rule.Declaration) VariableResolver(org.mvel2.integration.VariableResolver) AgendaItem(org.drools.core.common.AgendaItem)

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