|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sourceforge.htmlunit.corejs.javascript.ScriptableObject
net.sourceforge.htmlunit.corejs.javascript.IdScriptableObject
net.sourceforge.htmlunit.corejs.javascript.ImporterTopLevel
org.mozilla.javascript.tools.shell.Global
public class Global
This class provides for sharing functions across multiple threads. This is of particular interest to server applications.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface java.util.Map |
|---|
java.util.Map.Entry<K,V> |
| Field Summary |
|---|
| Fields inherited from class net.sourceforge.htmlunit.corejs.javascript.ScriptableObject |
|---|
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST |
| Fields inherited from interface net.sourceforge.htmlunit.corejs.javascript.Scriptable |
|---|
NOT_FOUND |
| Constructor Summary | |
|---|---|
Global()
|
|
Global(net.sourceforge.htmlunit.corejs.javascript.Context cx)
|
|
| Method Summary | |
|---|---|
static void |
defineClass(net.sourceforge.htmlunit.corejs.javascript.Context cx,
net.sourceforge.htmlunit.corejs.javascript.Scriptable thisObj,
java.lang.Object[] args,
net.sourceforge.htmlunit.corejs.javascript.Function funObj)
Load a Java class that defines a JavaScript object using the conventions outlined in ScriptableObject.defineClass. |
static java.lang.Object |
deserialize(net.sourceforge.htmlunit.corejs.javascript.Context cx,
net.sourceforge.htmlunit.corejs.javascript.Scriptable thisObj,
java.lang.Object[] args,
net.sourceforge.htmlunit.corejs.javascript.Function funObj)
|
static java.lang.Object |
doctest(net.sourceforge.htmlunit.corejs.javascript.Context cx,
net.sourceforge.htmlunit.corejs.javascript.Scriptable thisObj,
java.lang.Object[] args,
net.sourceforge.htmlunit.corejs.javascript.Function funObj)
Example: doctest("js> function f() {\n > return 3;\n > }\njs> f();\n3\n"); returns true |
static void |
gc(net.sourceforge.htmlunit.corejs.javascript.Context cx,
net.sourceforge.htmlunit.corejs.javascript.Scriptable thisObj,
java.lang.Object[] args,
net.sourceforge.htmlunit.corejs.javascript.Function funObj)
|
java.io.PrintStream |
getErr()
|
java.io.InputStream |
getIn()
|
java.io.PrintStream |
getOut()
|
java.lang.String[] |
getPrompts(net.sourceforge.htmlunit.corejs.javascript.Context cx)
|
static void |
help(net.sourceforge.htmlunit.corejs.javascript.Context cx,
net.sourceforge.htmlunit.corejs.javascript.Scriptable thisObj,
java.lang.Object[] args,
net.sourceforge.htmlunit.corejs.javascript.Function funObj)
Print a help message. |
void |
init(net.sourceforge.htmlunit.corejs.javascript.Context cx)
|
void |
init(net.sourceforge.htmlunit.corejs.javascript.ContextFactory factory)
|
void |
initQuitAction(QuitAction quitAction)
Set the action to call from quit(). |
boolean |
isInitialized()
|
static void |
load(net.sourceforge.htmlunit.corejs.javascript.Context cx,
net.sourceforge.htmlunit.corejs.javascript.Scriptable thisObj,
java.lang.Object[] args,
net.sourceforge.htmlunit.corejs.javascript.Function funObj)
Load and execute a set of JavaScript source files. |
static void |
loadClass(net.sourceforge.htmlunit.corejs.javascript.Context cx,
net.sourceforge.htmlunit.corejs.javascript.Scriptable thisObj,
java.lang.Object[] args,
net.sourceforge.htmlunit.corejs.javascript.Function funObj)
Load and execute a script compiled to a class file. |
static java.lang.Object |
print(net.sourceforge.htmlunit.corejs.javascript.Context cx,
net.sourceforge.htmlunit.corejs.javascript.Scriptable thisObj,
java.lang.Object[] args,
net.sourceforge.htmlunit.corejs.javascript.Function funObj)
Print the string values of its arguments. |
static void |
quit(net.sourceforge.htmlunit.corejs.javascript.Context cx,
net.sourceforge.htmlunit.corejs.javascript.Scriptable thisObj,
java.lang.Object[] args,
net.sourceforge.htmlunit.corejs.javascript.Function funObj)
Call embedding-specific quit action passing its argument as int32 exit code. |
static java.lang.Object |
readFile(net.sourceforge.htmlunit.corejs.javascript.Context cx,
net.sourceforge.htmlunit.corejs.javascript.Scriptable thisObj,
java.lang.Object[] args,
net.sourceforge.htmlunit.corejs.javascript.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 |
readUrl(net.sourceforge.htmlunit.corejs.javascript.Context cx,
net.sourceforge.htmlunit.corejs.javascript.Scriptable thisObj,
java.lang.Object[] args,
net.sourceforge.htmlunit.corejs.javascript.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(net.sourceforge.htmlunit.corejs.javascript.Context cx,
net.sourceforge.htmlunit.corejs.javascript.Scriptable thisObj,
java.lang.Object[] args,
net.sourceforge.htmlunit.corejs.javascript.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(net.sourceforge.htmlunit.corejs.javascript.Context cx,
net.sourceforge.htmlunit.corejs.javascript.Scriptable scope,
java.lang.String session,
java.lang.String sourceName,
int lineNumber)
|
static void |
seal(net.sourceforge.htmlunit.corejs.javascript.Context cx,
net.sourceforge.htmlunit.corejs.javascript.Scriptable thisObj,
java.lang.Object[] args,
net.sourceforge.htmlunit.corejs.javascript.Function funObj)
The seal function seals all supplied arguments. |
static void |
serialize(net.sourceforge.htmlunit.corejs.javascript.Context cx,
net.sourceforge.htmlunit.corejs.javascript.Scriptable thisObj,
java.lang.Object[] args,
net.sourceforge.htmlunit.corejs.javascript.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(net.sourceforge.htmlunit.corejs.javascript.Context cx,
net.sourceforge.htmlunit.corejs.javascript.Scriptable thisObj,
java.lang.Object[] args,
net.sourceforge.htmlunit.corejs.javascript.Function funObj)
The spawn function runs a given function or script in a different thread. |
static java.lang.Object |
sync(net.sourceforge.htmlunit.corejs.javascript.Context cx,
net.sourceforge.htmlunit.corejs.javascript.Scriptable thisObj,
java.lang.Object[] args,
net.sourceforge.htmlunit.corejs.javascript.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(net.sourceforge.htmlunit.corejs.javascript.Context cx,
net.sourceforge.htmlunit.corejs.javascript.Scriptable thisObj,
java.lang.Object[] args,
net.sourceforge.htmlunit.corejs.javascript.Function funObj)
Convert the argument to int32 number. |
static double |
version(net.sourceforge.htmlunit.corejs.javascript.Context cx,
net.sourceforge.htmlunit.corejs.javascript.Scriptable thisObj,
java.lang.Object[] args,
net.sourceforge.htmlunit.corejs.javascript.Function funObj)
Get and set the language version. |
| Methods inherited from class net.sourceforge.htmlunit.corejs.javascript.ImporterTopLevel |
|---|
execIdCall, findPrototypeId, get, getClassName, has, importPackage, init, initPrototypeId, initStandardObjects |
| Methods inherited from class net.sourceforge.htmlunit.corejs.javascript.IdScriptableObject |
|---|
activatePrototypeMap, addIdFunctionProperty, defaultGet, defaultPut, delete, exportAsJSClass, fillConstructorProperties, findInstanceIdInfo, getAttributes, getInstanceIdName, getInstanceIdValue, getMaxInstanceId, hasPrototypeMap, incompatibleCallError, initPrototypeConstructor, initPrototypeMethod, initPrototypeValue, instanceIdInfo, put, setAttributes, setInstanceIdValue |
| Methods inherited from class net.sourceforge.htmlunit.corejs.javascript.ScriptableObject |
|---|
associateValue, avoidObjectDetection, callMethod, callMethod, clear, containsKey, containsValue, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, entrySet, equivalentValues, get, get, getAllIds, getAssociatedValue, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getDefaultValue, getFunctionPrototype, getGetterOrSetter, getIds, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getPropertyIds, getPrototype, getSlot, getTopLevelScope, getTopScopeValue, getTypeOf, has, hasInstance, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isGenericDescriptor, isGetterOrSetter, isSealed, keySet, preventExtensions, put, put, putAll, putConst, putConstProperty, putProperty, putProperty, redefineProperty, remove, sealObject, setAttributes, setAttributes, setAttributes, setGetterOrSetter, setParentScope, setPrototype, size, values |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.util.Map |
|---|
equals, hashCode |
| Constructor Detail |
|---|
public Global()
public Global(net.sourceforge.htmlunit.corejs.javascript.Context cx)
| Method Detail |
|---|
public boolean isInitialized()
public void initQuitAction(QuitAction quitAction)
public void init(net.sourceforge.htmlunit.corejs.javascript.ContextFactory factory)
public void init(net.sourceforge.htmlunit.corejs.javascript.Context cx)
public static void help(net.sourceforge.htmlunit.corejs.javascript.Context cx,
net.sourceforge.htmlunit.corejs.javascript.Scriptable thisObj,
java.lang.Object[] args,
net.sourceforge.htmlunit.corejs.javascript.Function funObj)
public static void gc(net.sourceforge.htmlunit.corejs.javascript.Context cx,
net.sourceforge.htmlunit.corejs.javascript.Scriptable thisObj,
java.lang.Object[] args,
net.sourceforge.htmlunit.corejs.javascript.Function funObj)
public static java.lang.Object print(net.sourceforge.htmlunit.corejs.javascript.Context cx,
net.sourceforge.htmlunit.corejs.javascript.Scriptable thisObj,
java.lang.Object[] args,
net.sourceforge.htmlunit.corejs.javascript.Function funObj)
public static void quit(net.sourceforge.htmlunit.corejs.javascript.Context cx,
net.sourceforge.htmlunit.corejs.javascript.Scriptable thisObj,
java.lang.Object[] args,
net.sourceforge.htmlunit.corejs.javascript.Function funObj)
public static double version(net.sourceforge.htmlunit.corejs.javascript.Context cx,
net.sourceforge.htmlunit.corejs.javascript.Scriptable thisObj,
java.lang.Object[] args,
net.sourceforge.htmlunit.corejs.javascript.Function funObj)
public static void load(net.sourceforge.htmlunit.corejs.javascript.Context cx,
net.sourceforge.htmlunit.corejs.javascript.Scriptable thisObj,
java.lang.Object[] args,
net.sourceforge.htmlunit.corejs.javascript.Function funObj)
public static void defineClass(net.sourceforge.htmlunit.corejs.javascript.Context cx,
net.sourceforge.htmlunit.corejs.javascript.Scriptable thisObj,
java.lang.Object[] args,
net.sourceforge.htmlunit.corejs.javascript.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 member
java.lang.InstantiationException - if unable to instantiate
the named class
java.lang.reflect.InvocationTargetException - if an exception is thrown
during execution of methods of the named classorg.mozilla.javascript.ScriptableObject#defineClass(Scriptable,Class)
public static void loadClass(net.sourceforge.htmlunit.corejs.javascript.Context cx,
net.sourceforge.htmlunit.corejs.javascript.Scriptable thisObj,
java.lang.Object[] args,
net.sourceforge.htmlunit.corejs.javascript.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 class
java.lang.InstantiationException - if unable to instantiate
the named class
public static void serialize(net.sourceforge.htmlunit.corejs.javascript.Context cx,
net.sourceforge.htmlunit.corejs.javascript.Scriptable thisObj,
java.lang.Object[] args,
net.sourceforge.htmlunit.corejs.javascript.Function funObj)
throws java.io.IOException
java.io.IOException
public static java.lang.Object deserialize(net.sourceforge.htmlunit.corejs.javascript.Context cx,
net.sourceforge.htmlunit.corejs.javascript.Scriptable thisObj,
java.lang.Object[] args,
net.sourceforge.htmlunit.corejs.javascript.Function funObj)
throws java.io.IOException,
java.lang.ClassNotFoundException
java.io.IOException
java.lang.ClassNotFoundExceptionpublic java.lang.String[] getPrompts(net.sourceforge.htmlunit.corejs.javascript.Context cx)
public static java.lang.Object doctest(net.sourceforge.htmlunit.corejs.javascript.Context cx,
net.sourceforge.htmlunit.corejs.javascript.Scriptable thisObj,
java.lang.Object[] args,
net.sourceforge.htmlunit.corejs.javascript.Function funObj)
public int runDoctest(net.sourceforge.htmlunit.corejs.javascript.Context cx,
net.sourceforge.htmlunit.corejs.javascript.Scriptable scope,
java.lang.String session,
java.lang.String sourceName,
int lineNumber)
public static java.lang.Object spawn(net.sourceforge.htmlunit.corejs.javascript.Context cx,
net.sourceforge.htmlunit.corejs.javascript.Scriptable thisObj,
java.lang.Object[] args,
net.sourceforge.htmlunit.corejs.javascript.Function funObj)
public static java.lang.Object sync(net.sourceforge.htmlunit.corejs.javascript.Context cx,
net.sourceforge.htmlunit.corejs.javascript.Scriptable thisObj,
java.lang.Object[] args,
net.sourceforge.htmlunit.corejs.javascript.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
exit
public static java.lang.Object runCommand(net.sourceforge.htmlunit.corejs.javascript.Context cx,
net.sourceforge.htmlunit.corejs.javascript.Scriptable thisObj,
java.lang.Object[] args,
net.sourceforge.htmlunit.corejs.javascript.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(net.sourceforge.htmlunit.corejs.javascript.Context cx,
net.sourceforge.htmlunit.corejs.javascript.Scriptable thisObj,
java.lang.Object[] args,
net.sourceforge.htmlunit.corejs.javascript.Function funObj)
public static java.lang.Object readFile(net.sourceforge.htmlunit.corejs.javascript.Context cx,
net.sourceforge.htmlunit.corejs.javascript.Scriptable thisObj,
java.lang.Object[] args,
net.sourceforge.htmlunit.corejs.javascript.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(net.sourceforge.htmlunit.corejs.javascript.Context cx,
net.sourceforge.htmlunit.corejs.javascript.Scriptable thisObj,
java.lang.Object[] args,
net.sourceforge.htmlunit.corejs.javascript.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(net.sourceforge.htmlunit.corejs.javascript.Context cx,
net.sourceforge.htmlunit.corejs.javascript.Scriptable thisObj,
java.lang.Object[] args,
net.sourceforge.htmlunit.corejs.javascript.Function funObj)
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)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||