org.mozilla.javascript

Class ImporterTopLevel

Implemented Interfaces:
ConstProperties, DebuggableObject, IdFunctionCall, Scriptable, Serializable

public class ImporterTopLevel
extends IdScriptableObject

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: 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()
 []
Author:
Norris Boyd

Field Summary

Fields inherited from class org.mozilla.javascript.ScriptableObject

CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST

Fields inherited from interface org.mozilla.javascript.Scriptable

NOT_FOUND

Constructor Summary

ImporterTopLevel()
ImporterTopLevel(Context cx)
ImporterTopLevel(Context cx, boolean sealed)

Method Summary

Object
execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args)
'thisObj' will be null if invoked as constructor, in which case instance of Scriptable should be returned.
protected int
findPrototypeId(String s)
Object
get(String name, Scriptable start)
String
getClassName()
boolean
has(String name, Scriptable start)
void
importPackage(Context cx, Scriptable thisObj, Object[] args, Function funObj)
Deprecated. Kept only for compatibility.
static void
init(Context cx, Scriptable scope, boolean sealed)
protected void
initPrototypeId(int id)
void
initStandardObjects(Context cx, boolean sealed)

Methods inherited from class org.mozilla.javascript.IdScriptableObject

activatePrototypeMap, addIdFunctionProperty, defaultGet, defaultPut, delete, execIdCall, exportAsJSClass, fillConstructorProperties, findInstanceIdInfo, findPrototypeId, get, getAttributes, getInstanceIdName, getInstanceIdValue, getMaxInstanceId, has, hasPrototypeMap, incompatibleCallError, initPrototypeConstructor, initPrototypeId, initPrototypeMethod, initPrototypeValue, instanceIdInfo, put, setAttributes, setInstanceIdValue

Methods inherited from class org.mozilla.javascript.ScriptableObject

associateValue, callMethod, callMethod, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, deleteProperty, deleteProperty, equivalentValues, get, get, getAllIds, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getClassName, getClassPrototype, getDefaultValue, getDefaultValue, getFunctionPrototype, getGetterOrSetter, getIds, getObjectPrototype, getParentScope, getProperty, getProperty, getPropertyIds, getPrototype, getTopLevelScope, getTopScopeValue, has, has, hasInstance, hasProperty, hasProperty, isConst, isSealed, put, put, putConst, putConstProperty, putProperty, putProperty, redefineProperty, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setGetterOrSetter, setParentScope, setPrototype

Constructor Details

ImporterTopLevel

public ImporterTopLevel()

ImporterTopLevel

public ImporterTopLevel(Context cx)

ImporterTopLevel

public ImporterTopLevel(Context cx,
                        boolean sealed)

Method Details

execIdCall

public Object execIdCall(IdFunctionObject f,
                         Context cx,
                         Scriptable scope,
                         Scriptable thisObj,
                         Object[] args)
'thisObj' will be null if invoked as constructor, in which case instance of Scriptable should be returned.
Specified by:
execIdCall in interface IdFunctionCall
Overrides:
execIdCall in interface IdScriptableObject

findPrototypeId

protected int findPrototypeId(String s)
Overrides:
findPrototypeId in interface IdScriptableObject

get

public Object get(String name,
                  Scriptable start)
Specified by:
get in interface Scriptable
Overrides:
get in interface IdScriptableObject

getClassName

public String getClassName()
Specified by:
getClassName in interface Scriptable
Overrides:
getClassName in interface ScriptableObject

has

public boolean has(String name,
                   Scriptable start)
Specified by:
has in interface Scriptable
Overrides:
has in interface IdScriptableObject

importPackage

public void importPackage(Context cx,
                          Scriptable thisObj,
                          Object[] args,
                          Function funObj)

Deprecated. Kept only for compatibility.


init

public static void init(Context cx,
                        Scriptable scope,
                        boolean sealed)

initPrototypeId

protected void initPrototypeId(int id)
Overrides:
initPrototypeId in interface IdScriptableObject

initStandardObjects

public void initStandardObjects(Context cx,
                                boolean sealed)