Class ImporterTopLevel
This class defines a ScriptableObject that can be instantiated
as a top-level ("global") object to provide functionality similar
to Java's "import" statement.
This class can be used to create a top-level scope using the following code:
Scriptable scope = new ImporterTopLevel(cx);
Then JavaScript code will have access to the following methods:
- importClass - will "import" a class by making its unqualified name
available as a property of the top-level scope
- importPackage - will "import" all the classes of the package by
searching for unqualified names as classes qualified
by the given package.
The following code from the shell illustrates this use:
js> importClass(java.io.File)
js> f = new File('help.txt')
help.txt
js> importPackage(java.util)
js> v = new Vector()
[]
String getClassName
public @Override String getClassName()
importPackage
public void importPackage(Context cx,
Scriptable thisObj,
Object[] args,
Function funObj)
Kept only for compatibility.
initStandardObjects
public void initStandardObjects(Context cx,
boolean sealed)
int findPrototypeId
protected @Override int findPrototypeId(String s)
void initPrototypeId
protected @Override void initPrototypeId(int id)