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,ConstProperties,DebuggableObject,IdFunctionCall,Scriptable
public class NativeArray extends IdScriptableObject implements 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(Object[] array)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidadd(int index, Object element)booleanadd(Object o)booleanaddAll(int index, Collection c)booleanaddAll(Collection c)voidclear()booleancontains(Object o)booleancontainsAll(Collection c)voiddelete(int index)Removes the indexed property from the object.ObjectexecIdCall(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.Objectget(int index)Objectget(int index, Scriptable start)Returns the value of the indexed property or NOT_FOUND.Objectget(long index)Object[]getAllIds()Returns an array of ids for the properties of the object.intgetAttributes(int index)Get the attributes of an indexed property.StringgetClassName()Return the name of the class.ObjectgetDefaultValue(Class<?> hint)Implements the [[DefaultValue]] internal method.Object[]getIds()Returns an array of ids for the properties of the object.Integer[]getIndexIds()longgetLength()booleanhas(int index, Scriptable start)Returns true if the property index is defined.intindexOf(Object o)booleanisEmpty()Iteratoriterator()longjsGet_length()Deprecated.UsegetLength()instead.intlastIndexOf(Object o)ListIteratorlistIterator()ListIteratorlistIterator(int start)voidput(int index, Scriptable start, Object value)Sets the value of the indexed property, creating it if need be.voidput(String id, Scriptable start, Object value)Sets the value of the named property, creating it if need be.Objectremove(int index)booleanremove(Object o)booleanremoveAll(Collection c)booleanretainAll(Collection c)Objectset(int index, Object element)intsize()ListsubList(int fromIndex, int toIndex)Object[]toArray()Object[]toArray(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
-
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
equals, hashCode, replaceAll, sort, spliterator
-
-
-
-
Constructor Detail
-
NativeArray
public NativeArray(long lengthArg)
-
NativeArray
public NativeArray(Object[] array)
-
-
Method Detail
-
getClassName
public String getClassName()
Description copied from class:ScriptableObjectReturn the name of the class. This is typically the same name as the constructor. Classes extending ScriptableObject must implement this abstract method.- Specified by:
getClassNamein interfaceScriptable- Specified by:
getClassNamein 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:
execIdCallin interfaceIdFunctionCall- Overrides:
execIdCallin classIdScriptableObject
-
get
public Object get(int index, Scriptable start)
Description copied from class:ScriptableObjectReturns the value of the indexed property or NOT_FOUND.- Specified by:
getin interfaceScriptable- Overrides:
getin 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:ScriptableObjectReturns true if the property index is defined.- Specified by:
hasin interfaceScriptable- Overrides:
hasin 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(String id, Scriptable start, Object value)
Description copied from class:ScriptableObjectSets 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:
putin interfaceScriptable- Overrides:
putin 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, Object value)Description copied from class:ScriptableObjectSets the value of the indexed property, creating it if need be.- Specified by:
putin interfaceScriptable- Overrides:
putin 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:ScriptableObjectRemoves the indexed property from the object. If the property is not found, or it has the PERMANENT attribute, no action is taken.- Specified by:
deletein interfaceScriptable- Overrides:
deletein classScriptableObject- Parameters:
index- the numeric index for the property- See Also:
Scriptable.get(int, Scriptable),ScriptableObject.deleteProperty(Scriptable, int)
-
getIds
public Object[] getIds()
Description copied from class:ScriptableObjectReturns an array of ids for the properties of the object.Any properties with the attribute DONTENUM are not listed.
- Specified by:
getIdsin interfaceScriptable- Overrides:
getIdsin 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 Object[] getAllIds()
Description copied from class:ScriptableObjectReturns an array of ids for the properties of the object.All properties, even those with attribute DONTENUM, are listed.
- Specified by:
getAllIdsin interfaceDebuggableObject- Overrides:
getAllIdsin 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 Integer[] getIndexIds()
-
getDefaultValue
public Object getDefaultValue(Class<?> hint)
Description copied from class:ScriptableObjectImplements 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
hintof null means "no hint".- Specified by:
getDefaultValuein interfaceScriptable- Overrides:
getDefaultValuein 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:ScriptableObjectGet the attributes of an indexed property.- Overrides:
getAttributesin 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(Object o)
- Specified by:
containsin interfaceCollection- Specified by:
containsin interfaceList
-
toArray
public Object[] toArray()
- Specified by:
toArrayin interfaceCollection- Specified by:
toArrayin interfaceList
-
toArray
public Object[] toArray(Object[] a)
- Specified by:
toArrayin interfaceCollection- Specified by:
toArrayin interfaceList
-
containsAll
public boolean containsAll(Collection c)
- Specified by:
containsAllin interfaceCollection- Specified by:
containsAllin interfaceList
-
size
public int size()
- Specified by:
sizein interfaceCollection- Specified by:
sizein interfaceList- Overrides:
sizein classScriptableObject
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfaceCollection- Specified by:
isEmptyin interfaceList- Overrides:
isEmptyin classScriptableObject
-
get
public Object get(long index)
-
lastIndexOf
public int lastIndexOf(Object o)
- Specified by:
lastIndexOfin interfaceList
-
iterator
public Iterator iterator()
-
listIterator
public ListIterator listIterator()
- Specified by:
listIteratorin interfaceList
-
listIterator
public ListIterator listIterator(int start)
- Specified by:
listIteratorin interfaceList
-
add
public boolean add(Object o)
- Specified by:
addin interfaceCollection- Specified by:
addin interfaceList
-
remove
public boolean remove(Object o)
- Specified by:
removein interfaceCollection- Specified by:
removein interfaceList
-
addAll
public boolean addAll(Collection c)
- Specified by:
addAllin interfaceCollection- Specified by:
addAllin interfaceList
-
removeAll
public boolean removeAll(Collection c)
- Specified by:
removeAllin interfaceCollection- Specified by:
removeAllin interfaceList
-
retainAll
public boolean retainAll(Collection c)
- Specified by:
retainAllin interfaceCollection- Specified by:
retainAllin interfaceList
-
clear
public void clear()
- Specified by:
clearin interfaceCollection- Specified by:
clearin interfaceList
-
addAll
public boolean addAll(int index, Collection c)
-
-