org.mozilla.javascript
Class NativeJavaPackage
java.lang.Object
|
+--org.mozilla.javascript.ScriptableObject
|
+--org.mozilla.javascript.NativeJavaPackage
- All Implemented Interfaces:
- Scriptable, java.io.Serializable
- 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).
- Author:
- Mike Shaver
- See Also:
NativeJavaArray
,
NativeJavaObject
,
NativeJavaClass
, Serialized Form
Method Summary |
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.
|
boolean |
has(java.lang.String id,
int index,
Scriptable start)
|
static Scriptable |
init(Scriptable scope)
|
static Scriptable |
jsFunction_getClass(Context cx,
Scriptable thisObj,
java.lang.Object[] args,
Function funObj)
|
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.
|
java.lang.String |
toString()
|
Methods inherited from class org.mozilla.javascript.ScriptableObject |
callMethod, defineClass, defineClass, defineFunctionProperties, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, deleteProperty, deleteProperty, getAllIds, getAttributes, getAttributes, getClassPrototype, getFunctionPrototype, getIds, getObjectPrototype, getParentScope, getProperty, getProperty, getPropertyIds, getPrototype, getTopLevelScope, has, has, hasInstance, hasProperty, hasProperty, isSealed, putProperty, putProperty, sealObject, setAttributes, setAttributes, setParentScope, setPrototype |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
NativeJavaPackage
public NativeJavaPackage(java.lang.String packageName)
init
public static Scriptable init(Scriptable scope)
throws PropertyException
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
has
public boolean has(java.lang.String id,
int index,
Scriptable start)
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.
- Overrides:
put
in class ScriptableObject
- Following copied from class:
org.mozilla.javascript.ScriptableObject
- Parameters:
name
- the name of the propertystart
- the object whose property is being setvalue
- value to set the property to
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.
- Overrides:
put
in class ScriptableObject
- Following copied from class:
org.mozilla.javascript.ScriptableObject
- Parameters:
index
- the numeric index for the propertystart
- the object whose property is being setvalue
- value to set the property to
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.
- Overrides:
get
in class ScriptableObject
- Following copied from class:
org.mozilla.javascript.ScriptableObject
- 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
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.
- Overrides:
get
in class ScriptableObject
- Following copied from class:
org.mozilla.javascript.ScriptableObject
- 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
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".
- Overrides:
getDefaultValue
in class ScriptableObject
- Following copied from class:
org.mozilla.javascript.ScriptableObject
- Parameters:
typeHint
- the type hint- Returns:
- the default value for the object
See ECMA 8.6.2.6.
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object
jsFunction_getClass
public static Scriptable jsFunction_getClass(Context cx,
Scriptable thisObj,
java.lang.Object[] args,
Function funObj)