Package org.mozilla.javascript
Class NativeArray
java.lang.Object
org.mozilla.javascript.ScriptableObject
org.mozilla.javascript.IdScriptableObject
org.mozilla.javascript.NativeArray
- All Implemented Interfaces:
Serializable
,Iterable
,Collection
,List
,SequencedCollection
,ConstProperties
,DebuggableObject
,IdFunctionCall
,Scriptable
This class implements the Array native object.
- See Also:
-
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 -
Method Summary
Modifier and TypeMethodDescriptionvoid
boolean
boolean
addAll
(int index, Collection c) boolean
addAll
(Collection c) void
clear()
boolean
boolean
void
delete
(int index) Removes the indexed property from the 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.get
(int index) get
(int index, Scriptable start) Returns the value of the indexed property or NOT_FOUND.get
(long index) Object[]
Returns an array of ids for the properties of the object.int
getAttributes
(int index) Get the attributes of an indexed property.Return the name of the class.getDefaultValue
(Class<?> hint) Implements the [[DefaultValue]] internal method.Object[]
getIds()
Returns an array of ids for the properties of the object.Integer[]
long
boolean
has
(int index, Scriptable start) Returns true if the property index is defined.int
boolean
isEmpty()
iterator()
long
Deprecated.int
listIterator
(int start) void
put
(int index, Scriptable start, Object value) Sets the value of the indexed property, creating it if need be.void
put
(String id, Scriptable start, Object value) Sets the value of the named property, creating it if need be.remove
(int index) boolean
boolean
boolean
int
size()
subList
(int fromIndex, int toIndex) Object[]
toArray()
Object[]
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
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.List
addFirst, addLast, equals, getFirst, getLast, hashCode, removeFirst, removeLast, replaceAll, reversed, sort, spliterator
-
Constructor Details
-
NativeArray
public NativeArray(long lengthArg) -
NativeArray
-
-
Method Details
-
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 Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, 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
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:
-
has
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:
-
put
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:
-
put
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:
-
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:
-
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
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
-
getDefaultValue
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:
-
getLength
public long getLength() -
jsGet_length
Deprecated.UsegetLength()
instead. -
contains
- Specified by:
contains
in interfaceCollection
- Specified by:
contains
in interfaceList
-
toArray
- Specified by:
toArray
in interfaceCollection
- Specified by:
toArray
in interfaceList
-
toArray
- Specified by:
toArray
in interfaceCollection
- Specified by:
toArray
in interfaceList
-
containsAll
- Specified by:
containsAll
in interfaceCollection
- Specified by:
containsAll
in interfaceList
-
size
public int size()- Specified by:
size
in interfaceCollection
- Specified by:
size
in interfaceList
- Overrides:
size
in classScriptableObject
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceCollection
- Specified by:
isEmpty
in interfaceList
- Overrides:
isEmpty
in classScriptableObject
-
get
-
get
-
indexOf
-
lastIndexOf
- Specified by:
lastIndexOf
in interfaceList
-
iterator
-
listIterator
- Specified by:
listIterator
in interfaceList
-
listIterator
- Specified by:
listIterator
in interfaceList
-
add
- Specified by:
add
in interfaceCollection
- Specified by:
add
in interfaceList
-
remove
- Specified by:
remove
in interfaceCollection
- Specified by:
remove
in interfaceList
-
addAll
- Specified by:
addAll
in interfaceCollection
- Specified by:
addAll
in interfaceList
-
removeAll
- Specified by:
removeAll
in interfaceCollection
- Specified by:
removeAll
in interfaceList
-
retainAll
- Specified by:
retainAll
in interfaceCollection
- Specified by:
retainAll
in interfaceList
-
clear
public void clear()- Specified by:
clear
in interfaceCollection
- Specified by:
clear
in interfaceList
-
add
-
addAll
-
set
-
remove
-
subList
-
getLength()
instead.