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,SymbolScriptable
This class implements the Array native object.
- Author:
- Norris Boyd, Mike McCabe
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.mozilla.javascript.ScriptableObject
ScriptableObject.KeyComparator -
Field Summary
Fields inherited from class org.mozilla.javascript.ScriptableObject
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONSTFields inherited from interface org.mozilla.javascript.Scriptable
NOT_FOUND -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleanbooleanaddAll(int index, Collection c) booleanaddAll(Collection c) voidclear()booleanbooleanprotected voiddefineOwnProperty(Context cx, Object id, ScriptableObject desc, boolean checkValid) Defines a property on an object.voiddelete(int index) Removes the indexed property from the object.voidRemoves an object like the others, but using a Symbol as the key.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.protected voidprotected intMap name to id of instance property.protected intprotected intget(int index) get(int index, Scriptable start) Returns the value of the indexed property or NOT_FOUND.get(long index) get(Symbol key, Scriptable start) Another version of Get that supports Symbol keyed properties.intgetAttributes(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(boolean nonEnumerable, boolean getSymbols) protected StringgetInstanceIdName(int id) Map id back to property name it defines.protected ObjectgetInstanceIdValue(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 valuelongprotected intGet maximum id findInstanceIdInfo can generate.protected ScriptableObjectgetOwnPropertyDescriptor(Context cx, Object id) booleanhas(int index, Scriptable start) Returns true if the property index is defined.booleanhas(Symbol key, Scriptable start) A version of "has" that supports symbols.intprotected voidinitPrototypeId(int id) booleanisEmpty()iterator()longDeprecated.intlistIterator(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.voidput(Symbol key, Scriptable start, Object value) Implementation of put required by SymbolScriptable objects.remove(int index) booleanbooleanbooleanprotected voidsetInstanceIdAttributes(int id, int attr) Update the attributes of the given instance property.protected voidsetInstanceIdValue(int id, Object value) Set or delete id value.voidSets the prototype of the object.intsize()subList(int fromIndex, int toIndex) Object[]toArray()Object[]Methods inherited from class org.mozilla.javascript.IdScriptableObject
activatePrototypeMap, addIdFunctionProperty, defaultGet, defaultHas, defaultPut, delete, ensureType, ensureType, exportAsJSClass, findInstanceIdInfo, get, getAttributes, getAttributes, has, hasPrototypeMap, initPrototypeConstructor, initPrototypeMethod, initPrototypeMethod, initPrototypeMethod, initPrototypeValue, initPrototypeValue, instanceIdInfo, setAttributesMethods inherited from class org.mozilla.javascript.ScriptableObject
applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureSymbolScriptable, equivalentValues, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, getIds, getObjectPrototype, getParentScope, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, hasInstance, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, putConst, putConstProperty, putProperty, putProperty, putProperty, querySlot, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setCommonDescriptorProperties, setExternalArrayData, setGetterOrSetter, setParentScopeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods 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: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
-
getMaxInstanceId
protected int getMaxInstanceId()Description copied from class:IdScriptableObjectGet maximum id findInstanceIdInfo can generate.- Overrides:
getMaxInstanceIdin classIdScriptableObject
-
setInstanceIdAttributes
protected void setInstanceIdAttributes(int id, int attr) Description copied from class:IdScriptableObjectUpdate the attributes of the given instance property. Classes which want to support changing property attributes via Object.defineProperty must override this method. The default implementation throws InternalError.- Overrides:
setInstanceIdAttributesin classIdScriptableObject- Parameters:
id- the instance property idattr- the new attribute bitset
-
findInstanceIdInfo
Description copied from class:IdScriptableObjectMap name to id of instance property. Should return 0 if not found or the result ofIdScriptableObject.instanceIdInfo(int, int).- Overrides:
findInstanceIdInfoin classIdScriptableObject
-
getInstanceIdName
Description copied from class:IdScriptableObjectMap id back to property name it defines.- Overrides:
getInstanceIdNamein classIdScriptableObject
-
getInstanceIdValue
Description copied from class:IdScriptableObjectGet 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- Overrides:
getInstanceIdValuein classIdScriptableObject
-
setInstanceIdValue
Description copied from class:IdScriptableObjectSet or delete id value. If value == NOT_FOUND , the implementation should make sure that the following getInstanceIdValue return NOT_FOUND.- Overrides:
setInstanceIdValuein classIdScriptableObject
-
fillConstructorProperties
- Overrides:
fillConstructorPropertiesin classIdScriptableObject
-
initPrototypeId
protected void initPrototypeId(int id) - Overrides:
initPrototypeIdin classIdScriptableObject
-
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
-
setPrototype
Description copied from class:ScriptableObjectSets the prototype of the object.- Specified by:
setPrototypein interfaceScriptable- Overrides:
setPrototypein classScriptableObject- Parameters:
p- the prototype to set
-
get
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:
-
has
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:
-
has
Description copied from class:ScriptableObjectA version of "has" that supports symbols.- Specified by:
hasin interfaceSymbolScriptable- Overrides:
hasin classIdScriptableObject
-
get
Description copied from class:ScriptableObjectAnother version of Get that supports Symbol keyed properties.- Specified by:
getin interfaceSymbolScriptable- Overrides:
getin classIdScriptableObject
-
put
Description copied from class:ScriptableObjectImplementation of put required by SymbolScriptable objects.- Specified by:
putin interfaceSymbolScriptable- Overrides:
putin classIdScriptableObject
-
delete
Description copied from class:ScriptableObjectRemoves an object like the others, but using a Symbol as the key.- Specified by:
deletein interfaceSymbolScriptable- Overrides:
deletein classIdScriptableObject
-
put
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:
-
put
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:
-
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:
-
getIds
-
getIndexIds
-
getDefaultValue
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:
-
getOwnPropertyDescriptor
- Overrides:
getOwnPropertyDescriptorin classIdScriptableObject
-
defineOwnProperty
Description copied from class:ScriptableObjectDefines a property on an object.Based on [[DefineOwnProperty]] from 8.12.10 of the spec.
- Overrides:
defineOwnPropertyin classIdScriptableObject- Parameters:
cx- the current Contextid- the name/index of the propertydesc- the new property descriptor, as described in 8.6.1checkValid- whether to perform validity checks
-
getLength
public long getLength() -
jsGet_length
Deprecated.UsegetLength()instead. -
contains
- Specified by:
containsin interfaceCollection- Specified by:
containsin interfaceList
-
toArray
- Specified by:
toArrayin interfaceCollection- Specified by:
toArrayin interfaceList
-
toArray
- Specified by:
toArrayin interfaceCollection- Specified by:
toArrayin interfaceList
-
containsAll
- 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
-
get
-
indexOf
-
lastIndexOf
- Specified by:
lastIndexOfin interfaceList
-
iterator
-
listIterator
- Specified by:
listIteratorin interfaceList
-
listIterator
- Specified by:
listIteratorin interfaceList
-
add
- Specified by:
addin interfaceCollection- Specified by:
addin interfaceList
-
remove
- Specified by:
removein interfaceCollection- Specified by:
removein interfaceList
-
addAll
- Specified by:
addAllin interfaceCollection- Specified by:
addAllin interfaceList
-
removeAll
- Specified by:
removeAllin interfaceCollection- Specified by:
removeAllin interfaceList
-
retainAll
- Specified by:
retainAllin interfaceCollection- Specified by:
retainAllin interfaceList
-
clear
public void clear()- Specified by:
clearin interfaceCollection- Specified by:
clearin interfaceList
-
add
-
addAll
-
set
-
remove
-
subList
-
findPrototypeId
- Overrides:
findPrototypeIdin classIdScriptableObject
-
findPrototypeId
- Overrides:
findPrototypeIdin classIdScriptableObject
-
getLength()instead.