Package org.mozilla.javascript
Class NativeArray
- java.lang.Object
-
- org.mozilla.javascript.ScriptableObject
-
- org.mozilla.javascript.IdScriptableObject
-
- org.mozilla.javascript.NativeArray
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Iterable
,java.util.Collection
,java.util.List
,ConstProperties
,DebuggableObject
,IdFunctionCall
,Scriptable
public class NativeArray extends IdScriptableObject implements java.util.List
This class implements the Array native object.- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.mozilla.javascript.ScriptableObject
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST
-
Fields inherited from interface org.mozilla.javascript.Scriptable
NOT_FOUND
-
-
Constructor Summary
Constructors Constructor Description NativeArray(long lengthArg)
NativeArray(java.lang.Object[] array)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
add(int index, java.lang.Object element)
boolean
add(java.lang.Object o)
boolean
addAll(int index, java.util.Collection c)
boolean
addAll(java.util.Collection c)
void
clear()
boolean
contains(java.lang.Object o)
boolean
containsAll(java.util.Collection c)
void
delete(int index)
Removes the indexed property from the object.java.lang.Object
execIdCall(IdFunctionObject 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)
java.lang.Object
get(int index, Scriptable start)
Returns the value of the indexed property or NOT_FOUND.java.lang.Object
get(long index)
java.lang.Object[]
getAllIds()
Returns an array of ids for the properties of the object.int
getAttributes(int index)
Get the attributes of an indexed property.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.java.lang.Integer[]
getIndexIds()
long
getLength()
boolean
has(int index, Scriptable start)
Returns true if the property index is defined.int
indexOf(java.lang.Object o)
boolean
isEmpty()
java.util.Iterator
iterator()
long
jsGet_length()
Deprecated.UsegetLength()
instead.int
lastIndexOf(java.lang.Object o)
java.util.ListIterator
listIterator()
java.util.ListIterator
listIterator(int start)
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.Object
remove(int index)
boolean
remove(java.lang.Object o)
boolean
removeAll(java.util.Collection c)
boolean
retainAll(java.util.Collection c)
java.lang.Object
set(int index, java.lang.Object element)
int
size()
java.util.List
subList(int fromIndex, int toIndex)
java.lang.Object[]
toArray()
java.lang.Object[]
toArray(java.lang.Object[] a)
-
Methods inherited from class org.mozilla.javascript.IdScriptableObject
activatePrototypeMap, defineOwnProperty, delete, exportAsJSClass, get, getAttributes, has, hasPrototypeMap, initPrototypeConstructor, initPrototypeMethod, initPrototypeValue, setAttributes
-
Methods inherited from class org.mozilla.javascript.ScriptableObject
associateValue, avoidObjectDetection, callMethod, callMethod, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineProperty, defineProperty, defineProperty, defineProperty, deleteProperty, deleteProperty, get, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGetterOrSetter, getObjectPrototype, getParentScope, getProperty, getProperty, getPropertyIds, getPrototype, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, hasInstance, hasProperty, hasProperty, isConst, isExtensible, isSealed, preventExtensions, putConst, putConstProperty, putProperty, putProperty, redefineProperty, sealObject, setAttributes, setAttributes, setAttributes, setExternalArrayData, setGetterOrSetter, setParentScope, setPrototype
-
-
-
-
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
-
execIdCall
public java.lang.Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, java.lang.Object[] args)
Description copied from class:IdScriptableObject
'thisObj' will be null if invoked as constructor, in which case instance of Scriptable should be returned.- Specified by:
execIdCall
in interfaceIdFunctionCall
- Overrides:
execIdCall
in classIdScriptableObject
-
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)
-
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 classIdScriptableObject
- 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)
-
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.- Specified by:
delete
in interfaceScriptable
- Overrides:
delete
in classScriptableObject
- Parameters:
index
- the numeric index for the property- See Also:
Scriptable.get(int, Scriptable)
,ScriptableObject.deleteProperty(Scriptable, int)
-
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.
- Specified by:
getIds
in interfaceScriptable
- Overrides:
getIds
in classScriptableObject
- 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.
-
getAllIds
public java.lang.Object[] getAllIds()
Description copied from class:ScriptableObject
Returns an array of ids for the properties of the object.All properties, even those with attribute DONTENUM, are listed.
- Specified by:
getAllIds
in interfaceDebuggableObject
- Overrides:
getAllIds
in classScriptableObject
- 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.
-
getIndexIds
public java.lang.Integer[] getIndexIds()
-
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".- Specified by:
getDefaultValue
in interfaceScriptable
- Overrides:
getDefaultValue
in classScriptableObject
- Parameters:
hint
- the type hint- Returns:
- the default value for the object See ECMA 8.6.2.6.
-
getAttributes
public int getAttributes(int index)
Description copied from class:ScriptableObject
Get the attributes of an indexed property.- Overrides:
getAttributes
in classScriptableObject
- Parameters:
index
- the numeric index for the property- Returns:
- the bitset of attributes
- See Also:
ScriptableObject.has(String, Scriptable)
,ScriptableObject.READONLY
,ScriptableObject.DONTENUM
,ScriptableObject.PERMANENT
,ScriptableObject.EMPTY
-
getLength
public long getLength()
-
jsGet_length
@Deprecated public long jsGet_length()
Deprecated.UsegetLength()
instead.
-
contains
public boolean contains(java.lang.Object o)
- Specified by:
contains
in interfacejava.util.Collection
- Specified by:
contains
in interfacejava.util.List
-
toArray
public java.lang.Object[] toArray()
- Specified by:
toArray
in interfacejava.util.Collection
- Specified by:
toArray
in interfacejava.util.List
-
toArray
public java.lang.Object[] toArray(java.lang.Object[] a)
- Specified by:
toArray
in interfacejava.util.Collection
- Specified by:
toArray
in interfacejava.util.List
-
containsAll
public boolean containsAll(java.util.Collection c)
- Specified by:
containsAll
in interfacejava.util.Collection
- Specified by:
containsAll
in interfacejava.util.List
-
size
public int size()
- Specified by:
size
in interfacejava.util.Collection
- Specified by:
size
in interfacejava.util.List
- Overrides:
size
in classScriptableObject
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfacejava.util.Collection
- Specified by:
isEmpty
in interfacejava.util.List
- Overrides:
isEmpty
in classScriptableObject
-
get
public java.lang.Object get(long index)
-
get
public java.lang.Object get(int index)
- Specified by:
get
in interfacejava.util.List
-
indexOf
public int indexOf(java.lang.Object o)
- Specified by:
indexOf
in interfacejava.util.List
-
lastIndexOf
public int lastIndexOf(java.lang.Object o)
- Specified by:
lastIndexOf
in interfacejava.util.List
-
iterator
public java.util.Iterator iterator()
- Specified by:
iterator
in interfacejava.util.Collection
- Specified by:
iterator
in interfacejava.lang.Iterable
- Specified by:
iterator
in interfacejava.util.List
-
listIterator
public java.util.ListIterator listIterator()
- Specified by:
listIterator
in interfacejava.util.List
-
listIterator
public java.util.ListIterator listIterator(int start)
- Specified by:
listIterator
in interfacejava.util.List
-
add
public boolean add(java.lang.Object o)
- Specified by:
add
in interfacejava.util.Collection
- Specified by:
add
in interfacejava.util.List
-
remove
public boolean remove(java.lang.Object o)
- Specified by:
remove
in interfacejava.util.Collection
- Specified by:
remove
in interfacejava.util.List
-
addAll
public boolean addAll(java.util.Collection c)
- Specified by:
addAll
in interfacejava.util.Collection
- Specified by:
addAll
in interfacejava.util.List
-
removeAll
public boolean removeAll(java.util.Collection c)
- Specified by:
removeAll
in interfacejava.util.Collection
- Specified by:
removeAll
in interfacejava.util.List
-
retainAll
public boolean retainAll(java.util.Collection c)
- Specified by:
retainAll
in interfacejava.util.Collection
- Specified by:
retainAll
in interfacejava.util.List
-
clear
public void clear()
- Specified by:
clear
in interfacejava.util.Collection
- Specified by:
clear
in interfacejava.util.List
-
add
public void add(int index, java.lang.Object element)
- Specified by:
add
in interfacejava.util.List
-
addAll
public boolean addAll(int index, java.util.Collection c)
- Specified by:
addAll
in interfacejava.util.List
-
set
public java.lang.Object set(int index, java.lang.Object element)
- Specified by:
set
in interfacejava.util.List
-
remove
public java.lang.Object remove(int index)
- Specified by:
remove
in interfacejava.util.List
-
subList
public java.util.List subList(int fromIndex, int toIndex)
- Specified by:
subList
in interfacejava.util.List
-
-