List of utility methods to do Script
String | getScriptCompileMsg(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(); |
String | getSpParamOfWeiboLogin(String pwd, String servicetime, String nonce) get Sp Param Of Weibo Login return getSpParamOfWeiboLogin(pwd, servicetime, nonce, rsaPubkey);
|
void | removeScript(String name) remove Script if (ccMap.containsKey(name))
ccMap.remove(name);
|
void | runScript(final String script) run Script ScriptEngineManager scriptEngineManager = new ScriptEngineManager(); ScriptEngine engine = scriptEngineManager.getEngineByName("JavaScript"); engine.eval(script); |
Map | toMap(ScriptObjectMirror som, Class 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))); ... |
String | toSci(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) { ... |