| java.lang.Object org.mozilla.javascript.ScriptableObject org.mozilla.javascript.IdScriptableObject org.mozilla.javascript.ImporterTopLevel org.mozilla.javascript.tools.shell.Global
Global | public class Global extends ImporterTopLevel (Code) | | This class provides for sharing functions across multiple threads.
This is of particular interest to server applications.
author: Norris Boyd |
Method Summary | |
public static void | defineClass(Context cx, Scriptable thisObj, Object[] args, Function funObj) Load a Java class that defines a JavaScript object using the
conventions outlined in ScriptableObject.defineClass. | public static Object | deserialize(Context cx, Scriptable thisObj, Object[] args, Function funObj) | public static void | gc(Context cx, Scriptable thisObj, Object[] args, Function funObj) | public PrintStream | getErr() | public InputStream | getIn() | public PrintStream | getOut() | public String[] | getPrompts(Context cx) | public static void | help(Context cx, Scriptable thisObj, Object[] args, Function funObj) Print a help message. | public void | init(ContextFactory factory) | public void | init(Context cx) | public void | initQuitAction(QuitAction quitAction) Set the action to call from quit(). | public boolean | isInitialized() | public static void | load(Context cx, Scriptable thisObj, Object[] args, Function funObj) Load and execute a set of JavaScript source files. | public static void | loadClass(Context cx, Scriptable thisObj, Object[] args, Function funObj) Load and execute a script compiled to a class file.
This method is defined as a JavaScript function.
When called as a JavaScript function, a single argument is
expected. | static void | pipe(boolean fromProcess, InputStream from, OutputStream to) | public static Object | print(Context cx, Scriptable thisObj, Object[] args, Function funObj) Print the string values of its arguments. | public static void | quit(Context cx, Scriptable thisObj, Object[] args, Function funObj) Call embedding-specific quit action passing its argument as
int32 exit code. | public static Object | readFile(Context cx, Scriptable thisObj, 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. | public static Object | readUrl(Context cx, Scriptable thisObj, 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 RuntimeException | reportRuntimeError(String msgId) | static RuntimeException | reportRuntimeError(String msgId, String msgArg) | public static Object | runCommand(Context cx, Scriptable thisObj, 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.
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. | public static void | seal(Context cx, Scriptable thisObj, Object[] args, Function funObj) The seal function seals all supplied arguments. | public static void | serialize(Context cx, Scriptable thisObj, Object[] args, Function funObj) | public void | setErr(PrintStream err) | public void | setIn(InputStream in) | public void | setOut(PrintStream out) | public void | setSealedStdLib(boolean value) | public static Object | spawn(Context cx, Scriptable thisObj, Object[] args, Function funObj) The spawn function runs a given function or script in a different
thread. | public static Object | sync(Context cx, Scriptable thisObj, Object[] args, Function funObj) The sync function creates a synchronized function (in the sense
of a Java synchronized method) from an existing function. | public static Object | toint32(Context cx, Scriptable thisObj, Object[] args, Function funObj) Convert the argumnet to int32 number. | public static double | version(Context cx, Scriptable thisObj, Object[] args, Function funObj) Get and set the language version. |
initialized | boolean initialized(Code) | | |
serialVersionUID | final static long serialVersionUID(Code) | | |
initQuitAction | public void initQuitAction(QuitAction quitAction)(Code) | | Set the action to call from quit().
|
isInitialized | public boolean isInitialized()(Code) | | |
load | public static void load(Context cx, Scriptable thisObj, Object[] args, Function funObj)(Code) | | Load and execute a set of JavaScript source files.
This method is defined as a JavaScript function.
|
print | public static Object print(Context cx, Scriptable thisObj, Object[] args, Function funObj)(Code) | | Print the string values of its arguments.
This method is defined as a JavaScript function.
Note that its arguments are of the "varargs" form, which
allows it to handle an arbitrary number of arguments
supplied to the JavaScript function.
|
quit | public static void quit(Context cx, Scriptable thisObj, Object[] args, Function funObj)(Code) | | Call embedding-specific quit action passing its argument as
int32 exit code.
This method is defined as a JavaScript function.
|
readFile | public static Object readFile(Context cx, Scriptable thisObj, Object[] args, Function funObj) throws IOException(Code) | | 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.
Usage:
readFile(filePath)
readFile(filePath, charCoding)
The first form converts file's context to string using the default
character coding.
|
readUrl | public static Object readUrl(Context cx, Scriptable thisObj, Object[] args, Function funObj) throws IOException(Code) | | 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.
Usage:
readUrl(url)
readUrl(url, charCoding)
The first form converts file's context to string using the default
charCoding.
|
runCommand | public static Object runCommand(Context cx, Scriptable thisObj, Object[] args, Function funObj) throws IOException(Code) | | Execute the specified command with the given argument and options
as a separate process and return the exit status of the process.
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.
Te following properties of the option object are processed:
- args - provides an array of additional command arguments
- env - explicit environment object. All its enumeratable
properties define the corresponding environment variable names.
- input - the process input. If it is not
java.io.InputStream, it is converted to string and sent to the process
as its input. If not specified, no input is provided to the process.
- output - the process output instead of
java.lang.System.out. If it is not instance of java.io.OutputStream,
the process output is read, converted to a string, appended to the
output property value converted to string and put as the new value of
the output property.
- err - the process error output instead of
java.lang.System.err. If it is not instance of java.io.OutputStream,
the process error output is read, converted to a string, appended to
the err property value converted to string and put as the new
value of the err property.
|
setSealedStdLib | public void setSealedStdLib(boolean value)(Code) | | |
spawn | public static Object spawn(Context cx, Scriptable thisObj, Object[] args, Function funObj)(Code) | | The spawn function runs a given function or script in a different
thread.
js> function g() { a = 7; }
js> a = 3;
3
js> spawn(g)
Thread[Thread-1,5,main]
js> a
3
|
sync | public static Object sync(Context cx, Scriptable thisObj, Object[] args, Function funObj)(Code) | | The sync function creates a synchronized function (in the sense
of a Java synchronized method) from an existing function. The
new function synchronizes on the 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
exit
|
version | public static double version(Context cx, Scriptable thisObj, Object[] args, Function funObj)(Code) | | Get and set the language version.
This method is defined as a JavaScript function.
|
Methods inherited from org.mozilla.javascript.ImporterTopLevel | public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args)(Code)(Java Doc) protected int findPrototypeId(String s)(Code)(Java Doc) public Object get(String name, Scriptable start)(Code)(Java Doc) public String getClassName()(Code)(Java Doc) public boolean has(String name, Scriptable start)(Code)(Java Doc) public void importPackage(Context cx, Scriptable thisObj, Object[] args, Function funObj)(Code)(Java Doc) public static void init(Context cx, Scriptable scope, boolean sealed)(Code)(Java Doc) protected void initPrototypeId(int id)(Code)(Java Doc) public void initStandardObjects(Context cx, boolean sealed)(Code)(Java Doc)
|
Methods inherited from org.mozilla.javascript.IdScriptableObject | final public void activatePrototypeMap(int maxPrototypeId)(Code)(Java Doc) protected void addIdFunctionProperty(Scriptable obj, Object tag, int id, String name, int arity)(Code)(Java Doc) final protected Object defaultGet(String name)(Code)(Java Doc) final protected void defaultPut(String name, Object value)(Code)(Java Doc) public void delete(String name)(Code)(Java Doc) public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args)(Code)(Java Doc) final public IdFunctionObject exportAsJSClass(int maxPrototypeId, Scriptable scope, boolean sealed)(Code)(Java Doc) protected void fillConstructorProperties(IdFunctionObject ctor)(Code)(Java Doc) protected int findInstanceIdInfo(String name)(Code)(Java Doc) protected int findPrototypeId(String name)(Code)(Java Doc) public Object get(String name, Scriptable start)(Code)(Java Doc) public int getAttributes(String name)(Code)(Java Doc) protected String getInstanceIdName(int id)(Code)(Java Doc) protected Object getInstanceIdValue(int id)(Code)(Java Doc) protected int getMaxInstanceId()(Code)(Java Doc) public boolean has(String name, Scriptable start)(Code)(Java Doc) final public boolean hasPrototypeMap()(Code)(Java Doc) protected static EcmaError incompatibleCallError(IdFunctionObject f)(Code)(Java Doc) final public void initPrototypeConstructor(IdFunctionObject f)(Code)(Java Doc) protected void initPrototypeId(int id)(Code)(Java Doc) final public void initPrototypeMethod(Object tag, int id, String name, int arity)(Code)(Java Doc) final public void initPrototypeValue(int id, String name, Object value, int attributes)(Code)(Java Doc) protected static int instanceIdInfo(int attributes, int id)(Code)(Java Doc) public void put(String name, Scriptable start, Object value)(Code)(Java Doc) public void setAttributes(String name, int attributes)(Code)(Java Doc) protected void setInstanceIdValue(int id, Object value)(Code)(Java Doc)
|
Methods inherited from org.mozilla.javascript.ScriptableObject | final public Object associateValue(Object key, Object value)(Code)(Java Doc) public boolean avoidObjectDetection()(Code)(Java Doc) public static Object callMethod(Scriptable obj, String methodName, Object[] args)(Code)(Java Doc) public static Object callMethod(Context cx, Scriptable obj, String methodName, Object[] args)(Code)(Java Doc) public static void defineClass(Scriptable scope, Class clazz) throws IllegalAccessException, InstantiationException, InvocationTargetException(Code)(Java Doc) public static void defineClass(Scriptable scope, Class clazz, boolean sealed) throws IllegalAccessException, InstantiationException, InvocationTargetException(Code)(Java Doc) public static String defineClass(Scriptable scope, Class clazz, boolean sealed, boolean mapInheritance) throws IllegalAccessException, InstantiationException, InvocationTargetException(Code)(Java Doc) public void defineConst(String name, Scriptable start)(Code)(Java Doc) public static void defineConstProperty(Scriptable destination, String propertyName)(Code)(Java Doc) public void defineFunctionProperties(String[] names, Class clazz, int attributes)(Code)(Java Doc) public void defineProperty(String propertyName, Object value, int attributes)(Code)(Java Doc) public static void defineProperty(Scriptable destination, String propertyName, Object value, int attributes)(Code)(Java Doc) public void defineProperty(String propertyName, Class clazz, int attributes)(Code)(Java Doc) public void defineProperty(String propertyName, Object delegateTo, Method getter, Method setter, int attributes)(Code)(Java Doc) public void delete(String name)(Code)(Java Doc) public void delete(int index)(Code)(Java Doc) public static boolean deleteProperty(Scriptable obj, String name)(Code)(Java Doc) public static boolean deleteProperty(Scriptable obj, int index)(Code)(Java Doc) protected Object equivalentValues(Object value)(Code)(Java Doc) public Object get(String name, Scriptable start)(Code)(Java Doc) public Object get(int index, Scriptable start)(Code)(Java Doc) public Object[] getAllIds()(Code)(Java Doc) final public Object getAssociatedValue(Object key)(Code)(Java Doc) final public int getAttributes(String name, Scriptable start)(Code)(Java Doc) final public int getAttributes(int index, Scriptable start)(Code)(Java Doc) public int getAttributes(String name)(Code)(Java Doc) public int getAttributes(int index)(Code)(Java Doc) abstract public String getClassName()(Code)(Java Doc) public static Scriptable getClassPrototype(Scriptable scope, String className)(Code)(Java Doc) public Object getDefaultValue(Class typeHint)(Code)(Java Doc) public static Object getDefaultValue(Scriptable object, Class typeHint)(Code)(Java Doc) public static Scriptable getFunctionPrototype(Scriptable scope)(Code)(Java Doc) public Object getGetterOrSetter(String name, int index, boolean isSetter)(Code)(Java Doc) public Object[] getIds()(Code)(Java Doc) public static Scriptable getObjectPrototype(Scriptable scope)(Code)(Java Doc) public Scriptable getParentScope()(Code)(Java Doc) public static Object getProperty(Scriptable obj, String name)(Code)(Java Doc) public static Object getProperty(Scriptable obj, int index)(Code)(Java Doc) public static Object[] getPropertyIds(Scriptable obj)(Code)(Java Doc) public Scriptable getPrototype()(Code)(Java Doc) public static Scriptable getTopLevelScope(Scriptable obj)(Code)(Java Doc) public static Object getTopScopeValue(Scriptable scope, Object key)(Code)(Java Doc) public boolean has(String name, Scriptable start)(Code)(Java Doc) public boolean has(int index, Scriptable start)(Code)(Java Doc) public boolean hasInstance(Scriptable instance)(Code)(Java Doc) public static boolean hasProperty(Scriptable obj, String name)(Code)(Java Doc) public static boolean hasProperty(Scriptable obj, int index)(Code)(Java Doc) public boolean isConst(String name)(Code)(Java Doc) protected boolean isGetterOrSetter(String name, int index, boolean setter)(Code)(Java Doc) final public boolean isSealed()(Code)(Java Doc) public void put(String name, Scriptable start, Object value)(Code)(Java Doc) public void put(int index, Scriptable start, Object value)(Code)(Java Doc) public void putConst(String name, Scriptable start, Object value)(Code)(Java Doc) public static void putConstProperty(Scriptable obj, String name, Object value)(Code)(Java Doc) public static void putProperty(Scriptable obj, String name, Object value)(Code)(Java Doc) public static void putProperty(Scriptable obj, int index, Object value)(Code)(Java Doc) public static void redefineProperty(Scriptable obj, String name, boolean isConst)(Code)(Java Doc) public synchronized void sealObject()(Code)(Java Doc) final public void setAttributes(String name, Scriptable start, int attributes)(Code)(Java Doc) public void setAttributes(int index, Scriptable start, int attributes)(Code)(Java Doc) public void setAttributes(String name, int attributes)(Code)(Java Doc) public void setAttributes(int index, int attributes)(Code)(Java Doc) public void setGetterOrSetter(String name, int index, Callable getterOrSeter, boolean isSetter)(Code)(Java Doc) public void setParentScope(Scriptable m)(Code)(Java Doc) public void setPrototype(Scriptable m)(Code)(Java Doc)
|
|
|