Java Utililty Methods Script

List of utility methods to do Script

Description

The list of methods to do Script are organized into topic(s).

Method

StringgetScriptCompileMsg(ScriptException ex)
get Script Compile Msg
if (ex.getLineNumber() != 1 && ex.getColumnNumber() != -1) {
    return "At line " + ex.getLineNumber() + " column " + ex.getColumnNumber() + ": " + ex.getMessage();
} else {
    return ex.getMessage();
StringgetSpParamOfWeiboLogin(String pwd, String servicetime, String nonce)
get Sp Param Of Weibo Login
return getSpParamOfWeiboLogin(pwd, servicetime, nonce, rsaPubkey);
voidremoveScript(String name)
remove Script
if (ccMap.containsKey(name))
    ccMap.remove(name);
voidrunScript(final String script)
run Script
ScriptEngineManager scriptEngineManager = new ScriptEngineManager();
ScriptEngine engine = scriptEngineManager.getEngineByName("JavaScript");
engine.eval(script);
MaptoMap(ScriptObjectMirror som, Class type)
to Map
if (som == null)
    return null;
if (som.isArray())
    throw new ScriptException("The JS object is an array");
Map<String, T> map = new LinkedHashMap<String, T>();
if (som.isEmpty())
    return map;
som.forEach((s, o) -> map.put(s, ((ScriptObjectMirror) o).to(type)));
...
StringtoSci(BigDecimal bd, int sf)
to Sci
Double x = bd.doubleValue();
if (x.equals(Double.POSITIVE_INFINITY) || x.equals(Double.NEGATIVE_INFINITY)) {
    return x.toString();
} else {
    try {
        return toString(
                Double.parseDouble(engine.eval("Number(" + x + ").toPrecision(" + sf + ")").toString()));
    } catch (Exception ex) {
...