Java Script eval(String expression, Object... arguments)

Here you can find the source of eval(String expression, Object... arguments)

Description

eval

License

Apache License

Declaration

public static Object eval(String expression, Object... arguments) throws ScriptException 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;

public class Main {
    public static Object eval(String expression, Object... arguments) throws ScriptException {
        ScriptEngineManager engineManager = new ScriptEngineManager();
        ScriptEngine engine = engineManager.getEngineByName("JavaScript");
        for (int i = 0; i < arguments.length; i++) {
            expression = expression.replaceAll("%" + (i + 1), arguments[i].toString());
        }/*  w  w  w. j av  a2s  . c  om*/
        return engine.eval(expression);
    }
}

Related

  1. cdInShell(IResource resource)
  2. convert(Object from)
  3. dbObjectFromMap(Map from)
  4. decodeB64_TO_UTF8(String encodedStr)
  5. escapeJavascript(String str)
  6. eval(String name, Map params)
  7. eval(String script)
  8. evaluateExpression(String expr)
  9. evaluateExpression(String s)