org.mozilla.javascript
Class ImporterTopLevel

java.lang.Object
  |
  +--org.mozilla.javascript.ScriptableObject
        |
        +--org.mozilla.javascript.ImporterTopLevel
All Implemented Interfaces:
org.mozilla.javascript.debug.DebuggableObject, Scriptable, java.io.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
See Also:
Serialized Form

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()
          Deprecated.  
ImporterTopLevel(Context cx)
           
 
Method Summary
 java.lang.Object get(java.lang.String name, Scriptable start)
          Returns the value of the named property or NOT_FOUND.
 java.lang.String getClassName()
          Return the name of the class.
static void importClass(Context cx, Scriptable thisObj, java.lang.Object[] args, Function funObj)
           
static void importPackage(Context cx, Scriptable thisObj, java.lang.Object[] args, Function funObj)
           
 
Methods inherited from class org.mozilla.javascript.ScriptableObject
callMethod, defineClass, defineClass, defineFunctionProperties, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, deleteProperty, deleteProperty, get, getAllIds, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getFunctionPrototype, getIds, getObjectPrototype, getParentScope, getProperty, getProperty, getPropertyIds, getPrototype, getTopLevelScope, has, has, hasInstance, hasProperty, hasProperty, isSealed, put, put, putProperty, putProperty, sealObject, setAttributes, setAttributes, setParentScope, setPrototype
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImporterTopLevel

public ImporterTopLevel()
Deprecated.  


ImporterTopLevel

public ImporterTopLevel(Context cx)
Method Detail

getClassName

public java.lang.String getClassName()
Description copied from class: ScriptableObject
Return the name of the class. This is typically the same name as the constructor. Classes extending ScriptableObject must implement this abstract method.
Overrides:
getClassName in class ScriptableObject

get

public java.lang.Object get(java.lang.String name,
                            Scriptable start)
Description copied from class: ScriptableObject
Returns the value of the named property or NOT_FOUND. If the property was created using defineProperty, the appropriate getter method is called.
Overrides:
get in class ScriptableObject
Following copied from class: org.mozilla.javascript.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

importClass

public static void importClass(Context cx,
                               Scriptable thisObj,
                               java.lang.Object[] args,
                               Function funObj)

importPackage

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