org.mozilla.javascript

Class ImporterTopLevel

Implemented Interfaces:
org.mozilla.javascript.debug.DebuggableObject, Scriptable, Serializable

public class ImporterTopLevel
extends ScriptableObject

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

Nested Class Summary

Field Summary

Fields inherited from class org.mozilla.javascript.ScriptableObject

DONTENUM, EMPTY, PERMANENT, READONLY

Fields inherited from interface org.mozilla.javascript.Scriptable

NOT_FOUND

Constructor Summary

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

Method Summary

Object
get(String name, Scriptable start)
Returns the value of the named property or NOT_FOUND.
String
getClassName()
Return the name of the class.
boolean
has(String name, Scriptable start)
Returns true if the named property is defined.
void
importPackage(Context cx, Scriptable thisObj, Object[] args, Function funObj)
void
initStandardObjects(Context cx, boolean sealed)

Methods inherited from class org.mozilla.javascript.ScriptableObject

associateValue, callMethod, defineClass, defineClass, defineFunctionProperties, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, deleteProperty, deleteProperty, get, get, getAllIds, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getClassName, getClassPrototype, getDefaultValue, getFunctionPrototype, getIds, getObjectPrototype, getParentScope, getProperty, getProperty, getPropertyIds, getPrototype, getTopLevelScope, has, has, hasInstance, hasProperty, hasProperty, isSealed, put, put, putProperty, putProperty, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setParentScope, setPrototype

Constructor Details

ImporterTopLevel

public ImporterTopLevel()


ImporterTopLevel

public ImporterTopLevel(Context cx)


ImporterTopLevel

public ImporterTopLevel(Context cx,
                        boolean sealed)

Method Details

get

public Object get(String name,
                  Scriptable start)
Returns the value of the named property or NOT_FOUND. If the property was created using defineProperty, the appropriate getter method is called.
Specified by:
get in interface Scriptable
Overrides:
get in interface ScriptableObject

Parameters:
name - the name of the property
start - the object in which the lookup began

Returns:
the value of the property (may be null), or NOT_FOUND


getClassName

public String getClassName()
Return the name of the class. This is typically the same name as the constructor. Classes extending ScriptableObject must implement this abstract method.
Specified by:
getClassName in interface Scriptable
Overrides:
getClassName in interface ScriptableObject


has

public boolean has(String name,
                   Scriptable start)
Returns true if the named property is defined.
Specified by:
has in interface Scriptable
Overrides:
has in interface ScriptableObject

Parameters:
name - the name of the property
start - the object in which the lookup began

Returns:
true if and only if the property was found in the object


importPackage

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


initStandardObjects

public void initStandardObjects(Context cx,
                                boolean sealed)