Package org.htmlunit.corejs.javascript
Class NativeJavaPackage
- java.lang.Object
-
- org.htmlunit.corejs.javascript.ScriptableObject
-
- org.htmlunit.corejs.javascript.NativeJavaPackage
-
- All Implemented Interfaces:
java.io.Serializable
,ConstProperties
,DebuggableObject
,Scriptable
,SymbolScriptable
- Direct Known Subclasses:
NativeJavaTopPackage
public class NativeJavaPackage extends ScriptableObject
This class reflects Java packages into the JavaScript environment. We lazily reflect classes and subpackages, and use a caching/sharing system to ensure that members reflected into one JavaPackage appear in all other references to the same package (as with Packages.java.lang and java.lang).- See Also:
NativeJavaArray
,NativeJavaObject
,NativeJavaClass
, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.htmlunit.corejs.javascript.ScriptableObject
ScriptableObject.KeyComparator
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.ClassLoader
classLoader
private java.util.Set<java.lang.String>
negativeCache
private java.lang.String
packageName
private static long
serialVersionUID
-
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 Constructor Description NativeJavaPackage(boolean internalUsage, java.lang.String packageName, java.lang.ClassLoader classLoader)
NativeJavaPackage(java.lang.String packageName)
Deprecated.NativeJavaPackage is an internal class, do not use it directly.NativeJavaPackage(java.lang.String packageName, java.lang.ClassLoader classLoader)
Deprecated.NativeJavaPackage is an internal class, do not use it directly.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
(package private) NativeJavaPackage
forcePackage(java.lang.String name, Scriptable scope)
java.lang.Object
get(int index, Scriptable start)
Returns the value of the indexed property or NOT_FOUND.java.lang.Object
get(java.lang.String id, Scriptable start)
Returns the value of the named property or NOT_FOUND.java.lang.String
getClassName()
Return the name of the class.java.lang.Object
getDefaultValue(java.lang.Class<?> ignored)
Implements the [[DefaultValue]] internal method.(package private) java.lang.Object
getPkgProperty(java.lang.String name, Scriptable start, boolean createPkg)
boolean
has(int index, Scriptable start)
Returns true if the property index is defined.boolean
has(java.lang.String id, Scriptable start)
Returns true if the named property is defined.int
hashCode()
void
put(int index, Scriptable start, java.lang.Object value)
Sets the value of the indexed property, creating it if need be.void
put(java.lang.String id, Scriptable start, java.lang.Object value)
Sets the value of the named property, creating it if need be.private void
readObject(java.io.ObjectInputStream in)
java.lang.String
toString()
-
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, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, delete, deleteProperty, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureSymbolScriptable, equivalentValues, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getAttributes, getBase, getBase, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, getIds, getIds, getObjectPrototype, getOwnPropertyDescriptor, 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, setAttributes, setCommonDescriptorProperties, setExternalArrayData, setGetterOrSetter, setParentScope, setPrototype, size
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
packageName
private java.lang.String packageName
-
classLoader
private transient java.lang.ClassLoader classLoader
-
negativeCache
private java.util.Set<java.lang.String> negativeCache
-
-
Constructor Detail
-
NativeJavaPackage
NativeJavaPackage(boolean internalUsage, java.lang.String packageName, java.lang.ClassLoader classLoader)
-
NativeJavaPackage
@Deprecated public NativeJavaPackage(java.lang.String packageName, java.lang.ClassLoader classLoader)
Deprecated.NativeJavaPackage is an internal class, do not use it directly.
-
NativeJavaPackage
@Deprecated public NativeJavaPackage(java.lang.String packageName)
Deprecated.NativeJavaPackage is an internal class, do not use it directly.
-
-
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 interfaceScriptable
- Specified by:
getClassName
in classScriptableObject
-
has
public boolean has(java.lang.String id, Scriptable start)
Description copied from class:ScriptableObject
Returns true if the named property is defined.- Specified by:
has
in interfaceScriptable
- Overrides:
has
in classScriptableObject
- Parameters:
id
- 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:
Scriptable.get(String, Scriptable)
,ScriptableObject.getProperty(Scriptable, String)
-
has
public boolean has(int index, Scriptable start)
Description copied from class:ScriptableObject
Returns true if the property index is defined.- Specified by:
has
in interfaceScriptable
- Overrides:
has
in classScriptableObject
- Parameters:
index
- the numeric index for the propertystart
- the object in which the lookup began- Returns:
- true if and only if the property was found in the object
- See Also:
Scriptable.get(int, Scriptable)
,ScriptableObject.getProperty(Scriptable, int)
-
put
public void put(java.lang.String id, Scriptable start, java.lang.Object value)
Description copied from class:ScriptableObject
Sets the value of the named property, creating it if need be.If the property was created using defineProperty, the appropriate setter method is called.
If the property's attributes include READONLY, no action is taken. This method will actually set the property in the start object.
- Specified by:
put
in interfaceScriptable
- Overrides:
put
in classScriptableObject
- Parameters:
id
- the name of the propertystart
- the object whose property is being setvalue
- value to set the property to- See Also:
Scriptable.has(String, Scriptable)
,Scriptable.get(String, Scriptable)
,ScriptableObject.putProperty(Scriptable, String, Object)
,Context.toObject(Object, Scriptable)
-
put
public void put(int index, Scriptable start, java.lang.Object value)
Description copied from class:ScriptableObject
Sets the value of the indexed property, creating it if need be.- Specified by:
put
in interfaceScriptable
- Overrides:
put
in classScriptableObject
- Parameters:
index
- the numeric index for the propertystart
- the object whose property is being setvalue
- value to set the property to- See Also:
Scriptable.has(int, Scriptable)
,Scriptable.get(int, Scriptable)
,ScriptableObject.putProperty(Scriptable, int, Object)
,Context.toObject(Object, Scriptable)
-
get
public java.lang.Object get(java.lang.String id, 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 interfaceScriptable
- Overrides:
get
in classScriptableObject
- Parameters:
id
- 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:
Context.getUndefinedValue()
-
get
public java.lang.Object get(int index, Scriptable start)
Description copied from class:ScriptableObject
Returns the value of the indexed property or NOT_FOUND.- Specified by:
get
in interfaceScriptable
- Overrides:
get
in classScriptableObject
- Parameters:
index
- the numeric index for the propertystart
- the object in which the lookup began- Returns:
- the value of the property (may be null), or NOT_FOUND
- See Also:
Scriptable.get(String,Scriptable)
-
forcePackage
NativeJavaPackage forcePackage(java.lang.String name, Scriptable scope)
-
getPkgProperty
java.lang.Object getPkgProperty(java.lang.String name, Scriptable start, boolean createPkg)
-
getDefaultValue
public java.lang.Object getDefaultValue(java.lang.Class<?> ignored)
Description copied from class:ScriptableObject
Implements the [[DefaultValue]] internal method.Note that the toPrimitive conversion is a no-op for every type other than Object, for which [[DefaultValue]] is called. See ECMA 9.1.
A
hint
of null means "no hint".- Specified by:
getDefaultValue
in interfaceScriptable
- Overrides:
getDefaultValue
in classScriptableObject
- Parameters:
ignored
- the type hint- Returns:
- the default value for the object
See ECMA 8.6.2.6.
-
readObject
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException
- Throws:
java.io.IOException
java.lang.ClassNotFoundException
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-