public final class ScriptUtils extends Object
Modifier and Type | Method and Description |
---|---|
static Object |
convert(Object obj,
Object type)
Convert the given object to the given type.
|
static String |
format(String format,
Object[] args)
Method which converts javascript types to java types for the
String.format method (jrunscript function sprintf).
|
static Object |
makeSynchronizedFunction(jdk.nashorn.internal.runtime.ScriptFunction func,
Object sync)
Create a wrapper function that calls
func synchronized on sync or, if that is undefined,
self . |
static String |
parse(String code,
String name,
boolean includeLoc)
Returns AST as JSON compatible string.
|
static Object |
unwrap(Object obj)
Unwrap a script object mirror if needed.
|
static Object[] |
unwrapArray(Object[] args)
Unwrap an array of script object mirrors if needed.
|
static ScriptObjectMirror |
wrap(jdk.nashorn.internal.runtime.ScriptObject obj)
Make a script object mirror on given object if needed.
|
static Object[] |
wrapArray(Object[] args)
Wrap an array of object to script object mirrors if needed.
|
public static String parse(String code, String name, boolean includeLoc)
code
- code to be parsedname
- name of the code source (used for location)includeLoc
- tells whether to include location information for nodes or notpublic static String format(String format, Object[] args)
format
- a format stringargs
- arguments referenced by the format specifiers in formatpublic static Object makeSynchronizedFunction(jdk.nashorn.internal.runtime.ScriptFunction func, Object sync)
func
synchronized on sync
or, if that is undefined,
self
. Used to implement "sync" function in resources/mozilla_compat.js.func
- the function to wrapsync
- the object to synchronize onpublic static ScriptObjectMirror wrap(jdk.nashorn.internal.runtime.ScriptObject obj)
obj
- object to be wrappedpublic static Object unwrap(Object obj)
obj
- object to be unwrappedpublic static Object[] wrapArray(Object[] args)
args
- array to be unwrappedpublic static Object[] unwrapArray(Object[] args)
args
- array to be unwrapped
Copyright © 2014, 2015, Oracle and/or its affiliates. All rights reserved.