Class ImporterTopLevel

  • All Implemented Interfaces:
    Serializable, ConstProperties, DebuggableObject, IdFunctionCall, Scriptable
    Direct Known Subclasses:

    public class ImporterTopLevel
    extends TopLevel
    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(
     js> f = new File('help.txt')
     js> importPackage(java.util)
     js> v = new Vector()
    See Also:
    Serialized Form