ExpressionLanguageScriptEngineImpl.java 文件源码

java
阅读 18 收藏 0 点赞 0 评论 0

项目:oval 作者:
public Object evaluate(final String expression, final Map<String, ?> values) throws ExpressionEvaluationException {
    LOG.debug("Evaluating JavaScript expression: {1}", expression);
    try {
        final Bindings scope = engine.createBindings();
        for (final Entry<String, ?> entry : values.entrySet()) {
            scope.put(entry.getKey(), entry.getValue());
        }

        if (compilable != null) {
            CompiledScript compiled = compiledCache.get(expression);
            if (compiled == null) {
                compiled = compilable.compile(expression);
                compiledCache.put(expression, compiled);
            }
            return compiled.eval(scope);
        }
        return engine.eval(expression, scope);
    } catch (final ScriptException ex) {
        throw new ExpressionEvaluationException("Evaluating JavaScript expression failed: " + expression, ex);
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号