Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.mozilla.javascript
Class ImporterTopLevel

    java.lang.Object
      org.mozilla.javascript.ScriptableObject
          org.mozilla.javascript.IdScriptableObject
              org.mozilla.javascript.TopLevel
                  org.mozilla.javascript.ImporterTopLevel

All Implemented Interfaces:
  java.io.Serializable, ConstProperties, DebuggableObject, IdFunctionCall, Scriptable

    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(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

    Nested Class Summary

    Nested classes/interfaces inherited from class org.mozilla.javascript.TopLevel

    TopLevel.Builtins

    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

     java.lang.Object
    execIdCall(IdFunctionObject f,
               Context cx,
               Scriptable scope,
               Scriptable thisObj,
               java.lang.Object[] args)

              'thisObj' will be null if invoked as constructor, in which case
     instance of Scriptable should be returned.

    protected  int
    findPrototypeId(java.lang.String s)

     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.

     boolean
    has(java.lang.String name,
        Scriptable start)

              Returns true if the named property is defined.

     void
    importPackage(Context cx,
                  Scriptable thisObj,
                  java.lang.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.TopLevel

    cacheBuiltins, getBuiltinCtor, getBuiltinCtor, getBuiltinPrototype, getBuiltinPrototype

    Methods inherited from class org.mozilla.javascript.IdScriptableObject

    activatePrototypeMap, addIdFunctionProperty, defaultGet, defaultPut, defineOwnProperty, delete, exportAsJSClass, fillConstructorProperties, findInstanceIdInfo, getAttributes, getInstanceIdName, getInstanceIdValue, getMaxInstanceId, getOwnPropertyDescriptor, hasPrototypeMap, incompatibleCallError, initPrototypeConstructor, initPrototypeMethod, initPrototypeValue, instanceIdInfo, put, setAttributes, setInstanceIdValue

    Methods inherited from class org.mozilla.javascript.ScriptableObject

    applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineProperty, defineProperty, defineProperty, defineProperty, delete, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, equivalentValues, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getDefaultValue, getFunctionPrototype, getGetterOrSetter, getIds, getObjectPrototype, getParentScope, getProperty, getProperty, getPropertyIds, getPrototype, getSlot, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, hasInstance, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, putConst, putConstProperty, putProperty, putProperty, redefineProperty, sealObject, setAttributes, setAttributes, setAttributes, setGetterOrSetter, setParentScope, setPrototype, size

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Constructor Detail

    ImporterTopLevel

    public ImporterTopLevel()

    ImporterTopLevel

    public ImporterTopLevel(Context cx)

    ImporterTopLevel

    public ImporterTopLevel(Context cx,
                            boolean sealed)

    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.

    Specified by:getClassName in interface ScriptableOverrides:getClassName in class TopLevel

    init

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

    initStandardObjects

    public void initStandardObjects(Context cx,
                                    boolean sealed)

    has

    public boolean has(java.lang.String name,
                       Scriptable start)

    Description copied from class: ScriptableObject
    Returns true if the named property is defined.

    Specified by:has in interface ScriptableOverrides:has in class IdScriptableObject

    Parameters:name - the name of the propertystart - the object in which the lookup began
    Returns:true if and only if the property was found in the objectSee Also:Scriptable.get(String, Scriptable),
    ScriptableObject.getProperty(Scriptable, String)

    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.

    Specified by:get in interface ScriptableOverrides:get in class IdScriptableObject

    Parameters:name - the name of the propertystart - the object in which the lookup began
    Returns:the value of the property (may be null), or NOT_FOUNDSee Also:Context.getUndefinedValue()

    importPackage

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

    Deprecated. Kept only for compatibility.

    initPrototypeId

    protected void initPrototypeId(int id)

    Overrides:initPrototypeId in class IdScriptableObject

    execIdCall

    public java.lang.Object execIdCall(IdFunctionObject f,
                                       Context cx,
                                       Scriptable scope,
                                       Scriptable thisObj,
                                       java.lang.Object[] args)

    Description copied from class: IdScriptableObject
    'thisObj' will be null if invoked as constructor, in which case
     instance of Scriptable should be returned.

    Specified by:execIdCall in interface IdFunctionCallOverrides:execIdCall in class IdScriptableObject

    findPrototypeId

    protected int findPrototypeId(java.lang.String s)

    Overrides:findPrototypeId in class IdScriptableObject

          Overview
          Package
        Class
          Tree
          Deprecated
          Index
          Help

     PREV CLASS
     NEXT CLASS

      FRAMES
     NO FRAMES

      SUMMARY: NESTED | FIELD | CONSTR | METHOD

    DETAIL: FIELD | CONSTR | METHOD