org.mozilla.javascript
Class ImporterTopLevel

java.lang.Object
  |
  +--org.mozilla.javascript.ScriptableObject
        |
        +--org.mozilla.javascript.ImporterTopLevel

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 = cx.initStandardObjects(new ImporterTopLevel());
 
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

Fields inherited from class org.mozilla.javascript.ScriptableObject
DONTENUM, EMPTY, parent, PERMANENT, prototype, READONLY
 
Constructor Summary
ImporterTopLevel()
           
 
Method Summary
 java.lang.Object get(java.lang.String name, Scriptable start)
           
 java.lang.String getClassName()
           
 void importClass(java.lang.Object cl)
           
 void importPackage(java.lang.Object pkg)
           
 
Methods inherited from class org.mozilla.javascript.ScriptableObject
defineClass, defineClass, defineFunctionProperties, defineProperty, defineProperty, defineProperty, delete, delete, get, getAllIds, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getFunctionPrototype, getIds, getObjectPrototype, getParentScope, getPrototype, getTopLevelScope, has, has, hasInstance, isSealed, put, put, sealObject, setAttributes, setAttributes, setParentScope, setPrototype
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImporterTopLevel

public ImporterTopLevel()
Method Detail

getClassName

public java.lang.String getClassName()
Overrides:
getClassName in class ScriptableObject

get

public java.lang.Object get(java.lang.String name,
                            Scriptable start)
Overrides:
get in class ScriptableObject

importClass

public void importClass(java.lang.Object cl)

importPackage

public void importPackage(java.lang.Object pkg)