Package org.mozilla.javascript.typedarrays

## 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:
    `java.io.Serializable`, `java.lang.Iterable<T>`, `java.util.Collection<T>`, `java.util.List<T>`, `java.util.RandomAccess`, `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 java.util.List<T>, java.util.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:
    Serialized Form

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.mozilla.javascript.ScriptableObject

      `ScriptableObject.KeyComparator`

  - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected int` | `length` | The length, in elements, of the array
    `protected static int` | `MAX_PROTOTYPE_ID` |

    - ### 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

    Constructors
    Modifier | Constructor | Description
    --- | --- | ---
    `protected` | `NativeTypedArrayView()` |
    `protected` | `NativeTypedArrayView​(NativeArrayBuffer ab, int off, int len, int byteLen)` |

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `add​(int i, T aByte)` |
    `boolean` | `add​(T aByte)` |
    `boolean` | `addAll​(int i, java.util.Collection<? extends T> bytes)` |
    `boolean` | `addAll​(java.util.Collection<? extends T> bytes)` |
    `protected boolean` | `checkIndex​(int index)` |
    `void` | `clear()` |
    `protected abstract NativeTypedArrayView` | `construct​(NativeArrayBuffer ab, int off, int len)` |
    `boolean` | `contains​(java.lang.Object o)` |
    `boolean` | `containsAll​(java.util.Collection<?> objects)` |
    `void` | `delete​(int index)` | Removes the indexed property from the object.
    `boolean` | `equals​(java.lang.Object o)` |
    `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.
    `protected void` | `fillConstructorProperties​(IdFunctionObject ctor)` |
    `protected int` | `findInstanceIdInfo​(java.lang.String s)` | Map name to id of instance property.
    `protected int` | `findPrototypeId​(java.lang.String s)` |
    `protected int` | `findPrototypeId​(Symbol k)` |
    `java.lang.Object` | `get​(int index, Scriptable start)` | Returns the value of the indexed property or NOT_FOUND.
    `java.lang.Object` | `getArrayElement​(int index)` | Return the element at the specified index.
    `int` | `getArrayLength()` | Return the length of the array.
    `abstract int` | `getBytesPerElement()` | Return the number of bytes represented by each element in the array.
    `java.lang.Object[]` | `getIds()` | Returns an array of ids for the properties of the object.
    `protected java.lang.String` | `getInstanceIdName​(int id)` | Map id back to property name it defines.
    `protected java.lang.Object` | `getInstanceIdValue​(int id)` | Get id value.
    `protected int` | `getMaxInstanceId()` | Get maximum id findInstanceIdInfo can generate.
    `boolean` | `has​(int index, Scriptable start)` | Returns true if the property index is defined.
    `int` | `hashCode()` |
    `int` | `indexOf​(java.lang.Object o)` |
    `protected void` | `initPrototypeId​(int id)` |
    `boolean` | `isEmpty()` |
    `java.util.Iterator<T>` | `iterator()` |
    `protected abstract java.lang.Object` | `js_get​(int index)` |
    `protected abstract java.lang.Object` | `js_set​(int index, java.lang.Object c)` |
    `int` | `lastIndexOf​(java.lang.Object o)` |
    `java.util.ListIterator<T>` | `listIterator()` |
    `java.util.ListIterator<T>` | `listIterator​(int start)` |
    `void` | `put​(int index, Scriptable start, java.lang.Object val)` | Sets the value of the indexed property, creating it if need be.
    `protected abstract NativeTypedArrayView` | `realThis​(Scriptable thisObj, IdFunctionObject f)` |
    `T` | `remove​(int i)` |
    `boolean` | `remove​(java.lang.Object o)` |
    `boolean` | `removeAll​(java.util.Collection<?> objects)` |
    `boolean` | `retainAll​(java.util.Collection<?> objects)` |
    `void` | `setArrayElement​(int index, java.lang.Object value)` | Set the element at the specified index.
    `int` | `size()` |
    `java.util.List<T>` | `subList​(int i, int i2)` |
    `java.lang.Object[]` | `toArray()` |
    `<U> U[]` | `toArray​(U[] ts)` |

    - ### Methods inherited from class org.mozilla.javascript.typedarrays.NativeArrayBufferView

      `getBuffer, getByteLength, getByteOffset, isArg`

    - ### Methods inherited from class org.mozilla.javascript.IdScriptableObject

      `activatePrototypeMap, addIdFunctionProperty, defaultGet, defaultHas, defaultPut, defineOwnProperty, delete, delete, exportAsJSClass, findInstanceIdInfo, get, get, getAttributes, getOwnPropertyDescriptor, has, has, hasPrototypeMap, incompatibleCallError, 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, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureSymbolScriptable, equivalentValues, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getClassName, getClassPrototype, getDefaultValue, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGetterOrSetter, getObjectPrototype, getParentScope, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getSlot, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, hasInstance, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, putConst, putConstProperty, putProperty, putProperty, putProperty, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, 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.lang.Iterable

      `forEach`

    - ### Methods inherited from interface java.util.List

      `get, replaceAll, set, sort, spliterator`

