Package org.htmlunit.corejs.javascript
Class ImporterTopLevel
java.lang.Object
org.htmlunit.corejs.javascript.ScriptableObject
org.htmlunit.corejs.javascript.IdScriptableObject
org.htmlunit.corejs.javascript.TopLevel
org.htmlunit.corejs.javascript.ImporterTopLevel
- All Implemented Interfaces:
Serializable
,ConstProperties
,DebuggableObject
,IdFunctionCall
,Scriptable
,SymbolScriptable
- Direct Known Subclasses:
Global
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.
js> importClass(java.io.File) js> f = new File('help.txt') help.txt js> importPackage(java.util) js> v = new Vector() []
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.htmlunit.corejs.javascript.TopLevel
TopLevel.Builtins, TopLevel.NativeErrors
Nested classes/interfaces inherited from class org.htmlunit.corejs.javascript.ScriptableObject
ScriptableObject.KeyComparator
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
private static final int
private static final int
private static final int
private static final Object
private static final int
private static final long
private boolean
Fields inherited from class org.htmlunit.corejs.javascript.ScriptableObject
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST
Fields inherited from interface org.htmlunit.corejs.javascript.Scriptable
NOT_FOUND
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionexecIdCall
(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) 'thisObj' will be null if invoked as constructor, in which case * instance of Scriptable should be returned.protected int
get
(String name, Scriptable start) Returns the value of the named property or NOT_FOUND.Return the name of the class.private static Object[]
getNativeJavaPackages
(Scriptable scope) private Object
getPackageProperty
(String name, Scriptable start) boolean
has
(String name, Scriptable start) Returns true if the named property is defined.private static void
importClass
(Scriptable scope, NativeJavaClass cl) void
importPackage
(Context cx, Scriptable thisObj, Object[] args, Function funObj) Deprecated.Kept only for compatibility.private static void
importPackage
(ScriptableObject scope, NativeJavaPackage pkg) static void
init
(Context cx, Scriptable scope, boolean sealed) protected void
initPrototypeId
(int id) void
initStandardObjects
(Context cx, boolean sealed) private Object
js_construct
(Scriptable scope, Object[] args) private static Object
js_importClass
(Scriptable scope, Object[] args) private static Object
js_importPackage
(ScriptableObject scope, Object[] args) private ScriptableObject
realScope
(Scriptable scope, Scriptable thisObj, IdFunctionObject f) Methods inherited from class org.htmlunit.corejs.javascript.TopLevel
cacheBuiltins, clearCache, getBuiltinCtor, getBuiltinCtor, getBuiltinPrototype, getBuiltinPrototype, getNativeErrorCtor, getNativeErrorCtor
Methods inherited from class org.htmlunit.corejs.javascript.IdScriptableObject
activatePrototypeMap, addIdFunctionProperty, defaultGet, defaultHas, defaultPut, defineOwnProperty, delete, delete, ensureType, exportAsJSClass, fillConstructorProperties, findInstanceIdInfo, findInstanceIdInfo, findPrototypeId, get, getAttributes, getAttributes, getIds, getInstanceIdName, getInstanceIdValue, getMaxInstanceId, getOwnPropertyDescriptor, has, hasPrototypeMap, initPrototypeConstructor, initPrototypeMethod, initPrototypeMethod, initPrototypeMethod, initPrototypeValue, initPrototypeValue, instanceIdInfo, put, put, setAttributes, setInstanceIdAttributes, setInstanceIdValue
Methods inherited from class org.htmlunit.corejs.javascript.ScriptableObject
addLazilyInitializedValue, applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildClassCtor, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, checkValidAttributes, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, deleteProperty, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureSymbolScriptable, equivalentValues, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getBase, getBase, getClassPrototype, getDefaultValue, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, getIds, getObjectPrototype, getParentScope, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, hasInstance, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, putConst, putConstProperty, putImpl, putProperty, putProperty, putProperty, querySlot, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setCommonDescriptorProperties, setExternalArrayData, setGetterOrSetter, setParentScope, setPrototype, size
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
IMPORTER_TAG
-
Id_constructor
private static final int Id_constructor- See Also:
-
Id_importClass
private static final int Id_importClass- See Also:
-
Id_importPackage
private static final int Id_importPackage- See Also:
-
MAX_PROTOTYPE_ID
private static final int MAX_PROTOTYPE_ID- See Also:
-
AKEY
- See Also:
-
topScopeFlag
private boolean topScopeFlag
-
-
Constructor Details
-
ImporterTopLevel
public ImporterTopLevel() -
ImporterTopLevel
-
ImporterTopLevel
-
-
Method Details
-
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 interfaceScriptable
- Overrides:
getClassName
in classTopLevel
-
init
-
initStandardObjects
-
has
Description copied from class:ScriptableObject
Returns true if the named property is defined.- Specified by:
has
in interfaceScriptable
- Overrides:
has
in classIdScriptableObject
- 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 object
- See Also:
-
get
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 interfaceScriptable
- Overrides:
get
in classIdScriptableObject
- 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_FOUND
- See Also:
-
getPackageProperty
-
getNativeJavaPackages
-
importPackage
@Deprecated public void importPackage(Context cx, Scriptable thisObj, Object[] args, Function funObj) Deprecated.Kept only for compatibility. -
js_construct
-
js_importClass
-
js_importPackage
-
importPackage
-
importClass
-
initPrototypeId
protected void initPrototypeId(int id) - Overrides:
initPrototypeId
in classIdScriptableObject
-
execIdCall
public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, 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 interfaceIdFunctionCall
- Overrides:
execIdCall
in classIdScriptableObject
-
realScope
-
findPrototypeId
- Overrides:
findPrototypeId
in classIdScriptableObject
-