public static Object executeExpression(Object compiledExpression) { try { return ((ExecutableStatement) compiledExpression).getValue(null, MVELRuntime.IMMUTABLE_DEFAULT_FACTORY); } catch (EndWithValue e) { return e.getValue(); } }
public static Object executeExpression(final Object compiledExpression, final Object ctx, final VariableResolverFactory resolverFactory) { try { return ((ExecutableStatement) compiledExpression).getValue(ctx, resolverFactory); } catch (EndWithValue end) { return end.getValue(); } }
/** * Executes a compiled expression. * * @param compiledExpression - * @param ctx - * @return - * @see #compileExpression(String) */ public static Object executeExpression(final Object compiledExpression, final Object ctx) { try { return ((ExecutableStatement) compiledExpression).getValue(ctx, MVELRuntime.IMMUTABLE_DEFAULT_FACTORY); } catch (EndWithValue end) { return end.getValue(); } }
/** * Evaluates an expression and returns the resultant value as a String. * * @param expression A string containing the expressino to be evaluated. * @return The resultant value */ public static String evalToString(String expression) { try { return valueOf(eval(expression)); } catch (EndWithValue end) { return valueOf(end.getValue()); } }
/** * Evaluates an expression and returns the resultant value as a String. * * @param expression A string containing the expressino to be evaluated. * @param ctx The context object to evaluate against * @return The resultant value * @see #eval(String,Object) */ public static String evalToString(String expression, Object ctx) { try { return valueOf(eval(expression, ctx)); } catch (EndWithValue end) { return valueOf(end.getValue()); } }
/** * Evaluates an expression and returns the resultant value as a String. * * @param expression A string containing the expressino to be evaluated. * @param vars A Map of variables to be injected * @return The resultant value * @see #eval(String,Map) */ public static String evalToString(String expression, Map vars) { try { return valueOf(eval(expression, vars)); } catch (EndWithValue end) { return valueOf(end.getValue()); } }
/** * Evaluates an expression and returns the resultant value as a String. * * @param expression A string containing the expressino to be evaluated. * @param vars The variables to be injected * @return The resultant value * @see #eval(String,VariableResolverFactory) */ public static String evalToString(String expression, VariableResolverFactory vars) { try { return valueOf(eval(expression, vars)); } catch (EndWithValue end) { return valueOf(end.getValue()); } }
private static Object _evalFile(File file, String encoding, Object ctx, VariableResolverFactory factory) throws IOException { try { return eval(loadFromFile(file, encoding), ctx, factory); } catch (EndWithValue end) { return end.getValue(); } }
/** * Evaluate an expression in Boolean-only mode against a root context object. * * @param expression A string containing the expression to be evaluated. * @param ctx The context against which to evaluate the expression * @return The resultant value as a Boolean */ public static Boolean evalToBoolean(String expression, Object ctx) { try { return eval(expression, ctx, Boolean.class); } catch (EndWithValue end) { return convert(end.getValue(), Boolean.class); } }
/** * Executes a compiled expression. * * @param compiledExpression - * @param ctx - * @param vars - * @return - * @see #compileExpression(String) */ @SuppressWarnings({"unchecked"}) public static Object executeExpression(final Object compiledExpression, final Object ctx, final Map vars) { try { return ((ExecutableStatement) compiledExpression).getValue(ctx, vars != null ? new MapVariableResolverFactory(vars) : null); } catch (EndWithValue end) { return end.getValue(); } }
/** * 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) { try { return new MVELInterpretedRuntime(expression, MVELRuntime.IMMUTABLE_DEFAULT_FACTORY).parse(); } catch (EndWithValue end) { return end.getValue(); } }
/** * Evaluate an expression in Boolean-only with injected variables. * * @param expression A string containing the expression to be evaluated. * @param vars The variables to be injected * @return The resultant value as a Boolean */ public static Boolean evalToBoolean(String expression, Map<String, Object> vars) { try { return evalToBoolean(expression, null, vars); } catch (EndWithValue end) { return convert(end.getValue(), Boolean.class); } }
/** * Evaluate an expression in Boolean-only with injected variables. * * @param expression A string containing the expression to be evaluated. * @param vars The variables to be injected * @return The resultant value as a Boolean */ public static Boolean evalToBoolean(String expression, VariableResolverFactory vars) { try { return eval(expression, vars, Boolean.class); } catch (EndWithValue end) { return convert(end.getValue(), Boolean.class); } }
/** * Evaluate an expression in Boolean-only mode against a root context object and injected variables. * * @param expression A string containing the expression to be evaluated. * @param ctx The context against which to evaluate the expression * @param vars The variables to be injected * @return The resultant value as a Boolean */ public static Boolean evalToBoolean(String expression, Object ctx, VariableResolverFactory vars) { try { return eval(expression, ctx, vars, Boolean.class); } catch (EndWithValue end) { return convert(end.getValue(), Boolean.class); } }
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 static <T> T executeExpression(final Object compiledExpression, final Object ctx, final VariableResolverFactory vars, Class<T> toType) { try { return convert(executeExpression(compiledExpression, ctx, vars), toType); } catch (EndWithValue end) { return convert(end.getValue(), toType); } }
/** * Execute a compiled expression and convert the result to a type * * @param compiledExpression - * @param ctx - * @param vars - * @param toType - * @return - */ @SuppressWarnings({"unchecked"}) public static <T> T executeExpression(final Object compiledExpression, final Object ctx, final Map vars, Class<T> toType) { try { return convert(executeExpression(compiledExpression, ctx, vars), toType); } catch (EndWithValue end) { return convert(end.getValue(), toType); } }
/** * Execute a compiled expression and convert the result to a type. * * @param compiledExpression - * @param ctx - * @param toType - * @return - */ public static <T> T executeExpression(final Object compiledExpression, final Object ctx, Class<T> toType) { try { return convert(executeExpression(compiledExpression, ctx), toType); } catch (EndWithValue end) { return convert(end.getValue(), 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) { try { return convert(new MVELInterpretedRuntime(expression, null, vars).parse(), toType); } catch (EndWithValue end) { return convert(end.getValue(), toType); } }
public static Object executeDebugger(CompiledExpression expression, Object ctx, VariableResolverFactory vars) { try { if (expression.isImportInjectionRequired()) { return execute(true, expression, ctx, new ClassImportResolverFactory(expression .getParserContext().getParserConfiguration(), vars)); } else { return execute(true, expression, ctx, vars); } } catch (EndWithValue e) { return e.getValue(); } }