- - ### Field Detail

    - #### length

          protected final int length

      The length, in elements, of the array

    - #### MAX_PROTOTYPE_ID

          protected static final int MAX_PROTOTYPE_ID

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### NativeTypedArrayView

          protected NativeTypedArrayView()

    - #### NativeTypedArrayView

          protected NativeTypedArrayView​(NativeArrayBuffer ab,
                                         int off,
                                         int len,
                                         int byteLen)

  - ### Method Detail

    - #### 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 interface `Scriptable`
      Overrides:
        `get` in class `ScriptableObject`
      Parameters:
        `index` - the numeric index for the property
        `start` - 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 interface `Scriptable`
      Overrides:
        `has` in class `ScriptableObject`
      Parameters:
        `index` - the numeric index for the property
        `start` - 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​(int index,
                          Scriptable start,
                          java.lang.Object val)

      Description copied from class: `ScriptableObject`
      Sets the value of the indexed property, creating it if need be.
      Specified by:
        `put` in interface `Scriptable`
      Overrides:
        `put` in class `ScriptableObject`
      Parameters:
        `index` - the numeric index for the property
        `start` - the object whose property is being set
        `val` - 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 interface `Scriptable`
      Overrides:
        `delete` in class `ScriptableObject`
      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 interface `Scriptable`
      Overrides:
        `getIds` in class `ScriptableObject`
      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

          protected abstract NativeTypedArrayView construct​(NativeArrayBuffer ab,
                                                            int off,
                                                            int len)

    - #### js_get

          protected abstract java.lang.Object js_get​(int index)

    - #### js_set

          protected abstract java.lang.Object js_set​(int index,
                                                     java.lang.Object c)

    - #### realThis

          protected abstract NativeTypedArrayView realThis​(Scriptable thisObj,
                                                           IdFunctionObject f)

    - #### 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 interface `IdFunctionCall`
      Overrides:
        `execIdCall` in class `IdScriptableObject`

    - #### initPrototypeId

          protected void initPrototypeId​(int id)

      Overrides:
        `initPrototypeId` in class `IdScriptableObject`

    - #### findPrototypeId

          protected int findPrototypeId​(Symbol k)

      Overrides:
        `findPrototypeId` in class `IdScriptableObject`

    - #### findPrototypeId

          protected int findPrototypeId​(java.lang.String s)

      Overrides:
        `findPrototypeId` in class `IdScriptableObject`

    - #### fillConstructorProperties

          protected void fillConstructorProperties​(IdFunctionObject ctor)

      Overrides:
        `fillConstructorProperties` in class `IdScriptableObject`

    - #### getMaxInstanceId

          protected int getMaxInstanceId()

      Description copied from class: `IdScriptableObject`
      Get maximum id findInstanceIdInfo can generate.
      Overrides:
        `getMaxInstanceId` in class `NativeArrayBufferView`

    - #### getInstanceIdName

          protected java.lang.String getInstanceIdName​(int id)

      Description copied from class: `IdScriptableObject`
      Map id back to property name it defines.
      Overrides:
        `getInstanceIdName` in class `NativeArrayBufferView`

    - #### getInstanceIdValue

          protected java.lang.Object getInstanceIdValue​(int id)

      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 class `NativeArrayBufferView`

    - #### findInstanceIdInfo

          protected int findInstanceIdInfo​(java.lang.String s)

      Description copied from class: `IdScriptableObject`
      Map name to id of instance property. Should return 0 if not found or the result of `IdScriptableObject.instanceIdInfo(int, int)`.
      Overrides:
        `findInstanceIdInfo` in class `NativeArrayBufferView`

    - #### getArrayElement

          public java.lang.Object getArrayElement​(int index)

      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 interface `ExternalArrayData`

    - #### setArrayElement

          public void setArrayElement​(int index,
                                      java.lang.Object value)

      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 interface `ExternalArrayData`

    - #### getArrayLength

          public int getArrayLength()

      Description copied from interface: `ExternalArrayData`
      Return the length of the array.
      Specified by:
        `getArrayLength` in interface `ExternalArrayData`

    - #### size

          public int size()

      Specified by:
        `size` in interface `java.util.Collection<T>`
      Specified by:
        `size` in interface `java.util.List<T>`
      Overrides:
        `size` in class `ScriptableObject`

    - #### isEmpty

          public boolean isEmpty()

      Specified by:
        `isEmpty` in interface `java.util.Collection<T>`
      Specified by:
        `isEmpty` in interface `java.util.List<T>`
      Overrides:
        `isEmpty` in class `ScriptableObject`

    - #### contains

          public boolean contains​(java.lang.Object o)

      Specified by:
        `contains` in interface `java.util.Collection<T>`
      Specified by:
        `contains` in interface `java.util.List<T>`

    - #### containsAll

          public boolean containsAll​(java.util.Collection<?> objects)

      Specified by:
        `containsAll` in interface `java.util.Collection<T>`
      Specified by:
        `containsAll` in interface `java.util.List<T>`

    - #### indexOf

          public int indexOf​(java.lang.Object o)

      Specified by:
        `indexOf` in interface `java.util.List<T>`

    - #### lastIndexOf

          public int lastIndexOf​(java.lang.Object o)

      Specified by:
        `lastIndexOf` in interface `java.util.List<T>`

    - #### toArray

          public java.lang.Object[] toArray()

      Specified by:
        `toArray` in interface `java.util.Collection<T>`
      Specified by:
        `toArray` in interface `java.util.List<T>`

    - #### toArray

          public <U> U[] toArray​(U[] ts)

      Specified by:
        `toArray` in interface `java.util.Collection<T>`
      Specified by:
        `toArray` in interface `java.util.List<T>`

    - #### equals

          public boolean equals​(java.lang.Object o)

      Specified by:
        `equals` in interface `java.util.Collection<T>`
      Specified by:
        `equals` in interface `java.util.List<T>`
      Overrides:
        `equals` in class `java.lang.Object`

    - #### hashCode

          public int hashCode()

      Specified by:
        `hashCode` in interface `java.util.Collection<T>`
      Specified by:
        `hashCode` in interface `java.util.List<T>`
      Overrides:
        `hashCode` in class `java.lang.Object`

    - #### iterator

          public java.util.Iterator<T> iterator()

      Specified by:
        `iterator` in interface `java.util.Collection<T>`
      Specified by:
        `iterator` in interface `java.lang.Iterable<T>`
      Specified by:
        `iterator` in interface `java.util.List<T>`

    - #### listIterator

          public java.util.ListIterator<T> listIterator()

      Specified by:
        `listIterator` in interface `java.util.List<T>`

    - #### listIterator

          public java.util.ListIterator<T> listIterator​(int start)

      Specified by:
        `listIterator` in interface `java.util.List<T>`

    - #### subList

          public java.util.List<T> subList​(int i,
                                           int i2)

      Specified by:
        `subList` in interface `java.util.List<T>`

    - #### add

          public boolean add​(T aByte)

      Specified by:
        `add` in interface `java.util.Collection<T>`
      Specified by:
        `add` in interface `java.util.List<T>`

    - #### add

          public void add​(int i,
                          T aByte)

      Specified by:
        `add` in interface `java.util.List<T>`

    - #### addAll

          public boolean addAll​(java.util.Collection<? extends T> bytes)

      Specified by:
        `addAll` in interface `java.util.Collection<T>`
      Specified by:
        `addAll` in interface `java.util.List<T>`

    - #### addAll

          public boolean addAll​(int i,
                                java.util.Collection<? extends T> bytes)

      Specified by:
        `addAll` in interface `java.util.List<T>`

    - #### clear

          public void clear()

      Specified by:
        `clear` in interface `java.util.Collection<T>`
      Specified by:
        `clear` in interface `java.util.List<T>`

    - #### remove

          public T remove​(int i)

      Specified by:
        `remove` in interface `java.util.List<T>`

    - #### remove

          public boolean remove​(java.lang.Object o)

      Specified by:
        `remove` in interface `java.util.Collection<T>`
      Specified by:
        `remove` in interface `java.util.List<T>`

    - #### removeAll

          public boolean removeAll​(java.util.Collection<?> objects)

      Specified by:
        `removeAll` in interface `java.util.Collection<T>`
      Specified by:
        `removeAll` in interface `java.util.List<T>`

    - #### retainAll

          public boolean retainAll​(java.util.Collection<?> objects)

      Specified by:
        `retainAll` in interface `java.util.Collection<T>`
      Specified by:
        `retainAll` in interface `java.util.List<T>`