List of utility methods to do Nashorn Javascript Library
boolean | isNativeObject(final Object value) is Native Object return (value instanceof ScriptObject) && !isNativeArray(value); |
ScriptObject | newObject() new Object return Global.newEmptyInstance();
|
String | parse(final String code, final String name, final boolean includeLoc) Returns AST as JSON compatible string. return ScriptRuntime.parse(code, name, includeLoc);
|
int | rightAdjustCharHeadWithPrev(final int s, final IntHolder prev) right Adjust Char Head With Prev if (prev != null) { prev.value = -1; return s; |
Date | toDate(final Object value) to Date final Number time = (Number) ((ScriptObjectMirror) value).callMember("getTime"); return new Date(time.longValue()); |
NativeRegExp | toRegExp(String source, String optionsString) to Reg Exp return (NativeRegExp) NativeRegExp.constructor(true, null, source, optionsString);
|
Object | unwrap(final Object source) unwrap if (source instanceof ScriptObjectMirror) { return ScriptUtils.unwrap(source); return source; |
Map | unwrapMap(ScriptObjectMirror jso) unwrap Map if (jso.isArray()) { throw new UnsupportedOperationException("JavaScript input is an Array!"); return (Map<String, Object>) unwrap(jso); |
Object | wrap(Map wrap return ScriptObjectMirror.wrap(map, null);
|