Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
org.mozilla.javascript.ScriptableObject
org.mozilla.javascript.IdScriptableObject
Field Summary |
Fields inherited from class org.mozilla.javascript.ScriptableObject | |
DONTENUM , EMPTY , PERMANENT , READONLY |
Fields inherited from interface org.mozilla.javascript.Scriptable | |
NOT_FOUND |
Constructor Summary | |
|
Method Summary | |
void |
|
protected void |
|
protected Object |
|
protected void |
|
void |
|
Object |
|
IdFunctionObject |
|
protected void | |
protected int |
|
protected int |
|
Object |
|
int |
|
protected String |
|
protected Object |
|
protected int |
|
boolean |
|
boolean | |
protected static EcmaError |
|
void | |
protected void |
|
void |
|
void |
|
protected static int |
|
void |
|
void |
|
protected void |
|
public final void activatePrototypeMap(int maxPrototypeId)
protected void addIdFunctionProperty(Scriptable obj, Object tag, int id, String name, int arity)
protected final Object defaultGet(String name)
protected final void defaultPut(String name, Object value)
public void delete(String name)
Removes a property from this object. This operation corresponds to the ECMA [[Delete]] except that the no result is returned. The runtime will guarantee that this method is called only if the property exists. After this method is called, the runtime will call Scriptable.has to see if the property has been removed in order to determine the boolean result of the delete operator as defined by ECMA 11.4.1. A property can be made permanent by ignoring calls to remove it. The property is specified by a String name as defined forget
. To delete properties defined in a prototype chain, see deleteProperty in ScriptableObject.
- Specified by:
- delete in interface Scriptable
- Overrides:
- delete in interface ScriptableObject
- Parameters:
name
- the identifier for the property
- See Also:
org.mozilla.javascript.Scriptable.get
,org.mozilla.javascript.ScriptableObject.deleteProperty
public Object execIdCall(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.
- Specified by:
- execIdCall in interface IdFunctionCall
public final IdFunctionObject exportAsJSClass(int maxPrototypeId, Scriptable scope, boolean sealed)
protected int findInstanceIdInfo(String name)
Map name to id of instance property. Should return 0 if not found or the result ofinstanceIdInfo(int,int)
.
protected int findPrototypeId(String name)
public Object get(String name, Scriptable start)
Get a named property from the object. Looks property up in this object and returns the associated value if found. Returns NOT_FOUND if not found. Note that this method is not expected to traverse the prototype chain. This is different from the ECMA [[Get]] operation. Depending on the property selector, the runtime will call this method or the form ofget
that takes an integer:The values that may be returned are limited to the following:
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)
- java.lang.Boolean objects
- java.lang.String objects
- java.lang.Number objects
- org.mozilla.javascript.Scriptable objects
- null
- The value returned by Context.getUndefinedValue()
- NOT_FOUND
- Specified by:
- get in interface Scriptable
- Overrides:
- get in interface 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
- See Also:
Context.getUndefinedValue()
public int getAttributes(String name)
- Overrides:
- getAttributes in interface ScriptableObject
protected String getInstanceIdName(int id)
Map id back to property name it defines.
protected Object getInstanceIdValue(int id)
Get id value. If id value is constant, descendant can call cacheIdValue to store value in the permanent cache. Default implementation creates IdFunctionObject instance for given id and cache its value
protected int getMaxInstanceId()
Get maximum id findInstanceIdInfo can generate.
public boolean has(String name, Scriptable start)
Indicates whether or not a named property is defined in an object. Does not traverse the prototype chain. The property is specified by a String name as defined for theget
method.
- Specified by:
- has in interface Scriptable
- Overrides:
- has in interface ScriptableObject
- Parameters:
name
- the name of the propertystart
- the object in which the lookup began
- 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
public final boolean hasPrototypeMap()
protected static EcmaError incompatibleCallError(IdFunctionObject f)
Utility method to construct type error to indicate incompatible call when converting script thisObj to a particular type is not possible. Possible usage would be to have a private function like realThis:private static NativeSomething realThis(Scriptable thisObj, IdFunctionObject f) { if (!(thisObj instanceof NativeSomething)) throw incompatibleCallError(f); return (NativeSomething)thisObj; }Note that although such function can be implemented universally via java.lang.Class.isInstance(), it would be much more slower.
- Parameters:
- Returns:
- Scriptable object suitable for a check by the instanceof operator.
protected void initPrototypeId(int id)
public final void initPrototypeMethod(Object tag, int id, String name, int arity)
public final void initPrototypeValue(int id, String name, Object value, int attributes)
protected static int instanceIdInfo(int attributes, int id)
public void put(String name, Scriptable start, Object value)
Sets a named property in this object. The property is specified by a string name as defined forget
. The possible values that may be passed in are as defined forget
. A class that implements this method may choose to ignore calls to set certain properties, in which case those properties are effectively read-only. For properties defined in a prototype chain, useputProperty
in ScriptableObject. Note that if a property a is defined in the prototype p of an object o, then evaluatingo.a = 23
will causeset
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:Arbitrary Java objects may be wrapped in a Scriptable by first calling
- java.lang.Boolean objects
- java.lang.String objects
- java.lang.Number objects
- org.mozilla.javascript.Scriptable objects
- null
- The value returned by Context.getUndefinedValue()
Context.toObject
. This allows the property of a JavaScript object to contain an arbitrary Java object as a value. Note thathas
will be called by the runtime first beforeset
is called to determine in which object the property is defined. Note that this method is not expected to traverse the prototype chain, which is different from the ECMA [[Put]] operation.
- Specified by:
- put in interface Scriptable
- Overrides:
- put in interface ScriptableObject
- Parameters:
name
- the name of the propertystart
- the object whose property is being setvalue
- value to set the property to
- See Also:
org.mozilla.javascript.Scriptable.has
,org.mozilla.javascript.Scriptable.get
,org.mozilla.javascript.ScriptableObject.putProperty
,org.mozilla.javascript.Context.toObject
public void setAttributes(String name, int attributes)
- Overrides:
- setAttributes in interface ScriptableObject
protected void setInstanceIdValue(int id, Object value)
Set or delete id value. If value == NOT_FOUND , the implementation should make sure that the following getInstanceIdValue return NOT_FOUND.