public class Global extends ImporterTopLevel
TopLevel.Builtins
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST
NOT_FOUND
Modifier and Type | Method and Description |
---|---|
static void |
defineClass(Context cx,
Scriptable thisObj,
java.lang.Object[] args,
Function funObj)
Load a Java class that defines a JavaScript object using the
conventions outlined in ScriptableObject.defineClass.
|
static java.lang.Object |
deserialize(Context cx,
Scriptable thisObj,
java.lang.Object[] args,
Function funObj) |
static java.lang.Object |
doctest(Context cx,
Scriptable thisObj,
java.lang.Object[] args,
Function funObj)
Example: doctest("js> function f() {\n > return 3;\n > }\njs> f();\n3\n"); returns 2
(since 2 tests were executed).
|
static void |
gc(Context cx,
Scriptable thisObj,
java.lang.Object[] args,
Function funObj) |
ShellConsole |
getConsole(java.nio.charset.Charset cs) |
java.io.PrintStream |
getErr() |
java.io.InputStream |
getIn() |
java.io.PrintStream |
getOut() |
java.lang.String[] |
getPrompts(Context cx) |
static void |
help(Context cx,
Scriptable thisObj,
java.lang.Object[] args,
Function funObj)
Print a help message.
|
void |
init(Context cx) |
void |
init(ContextFactory factory) |
void |
initQuitAction(QuitAction quitAction)
Set the action to call from quit().
|
Require |
installRequire(Context cx,
java.util.List<java.lang.String> modulePath,
boolean sandboxed) |
boolean |
isInitialized() |
static void |
load(Context cx,
Scriptable thisObj,
java.lang.Object[] args,
Function funObj)
Load and execute a set of JavaScript source files.
|
static void |
loadClass(Context cx,
Scriptable thisObj,
java.lang.Object[] args,
Function funObj)
Load and execute a script compiled to a class file.
|
static java.lang.Object |
print(Context cx,
Scriptable thisObj,
java.lang.Object[] args,
Function funObj)
Print the string values of its arguments.
|
static void |
quit(Context cx,
Scriptable thisObj,
java.lang.Object[] args,
Function funObj)
Call embedding-specific quit action passing its argument as
int32 exit code.
|
static java.lang.Object |
readFile(Context cx,
Scriptable thisObj,
java.lang.Object[] args,
Function funObj)
The readFile reads the given file content and convert it to a string
using the specified character coding or default character coding if
explicit coding argument is not given.
|
static java.lang.Object |
readline(Context cx,
Scriptable thisObj,
java.lang.Object[] args,
Function funObj)
The readline reads one line from the standard input.
|
static java.lang.Object |
readUrl(Context cx,
Scriptable thisObj,
java.lang.Object[] args,
Function funObj)
The readUrl opens connection to the given URL, read all its data
and converts them to a string
using the specified character coding or default character coding if
explicit coding argument is not given.
|
static java.lang.Object |
runCommand(Context cx,
Scriptable thisObj,
java.lang.Object[] args,
Function funObj)
Execute the specified command with the given argument and options
as a separate process and return the exit status of the process.
|
int |
runDoctest(Context cx,
Scriptable scope,
java.lang.String session,
java.lang.String sourceName,
int lineNumber) |
static void |
seal(Context cx,
Scriptable thisObj,
java.lang.Object[] args,
Function funObj)
The seal function seals all supplied arguments.
|
static void |
serialize(Context cx,
Scriptable thisObj,
java.lang.Object[] args,
Function funObj) |
void |
setErr(java.io.PrintStream err) |
void |
setIn(java.io.InputStream in) |
void |
setOut(java.io.PrintStream out) |
void |
setSealedStdLib(boolean value) |
static java.lang.Object |
spawn(Context cx,
Scriptable thisObj,
java.lang.Object[] args,
Function funObj)
The spawn function runs a given function or script in a different
thread.
|
static java.lang.Object |
sync(Context cx,
Scriptable thisObj,
java.lang.Object[] args,
Function funObj)
The sync function creates a synchronized function (in the sense
of a Java synchronized method) from an existing function.
|
static java.lang.Object |
toint32(Context cx,
Scriptable thisObj,
java.lang.Object[] args,
Function funObj)
Convert the argument to int32 number.
|
static double |
version(Context cx,
Scriptable thisObj,
java.lang.Object[] args,
Function funObj)
Get and set the language version.
|
static java.lang.Object |
write(Context cx,
Scriptable thisObj,
java.lang.Object[] args,
Function funObj)
Print just as in "print," but without the trailing newline.
|
execIdCall, get, getClassName, has, importPackage, init, initStandardObjects
cacheBuiltins, getBuiltinCtor, getBuiltinCtor, getBuiltinPrototype, getBuiltinPrototype
activatePrototypeMap, defineOwnProperty, delete, exportAsJSClass, getAttributes, hasPrototypeMap, initPrototypeConstructor, initPrototypeMethod, initPrototypeValue, put, setAttributes
associateValue, avoidObjectDetection, callMethod, callMethod, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineProperty, defineProperty, defineProperty, defineProperty, delete, deleteProperty, deleteProperty, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGetterOrSetter, getIds, getObjectPrototype, getParentScope, getProperty, getProperty, getPropertyIds, getPrototype, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, hasInstance, hasProperty, hasProperty, isConst, isEmpty, isExtensible, isSealed, preventExtensions, put, putConst, putConstProperty, putProperty, putProperty, redefineProperty, sealObject, setAttributes, setAttributes, setAttributes, setExternalArrayData, setGetterOrSetter, setParentScope, setPrototype, size
public Global()
public Global(Context cx)
public boolean isInitialized()
public void initQuitAction(QuitAction quitAction)
public void init(ContextFactory factory)
public void init(Context cx)
public Require installRequire(Context cx, java.util.List<java.lang.String> modulePath, boolean sandboxed)
public static void help(Context cx, Scriptable thisObj, java.lang.Object[] args, Function funObj)
public static void gc(Context cx, Scriptable thisObj, java.lang.Object[] args, Function funObj)
public static java.lang.Object print(Context cx, Scriptable thisObj, java.lang.Object[] args, Function funObj)
public static java.lang.Object write(Context cx, Scriptable thisObj, java.lang.Object[] args, Function funObj)
public static void quit(Context cx, Scriptable thisObj, java.lang.Object[] args, Function funObj)
public static double version(Context cx, Scriptable thisObj, java.lang.Object[] args, Function funObj)
public static void load(Context cx, Scriptable thisObj, java.lang.Object[] args, Function funObj)
public static void defineClass(Context cx, Scriptable thisObj, java.lang.Object[] args, Function funObj) throws java.lang.IllegalAccessException, java.lang.InstantiationException, java.lang.reflect.InvocationTargetException
This method is defined as a JavaScript function.
java.lang.IllegalAccessException
- if access is not available
to a reflected class memberjava.lang.InstantiationException
- if unable to instantiate
the named classjava.lang.reflect.InvocationTargetException
- if an exception is thrown
during execution of methods of the named classScriptableObject.defineClass(Scriptable,Class)
public static void loadClass(Context cx, Scriptable thisObj, java.lang.Object[] args, Function funObj) throws java.lang.IllegalAccessException, java.lang.InstantiationException
This method is defined as a JavaScript function. When called as a JavaScript function, a single argument is expected. This argument should be the name of a class that implements the Script interface, as will any script compiled by jsc.
java.lang.IllegalAccessException
- if access is not available
to the classjava.lang.InstantiationException
- if unable to instantiate
the named classpublic static void serialize(Context cx, Scriptable thisObj, java.lang.Object[] args, Function funObj) throws java.io.IOException
java.io.IOException
public static java.lang.Object deserialize(Context cx, Scriptable thisObj, java.lang.Object[] args, Function funObj) throws java.io.IOException, java.lang.ClassNotFoundException
java.io.IOException
java.lang.ClassNotFoundException
public java.lang.String[] getPrompts(Context cx)
public static java.lang.Object doctest(Context cx, Scriptable thisObj, java.lang.Object[] args, Function funObj)
public int runDoctest(Context cx, Scriptable scope, java.lang.String session, java.lang.String sourceName, int lineNumber)
public static java.lang.Object spawn(Context cx, Scriptable thisObj, java.lang.Object[] args, Function funObj)
public static java.lang.Object sync(Context cx, Scriptable thisObj, java.lang.Object[] args, Function funObj)
this
object of
its invocation.
js> var o = { f : sync(function(x) {
print("entry");
Packages.java.lang.Thread.sleep(x*1000);
print("exit");
})};
js> spawn(function() {o.f(5);});
Thread[Thread-0,5,main]
entry
js> spawn(function() {o.f(5);});
Thread[Thread-1,5,main]
js>
exit
entry
exitpublic static java.lang.Object runCommand(Context cx, Scriptable thisObj, java.lang.Object[] args, Function funObj) throws java.io.IOException
Usage:
runCommand(command) runCommand(command, arg1, ..., argN) runCommand(command, arg1, ..., argN, options)All except the last arguments to runCommand are converted to strings and denote command name and its arguments. If the last argument is a JavaScript object, it is an option object. Otherwise it is converted to string denoting the last argument and options objects assumed to be empty. The following properties of the option object are processed:
java.io.IOException
public static void seal(Context cx, Scriptable thisObj, java.lang.Object[] args, Function funObj)
public static java.lang.Object readFile(Context cx, Scriptable thisObj, java.lang.Object[] args, Function funObj) throws java.io.IOException
Usage:
readFile(filePath) readFile(filePath, charCoding)The first form converts file's context to string using the default character coding.
java.io.IOException
public static java.lang.Object readUrl(Context cx, Scriptable thisObj, java.lang.Object[] args, Function funObj) throws java.io.IOException
Usage:
readUrl(url) readUrl(url, charCoding)The first form converts file's context to string using the default charCoding.
java.io.IOException
public static java.lang.Object toint32(Context cx, Scriptable thisObj, java.lang.Object[] args, Function funObj)
public ShellConsole getConsole(java.nio.charset.Charset cs)
public java.io.InputStream getIn()
public void setIn(java.io.InputStream in)
public java.io.PrintStream getOut()
public void setOut(java.io.PrintStream out)
public java.io.PrintStream getErr()
public void setErr(java.io.PrintStream err)
public void setSealedStdLib(boolean value)
public static java.lang.Object readline(Context cx, Scriptable thisObj, java.lang.Object[] args, Function funObj) throws java.io.IOException
Usage:
readline(prompt)
java.io.IOException
Copyright © 2010 - 2020 Adobe. All Rights Reserved