/** * Evaluate an expression against a context object and return the value * * @param expression A char[] containing the expression to be evaluated. * @param ctx The context object to evaluate against * @return The resultant value * @see #eval(String, Object) */ public static Object eval(char[] expression, Object ctx) { return new MVELInterpretedRuntime(expression, ctx).parse(); }
/** * Evaluate an expression against a context object and return the value * * @param expression A char[] containing the expression to be evaluated. * @param ctx The context object to evaluate against * @param vars The variables to be injected * @return The resultant value * @see #eval(String, Object, VariableResolverFactory) */ public static Object eval(char[] expression, Object ctx, VariableResolverFactory vars) { return new MVELInterpretedRuntime(expression, ctx, vars).parse(); }
/** * Evaluate an expression against a context object and return the value * * @param expression A char[] containing the expression to be evaluated. * @param ctx The context object to evaluate against * @param vars A Map of variables to be injected * @return The resultant value * @see #eval(String, Object, Map) */ public static Object eval(char[] expression, Object ctx, Map vars) { return new MVELInterpretedRuntime(expression, ctx, vars).parse(); }
/** * Evaluate an expression and return the value. * * @param expression A String containing the expression to be evaluated. * @return the resultant value */ public static Object eval(String expression) { return new MVELInterpretedRuntime(expression, MVELRuntime.IMMUTABLE_DEFAULT_FACTORY).parse(); }
/** * Evaluate an expression against a context object and return the value * * @param expression A char[] containing the expression to be evaluated. * @param ctx The context object to evaluate against * @param vars A Map of variables to be injected * @return The resultant value * @see #eval(String, Object, Map) */ public static Object eval(char[] expression, Object ctx, Map vars) { return new MVELInterpretedRuntime(expression, ctx, vars).parse(); }
/** * Evaluate an expression against a context object and return the value * * @param expression A char[] containing the expression to be evaluated. * @param ctx The context object to evaluate against * @param vars The variables to be injected * @return The resultant value * @see #eval(String, Object, VariableResolverFactory) */ public static Object eval(char[] expression, Object ctx, VariableResolverFactory vars) { return new MVELInterpretedRuntime(expression, ctx, vars).parse(); }
/** * Evaluates an expression against a context object and injected variables from a {@link VariableResolverFactory}. * This method of execution will prefer to find variables from the factory and <em>then</em> from the context. * * @param expression A string containing the expression to be evaluated * @param ctx The context object to evaluate against. * @param resolverFactory The instance of the VariableResolverFactory to be used. * @return The resultant value * @see #eval(String, org.mvel2.integration.VariableResolverFactory) */ public static Object eval(String expression, Object ctx, VariableResolverFactory resolverFactory) { return new MVELInterpretedRuntime(expression, ctx, resolverFactory).parse(); }
/** * Evaluate an expression against a context object and return the value * * @param expression A char[] containing the expression to be evaluated. * @param ctx The context object to evaluate against * @return The resultant value * @see #eval(String, Object) */ public static Object eval(char[] expression, Object ctx) { return new MVELInterpretedRuntime(expression, ctx).parse(); }
/** * Evaluate an expression with a context object and return the value. If necessary convert * the resultant value to the specified type. * * @param expression A char[] containing the expression to be evaluated. * @param ctx The context object to evaluate against * @param toType The target type the resultant value will be converted to, if necessary. * @return The resultant value * @see #eval(String, Object, Class) */ public static <T> T eval(char[] expression, Object ctx, Class<T> toType) { return convert(new MVELInterpretedRuntime(expression, ctx).parse(), toType); }
/** * Evaluate an expression with injected variables and return the resultant value. If necessary convert * the resultant value to the specified type. * * @param expression A char[] containing the expression to be evaluated. * @param vars The variables to be injected * @param toType The target type the resultant value will be converted to, if necessary. * @return The resultant value * @see #eval(String, Map, Class) */ public static <T> T eval(char[] expression, Map<String, Object> vars, Class<T> toType) { return convert(new MVELInterpretedRuntime(expression, null, vars).parse(), toType); }
/** * Evaluates an expression against a context object and, if necessary, coerces the resultant value to the specified * type. * * @param expression A string containing the expression to be evaluated. * @param ctx The context object to evaluate against. * @param toType The target type that the resultant value will be converted to, if necessary. * @return The resultant value * @see #eval(String, Class) */ public static <T> T eval(String expression, Object ctx, Class<T> toType) { return convert(new MVELInterpretedRuntime(expression, ctx).parse(), toType); }
/** * Evaluate an expression with injected variables and return the value. If necessary convert * the resultant value to the specified type. * * @param expression A char[] containing the expression to be evaluated. * @param vars The variables to be injected * @param toType The target type the resultant value will be converted to, if necessary. * @return The resultant value * @see #eval(String, VariableResolverFactory, Class) */ public static <T> T eval(char[] expression, VariableResolverFactory vars, Class<T> toType) { return convert(new MVELInterpretedRuntime(expression, null, vars).parse(), toType); }
/** * Evaluate an expression and return the value. * * @param expression A char[] containing the expression to be evaluated. * @return The resultant value * @see #eval(String) */ public static Object eval(char[] expression) { return new MVELInterpretedRuntime(expression, new ImmutableDefaultFactory()).parse(); }
/** * Evaluate an expression and return the value. * * @param expression A String containing the expression to be evaluated. * @return the resultant value */ public static Object eval(String expression) { return new MVELInterpretedRuntime(expression, new ImmutableDefaultFactory()).parse(); }
/** * Evaluates an expression against externally injected variables. This is a wrapper convenience method which * wraps the provided Map of vars in a {@link MapVariableResolverFactory} * * @param expression A string containing the expression to be evaluated. * @param vars A map of vars to be injected * @return The resultant value * @see #eval(String, org.mvel2.integration.VariableResolverFactory) */ public static Object eval(String expression, Map<String, Object> vars) { return new MVELInterpretedRuntime(expression, null, new MapVariableResolverFactory(vars)).parse(); }
/** * Evaluate an expression and return the value. * * @param expression A char[] containing the expression to be evaluated. * @return The resultant value * @see #eval(String) */ public static Object eval(char[] expression) { return new MVELInterpretedRuntime(expression, new ImmutableDefaultFactory()).parse(); }
/** * Evaluate an expression and return the value. * * @param expression A String containing the expression to be evaluated. * @return the resultant value */ public static Object eval(String expression) { return new MVELInterpretedRuntime(expression, new ImmutableDefaultFactory()).parse(); }
public static <T> T eval(char[] expression, Class<T> type) { try { return convert(new MVELInterpretedRuntime(expression).parse(), type); } catch (EndWithValue end) { return (T) end.getValue(); } }
public Object getReducedValue(Object ctx, Object thisValue, VariableResolverFactory factory) { checkNameSafety(varName); MVELInterpretedRuntime runtime = new MVELInterpretedRuntime(expr, start, offset, ctx, factory, pCtx); if (col) { PropertyAccessor.set(factory.getVariableResolver(varName).getValue(), factory, index, ctx = runtime.parse(), pCtx); } else { return factory.createVariable(varName, runtime.parse()).getValue(); } return ctx; }
public Object getReducedValue(Object ctx, Object thisValue, VariableResolverFactory factory) { checkNameSafety(varName); MVELInterpretedRuntime runtime = new MVELInterpretedRuntime(expr, start, offset, ctx, factory, pCtx); if (col) { PropertyAccessor.set(factory.getVariableResolver(varName).getValue(), factory, index, ctx = runtime.parse(), pCtx); } else { return factory.createVariable(varName, runtime.parse()).getValue(); } return ctx; }