org.mozilla.javascript
Class NativeArray

java.lang.Object
  |
  +--org.mozilla.javascript.ScriptableObject
        |
        +--org.mozilla.javascript.IdScriptable
              |
              +--org.mozilla.javascript.NativeArray
All Implemented Interfaces:
IdFunctionMaster, Scriptable, java.io.Serializable

public class NativeArray
extends IdScriptable

This class implements the Array native object.

Author:
Norris Boyd, Mike McCabe
See Also:
Serialized Form

Fields inherited from class org.mozilla.javascript.ScriptableObject
DONTENUM, EMPTY, PERMANENT, READONLY
 
Fields inherited from interface org.mozilla.javascript.Scriptable
NOT_FOUND
 
Constructor Summary
NativeArray()
          Zero-parameter constructor: just used to create Array.prototype
NativeArray(long length)
           
NativeArray(java.lang.Object[] array)
           
 
Method Summary
 void delete(int index)
          Removes the indexed property from the object.
 java.lang.Object execMethod(int methodId, IdFunction f, Context cx, Scriptable scope, Scriptable thisObj, java.lang.Object[] args)
          'thisObj' will be null if invoked as constructor, in which case instance of Scriptable should be returned.
 java.lang.Object get(int index, Scriptable start)
          Returns the value of the indexed property or NOT_FOUND.
 java.lang.String getClassName()
          Return the name of the class.
 java.lang.Object getDefaultValue(java.lang.Class hint)
          Implements the [[DefaultValue]] internal method.
 java.lang.Object[] getIds()
          Returns an array of ids for the properties of the object.
 boolean has(int index, Scriptable start)
          Returns true if the property index is defined.
static void init(Context cx, Scriptable scope, boolean sealed)
           
 long jsGet_length()
           
 int methodArity(int methodId)
          Get arity or defined argument count for method with given id.
 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.
 
Methods inherited from class org.mozilla.javascript.IdScriptable
addAsPrototype, defineProperty, delete, get, getAttributes, has, setAttributes
 
Methods inherited from class org.mozilla.javascript.ScriptableObject
callMethod, defineClass, defineClass, defineFunctionProperties, defineProperty, defineProperty, defineProperty, deleteProperty, deleteProperty, getAllIds, getAttributes, getClassPrototype, getFunctionPrototype, getObjectPrototype, getParentScope, getProperty, getProperty, getPropertyIds, getPrototype, getTopLevelScope, hasInstance, hasProperty, hasProperty, isSealed, putProperty, putProperty, sealObject, setAttributes, setParentScope, setPrototype
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NativeArray

public NativeArray()
Zero-parameter constructor: just used to create Array.prototype

NativeArray

public NativeArray(long length)

NativeArray

public NativeArray(java.lang.Object[] array)
Method Detail

init

public static void init(Context cx,
                        Scriptable scope,
                        boolean sealed)

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

methodArity

public int methodArity(int methodId)
Description copied from class: IdScriptable
Get arity or defined argument count for method with given id. Should return -1 if methodId is not known or can not be used with execMethod call.
Overrides:
methodArity in class IdScriptable

execMethod

public java.lang.Object execMethod(int methodId,
                                   IdFunction f,
                                   Context cx,
                                   Scriptable scope,
                                   Scriptable thisObj,
                                   java.lang.Object[] args)
                            throws JavaScriptException
Description copied from class: IdScriptable
'thisObj' will be null if invoked as constructor, in which case instance of Scriptable should be returned.
Overrides:
execMethod in class IdScriptable

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 property
start - the object in which the lookup began
Returns:
the value of the property (may be null), or NOT_FOUND

has

public boolean has(int index,
                   Scriptable start)
Description copied from class: ScriptableObject
Returns true if the property index is defined.
Overrides:
has in class ScriptableObject
Following copied from class: org.mozilla.javascript.ScriptableObject
Parameters:
index - the numeric index for the property
start - the object in which the lookup began
Returns:
true if and only if the property was found in the object

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 IdScriptable
Following copied from class: org.mozilla.javascript.ScriptableObject
Parameters:
name - the name of the property
start - the object whose property is being set
value - 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 property
start - the object whose property is being set
value - value to set the property to

delete

public void delete(int index)
Description copied from class: ScriptableObject
Removes the indexed property from the object. If the property is not found, or it has the PERMANENT attribute, no action is taken.
Overrides:
delete in class ScriptableObject
Following copied from class: org.mozilla.javascript.ScriptableObject
Parameters:
index - the numeric index for the property

getIds

public java.lang.Object[] getIds()
Description copied from class: ScriptableObject
Returns an array of ids for the properties of the object.

Any properties with the attribute DONTENUM are not listed.

Overrides:
getIds in class ScriptableObject
Following copied from class: org.mozilla.javascript.ScriptableObject
Returns:
an array of java.lang.Objects with an entry for every listed property. Properties accessed via an integer index will have a corresponding Integer entry in the returned array. Properties accessed by a String will have a String entry in the returned array.

getDefaultValue

public java.lang.Object getDefaultValue(java.lang.Class hint)
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.

jsGet_length

public long jsGet_length()