org.apache.bsf.debug.jsdi
public interface JsObject extends Remote
Host system implementors may find it easier to extend the ScriptableObject class rather than implementing Scriptable when writing host objects.
There are many static methods defined in ScriptableObject that perform the multiple calls to the Scriptable interface needed in order to manipulate properties in prototype chains.
UNKNOWN: Olivier Gruber
Field Summary | |
---|---|
static int | DONTDELETE
Property attribute indicating property cannot be deleted.
|
static int | DONTENUM
Property attribute indicating property is not enumerated.
|
static int | EMPTY
The empty property attribute.
|
static int | INTERNAL
Property attribute indicating property cannot be deleted.
|
static int | READONLY
Property attribute indicating assignment to this property is ignored.
|
Method Summary | |
---|---|
void | define(String propertyName, Object value, int attributes)
The value can be any of the following type:
java.lang.Boolean
java.lang.Number
java.lang.String
org.apache.bsf.debug.jsdi.JsObject |
void | delete(int index)
Removes a property from this object.
|
void | delete(String name)
Removes a property from this object.
|
Object | get(String name)
Get a named property from the object.
|
Object | get(int index) |
String | getClassName()
Get the name of the set of objects implemented by this Java class.
|
Object | getDefaultValue(Class hint)
Get the default value of the object with a given hint.
|
Object[] | getIds(boolean all)
Returns an array of property ids defined on this object.
|
JsObject | getPrototype()
Get the prototype of the object. |
JsObject | getScope()
The scope is for supporting two things.
|
boolean | has(int index)
Indicates whether or not an indexed property is defined in an object.
|
boolean | has(String name)
Indicates whether or not a named property is defined in an object.
|
boolean | hasInstance(JsObject instance)
The instanceof operator.
|
boolean | isFunction() |
boolean | isScript() |
void | put(int index, Object value)
Sets an indexed property in this object.
|
void | put(String name, Object value)
Sets a named property in this object.
|
void | setPrototype(JsObject prototype)
Set the prototype of the object. |
void | setScope(JsObject scope)
Set the prototype of the object. |
See Also: org.mozilla.javascript.ScriptableObject#delete org.mozilla.javascript.ScriptableObject#getAttributes org.mozilla.javascript.ScriptableObject#setAttributes
See Also: org.mozilla.javascript.ScriptableObject#getIds org.mozilla.javascript.ScriptableObject#getAttributes org.mozilla.javascript.ScriptableObject#setAttributes
See Also: org.mozilla.javascript.ScriptableObject#getAttributes org.mozilla.javascript.ScriptableObject#setAttributes
See Also: org.mozilla.javascript.ScriptableObject#delete org.mozilla.javascript.ScriptableObject#getAttributes org.mozilla.javascript.ScriptableObject#setAttributes
See Also: org.mozilla.javascript.ScriptableObject#put org.mozilla.javascript.ScriptableObject#getAttributes org.mozilla.javascript.ScriptableObject#setAttributes
A property can be made permanent by ignoring calls to remove
it.
The property is specified by an integral index
as defined for get
.
To delete properties defined in a prototype chain,
first find the owner object of the property and then
call deleteProperty on that owner object.
Identical to delete(String)
except that
an integral index is used to select the property.
Parameters: index the numeric index for the property
See Also: org.mozilla.javascript.Scriptable#get org.mozilla.javascript.ScriptableObject#deleteProperty
A property can be made permanent by ignoring calls to remove it.
The property is specified by a String name
as defined for get
.
To delete properties defined in a prototype chain, first find the owner object of the property and then call deleteProperty on that owner object.
Parameters: name the identifier for the property
See Also: org.mozilla.javascript.Scriptable#get org.mozilla.javascript.ScriptableObject#deleteProperty
get
that takes an
integer:
JavaScript code | Java code |
---|---|
a.b | a.get("b", a) |
a["foo"] | a.get("foo", a) |
a[3] | a.get(3, a) |
a["3"] | a.get(3, a) |
a[3.0] | a.get(3, a) |
a["3.0"] | a.get("3.0", a) |
a[1.1] | a.get("1.1", a) |
a[-4] | a.get(-4, a) |
The values that may be returned are limited to the following:
Parameters: name the name of the property
Returns: the value of the property (may be null), or NOT_FOUND
See ECMA 8.6.2 and 15.2.4.2.
A hint
of null means "no hint".
See ECMA 8.6.2.6.
Parameters: hint the type hint
Returns: the default value
Returns: an array of all ids from all object in the prototype chain. If a given id occurs multiple times in the prototype chain, it will occur only once in this list. The elements are limited to: - java.lang.String for the property name if it has one. - java.lang.Integer for properties without a name, it is their index.
Since: 1.5R2
Returns: the prototype
The property is specified by an integral index
as defined for the get
method.
Parameters: index the numeric index for the property
Returns: true if and only if the indexed property is found in the object
See Also: org.mozilla.javascript.Scriptable#get org.mozilla.javascript.ScriptableObject#getProperty
The property is specified by a String name
as defined for the get
method.
Parameters: name the name of the property
Returns: true if and only if the named property is found in the object
See Also: org.mozilla.javascript.Scriptable#get org.mozilla.javascript.ScriptableObject#getProperty
The JavaScript code "lhs instanceof rhs" causes rhs.hasInstance(lhs) to be called.
The return value is implementation dependent so that embedded host objects can return an appropriate value. See the JS 1.3 language documentation for more detail.
This operator corresponds to the proposed EMCA [[HasInstance]] operator.
Parameters: instance The value that appeared on the LHS of the instanceof operator
Returns: an implementation dependent value
The property is specified by an integral index
as defined for get
.
Parameters: index the numeric index for the property value value to set the property to
The property is specified by a string name
as defined for get
.
Note that if a property a is defined in the prototype p
of an object o, then evaluating o.a = 23
will cause
set
to be called on the prototype p with
o as the start parameter.
To preserve JavaScript semantics, it is the Scriptable
object's responsibility to modify o.
This design allows properties to be defined in prototypes and implemented in terms of getters and setters of Java values without consuming slots in each instance.
The values that may be set are limited to the following:
IMPORTANT: JAVA OBJECTS. The wrapping is not yet supported.
Parameters: prototype the prototype to set
Parameters: prototype the prototype to set