Class NativeTypedArrayView<T>
java.lang.Object
org.mozilla.javascript.ScriptableObject
org.mozilla.javascript.IdScriptableObject
org.mozilla.javascript.typedarrays.NativeArrayBufferView
org.mozilla.javascript.typedarrays.NativeTypedArrayView<T>
- All Implemented Interfaces:
Serializable
,Iterable<T>
,Collection<T>
,List<T>
,RandomAccess
,SequencedCollection<T>
,ConstProperties
,DebuggableObject
,ExternalArrayData
,IdFunctionCall
,Scriptable
,SymbolScriptable
- Direct Known Subclasses:
NativeFloat32Array
,NativeFloat64Array
,NativeInt16Array
,NativeInt32Array
,NativeInt8Array
,NativeUint16Array
,NativeUint32Array
,NativeUint8Array
,NativeUint8ClampedArray
public abstract class NativeTypedArrayView<T>
extends NativeArrayBufferView
implements List<T>, RandomAccess, ExternalArrayData
This class is the abstract parent for all of the various typed arrays. Each one shows a view of a
specific NativeArrayBuffer, and modifications here will affect the rest.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.mozilla.javascript.ScriptableObject
ScriptableObject.KeyComparator
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final int
The length, in elements, of the arrayprotected static final int
Fields inherited from class org.mozilla.javascript.typedarrays.NativeArrayBufferView
arrayBuffer, byteLength, offset
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
ConstructorsModifierConstructorDescriptionprotected
protected
NativeTypedArrayView
(NativeArrayBuffer ab, int off, int len, int byteLen) -
Method Summary
Modifier and TypeMethodDescriptionvoid
boolean
boolean
addAll
(int i, Collection<? extends T> bytes) boolean
addAll
(Collection<? extends T> bytes) protected boolean
checkIndex
(int index) void
clear()
protected abstract NativeTypedArrayView
<T> construct
(NativeArrayBuffer ab, int off, int len) boolean
boolean
containsAll
(Collection<?> objects) void
delete
(int index) Removes the indexed property from the object.boolean
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 void
protected int
Map name to id of instance property.protected int
protected int
get
(int index, Scriptable start) Returns the value of the indexed property or NOT_FOUND.getArrayElement
(int index) Return the element at the specified index.int
Return the length of the array.abstract int
Return the number of bytes represented by each element in the array.Object[]
getIds()
Returns an array of ids for the properties of the object.protected String
getInstanceIdName
(int id) Map id back to property name it defines.protected Object
getInstanceIdValue
(int id) Get id value.protected int
Get maximum id findInstanceIdInfo can generate.boolean
has
(int index, Scriptable start) Returns true if the property index is defined.int
hashCode()
int
protected void
initPrototypeId
(int id) boolean
isEmpty()
iterator()
protected abstract Object
js_get
(int index) protected abstract Object
int
listIterator
(int start) void
put
(int index, Scriptable start, Object val) Sets the value of the indexed property, creating it if need be.protected abstract NativeTypedArrayView
<T> realThis
(Scriptable thisObj, IdFunctionObject f) remove
(int i) boolean
boolean
removeAll
(Collection<?> objects) boolean
retainAll
(Collection<?> objects) void
setArrayElement
(int index, Object value) Set the element at the specified index.int
size()
subList
(int i, int i2) Object[]
toArray()
<U> U[]
toArray
(U[] ts) Methods inherited from class org.mozilla.javascript.typedarrays.NativeArrayBufferView
getBuffer, getByteLength, getByteOffset, isArg, useLittleEndian
Methods inherited from class org.mozilla.javascript.IdScriptableObject
activatePrototypeMap, addIdFunctionProperty, defaultGet, defaultHas, defaultPut, defineOwnProperty, delete, delete, ensureType, exportAsJSClass, findInstanceIdInfo, get, get, getAttributes, getAttributes, getOwnPropertyDescriptor, has, has, hasPrototypeMap, initPrototypeConstructor, initPrototypeMethod, initPrototypeMethod, initPrototypeMethod, initPrototypeValue, initPrototypeValue, instanceIdInfo, put, put, setAttributes, setInstanceIdAttributes, setInstanceIdValue
Methods 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, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureSymbolScriptable, equivalentValues, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getClassName, getClassPrototype, getDefaultValue, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, 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, setParentScope, setPrototype
Methods inherited from class java.lang.Object
clone, finalize, getClass, 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, get, getFirst, getLast, removeFirst, removeLast, replaceAll, reversed, set, sort, spliterator
-
Field Details
-
length
protected final int lengthThe length, in elements, of the array -
MAX_PROTOTYPE_ID
protected static final int MAX_PROTOTYPE_ID- See Also:
-
-
Constructor Details
-
NativeTypedArrayView
protected NativeTypedArrayView() -
NativeTypedArrayView
-
-
Method Details
-
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 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 setval
- 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.
-
checkIndex
protected boolean checkIndex(int index) -
getBytesPerElement
public abstract int getBytesPerElement()Return the number of bytes represented by each element in the array. This can be useful when wishing to manipulate the byte array directly from Java. -
construct
-
js_get
-
js_set
-
realThis
-
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
-
initPrototypeId
protected void initPrototypeId(int id) - Overrides:
initPrototypeId
in classIdScriptableObject
-
findPrototypeId
- Overrides:
findPrototypeId
in classIdScriptableObject
-
findPrototypeId
- Overrides:
findPrototypeId
in classIdScriptableObject
-
fillConstructorProperties
- Overrides:
fillConstructorProperties
in classIdScriptableObject
-
getMaxInstanceId
protected int getMaxInstanceId()Description copied from class:IdScriptableObject
Get maximum id findInstanceIdInfo can generate.- Overrides:
getMaxInstanceId
in classNativeArrayBufferView
-
getInstanceIdName
Description copied from class:IdScriptableObject
Map id back to property name it defines.- Overrides:
getInstanceIdName
in classNativeArrayBufferView
-
getInstanceIdValue
Description copied from class:IdScriptableObject
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 value- Overrides:
getInstanceIdValue
in classNativeArrayBufferView
-
findInstanceIdInfo
Description copied from class:IdScriptableObject
Map name to id of instance property. Should return 0 if not found or the result ofIdScriptableObject.instanceIdInfo(int, int)
.- Overrides:
findInstanceIdInfo
in classNativeArrayBufferView
-
getArrayElement
Description copied from interface:ExternalArrayData
Return the element at the specified index. The result must be a type that is valid in JavaScript: Number, String, or Scriptable. This method will not be called unless "index" is in range.- Specified by:
getArrayElement
in interfaceExternalArrayData
-
setArrayElement
Description copied from interface:ExternalArrayData
Set the element at the specified index. This method will not be called unless "index" is in range. The method must check that "value" is a valid type, and convert it if necessary.- Specified by:
setArrayElement
in interfaceExternalArrayData
-
getArrayLength
public int getArrayLength()Description copied from interface:ExternalArrayData
Return the length of the array.- Specified by:
getArrayLength
in interfaceExternalArrayData
-
containsAll
- Specified by:
containsAll
in interfaceCollection<T>
- Specified by:
containsAll
in interfaceList<T>
-
indexOf
-
lastIndexOf
- Specified by:
lastIndexOf
in interfaceList<T>
-
toArray
-
toArray
public <U> U[] toArray(U[] ts) -
size
public int size()- Specified by:
size
in interfaceCollection<T>
- Specified by:
size
in interfaceList<T>
- Overrides:
size
in classScriptableObject
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceCollection<T>
- Specified by:
isEmpty
in interfaceList<T>
- Overrides:
isEmpty
in classScriptableObject
-
contains
-
equals
-
hashCode
public int hashCode() -
iterator
-
listIterator
- Specified by:
listIterator
in interfaceList<T>
-
listIterator
- Specified by:
listIterator
in interfaceList<T>
-
subList
-
add
-
add
-
addAll
-
addAll
-
clear
public void clear() -
remove
-
remove
-
removeAll
-
retainAll
-