Java Utililty Methods Nashorn Javascript Library

List of utility methods to do Nashorn Javascript Library

Description

The list of methods to do Nashorn Javascript Library are organized into topic(s).

Method

booleanisNativeObject(final Object value)
is Native Object
return (value instanceof ScriptObject) && !isNativeArray(value);
ScriptObjectnewObject()
new Object
return Global.newEmptyInstance();
Stringparse(final String code, final String name, final boolean includeLoc)
Returns AST as JSON compatible string.
return ScriptRuntime.parse(code, name, includeLoc);
intrightAdjustCharHeadWithPrev(final int s, final IntHolder prev)
right Adjust Char Head With Prev
if (prev != null) {
    prev.value = -1; 
return s;
DatetoDate(final Object value)
to Date
final Number time = (Number) ((ScriptObjectMirror) value).callMember("getTime");
return new Date(time.longValue());
NativeRegExptoRegExp(String source, String optionsString)
to Reg Exp
return (NativeRegExp) NativeRegExp.constructor(true, null, source, optionsString);
Objectunwrap(final Object source)
unwrap
if (source instanceof ScriptObjectMirror) {
    return ScriptUtils.unwrap(source);
return source;
MapunwrapMap(ScriptObjectMirror jso)
unwrap Map
if (jso.isArray()) {
    throw new UnsupportedOperationException("JavaScript input is an Array!");
return (Map<String, Object>) unwrap(jso);
Objectwrap(Map map)
wrap
return ScriptObjectMirror.wrap(map, null);