Module org.htmlunit.corejs
Class NativeTypedArrayView<T>
java.lang.Object
org.htmlunit.corejs.javascript.SlotMapOwner<Scriptable>
org.htmlunit.corejs.javascript.ScriptableObject
org.htmlunit.corejs.javascript.typedarrays.NativeArrayBufferView
org.htmlunit.corejs.javascript.typedarrays.NativeTypedArrayView<T>
- All Implemented Interfaces:
Serializable,Iterable<T>,Collection<T>,List<T>,RandomAccess,ConstProperties<Scriptable>,DebuggableObject,ExternalArrayData,PropHolder<Scriptable>,Scriptable,SymbolScriptable
- Direct Known Subclasses:
NativeBigIntArrayView,NativeFloat16Array,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 ClassesModifier and TypeClassDescriptionprotected static interfaceprotected static interfaceNested classes/interfaces inherited from class org.htmlunit.corejs.javascript.ScriptableObject
ScriptableObject.DescriptorInfo, ScriptableObject.KeyComparator, ScriptableObject.LambdaGetterFunction, ScriptableObject.LambdaSetterFunction -
Field Summary
Fields inherited from class org.htmlunit.corejs.javascript.typedarrays.NativeArrayBufferView
arrayBuffer, byteLength, offset, outOfRangeFields inherited from class org.htmlunit.corejs.javascript.ScriptableObject
CONST, DONTENUM, EMPTY, LEGACY_CONST, PERMANENT, READONLY, STRICTLY_READONLY, UNINITIALIZED_CONSTFields inherited from class org.htmlunit.corejs.javascript.SlotMapOwner
isSealedFields inherited from interface org.htmlunit.corejs.javascript.Scriptable
NOT_FOUND -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedprotectedNativeTypedArrayView(NativeArrayBuffer ab, int off, int len, int byteLen) Construct a TypedArray view over an ArrayBuffer. -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleanbooleanaddAll(int i, Collection<? extends T> bytes) booleanaddAll(Collection<? extends T> bytes) protected booleancheckIndex(int index) Returnstrue, if the index is wrong.voidclear()booleanbooleancontainsAll(Collection<?> objects) protected booleandefineOwnProperty(Context cx, Object id, ScriptableObject.DescriptorInfo desc, boolean checkValid) Defines a property on an object.voiddelete(int index) Removes the indexed property from the object.voidRemoves a named property from the object.protected voidensureIndex(int index) Enusres that the index is in the given rangebooleanget(int index, Scriptable start) Returns the value of the indexed property or NOT_FOUND.get(String name, Scriptable start) Returns the value of the named property or NOT_FOUND.getArrayElement(int index) Return the element at the specified index.intReturn the length of the array.abstract intReturn the number of bytes represented by each element in the array.Object[]getIds()Returns an array of ids for the properties of the object.booleanhas(int index, Scriptable start) Returns true if the property index is defined.booleanhas(String name, Scriptable start) Returns true if the named property is defined.inthashCode()intbooleanisEmpty()booleanCheck if this TypedArray view is out of bounds (ES2025).iterator()protected static NativeTypedArrayView<?>js_constructor(Context cx, JSFunction f, Object nt, VarScope s, Object thisObj, Object[] args, NativeTypedArrayView.TypedArrayConstructable constructable, int bytesPerElement, TopLevel.Builtins type) protected static NativeTypedArrayView<?>js_constructor(Context cx, VarScope scope, Object[] args, NativeTypedArrayView.TypedArrayConstructable constructable, int bytesPerElement) protected abstract Objectjs_get(int index) protected abstract ObjectintlistIterator(int start) booleanvoidput(int index, Scriptable start, Object val) Sets the value of the indexed property, creating it if need be.voidput(String name, Scriptable start, Object val) Sets the value of the named property, creating it if need be.remove(int i) booleanbooleanremoveAll(Collection<?> objects) booleanretainAll(Collection<?> objects) voidsetArrayElement(int index, Object value) Set the element at the specified index.intsize()subList(int i, int i2) Object[]toArray()<U> U[]toArray(U[] ts) protected Objectprotected intMethod to allow implementation of https://tc39.es/ecma262/multipage/indexed-collections.html#sec-validatetypedarray, but only return the actual length since we don't really need to create a witness record.Methods inherited from class org.htmlunit.corejs.javascript.typedarrays.NativeArrayBufferView
getBuffer, getByteLength, getByteOffset, isArgMethods inherited from class org.htmlunit.corejs.javascript.ScriptableObject
applyDescriptorToAttributeBitset, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkNotSealed, checkPropertyChangeForSlot, checkPropertyChangeForSlot, checkPropertyDefinition, checkPropertyDefinition, checkSlotRemoval, defineBuiltinProperty, defineBuiltinProperty, defineBuiltInProperty, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, deleteProperty, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureScriptableObjectButNotSymbol, ensureSymbolScriptable, ensureType, equivalentValues, get, getAllIds, getAncestor, getArrayPrototype, getClassName, getClassPrototype, getClassPrototype, getDefaultValue, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getSuperProperty, getSuperProperty, getSuperProperty, getThis, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, hasInstance, hasProperty, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isAccessorDescriptor, isConst, isDataDescriptor, isExtensible, isFalse, isGenericDescriptor, isGenericDescriptor, isGetterOrSetter, isGetterOrSetter, isTrue, put, putConst, putConstProperty, putConstProperty, putOwnProperty, putOwnProperty, putOwnProperty, putProperty, putProperty, putProperty, putProperty, putSuperProperty, putSuperProperty, putSuperProperty, querySlot, redefineProperty, redefineProperty, sameValue, sealObject, setCommonDescriptorProperties, setExternalArrayData, setGetterOrSetter, setParentScope, setPrototypeMethods inherited from class org.htmlunit.corejs.javascript.SlotMapOwner
associateValue, checkNotSealed, copyAssociatedValue, createSlotMap, createSlotMap, defineProperty, defineProperty, get, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getAttributes, has, isSealed, readMaps, setAttributes, setAttributes, setAttributes, setAttributes, setAttributes, writeMapsMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.List
get, replaceAll, set, sort, spliteratorMethods inherited from interface org.htmlunit.corejs.javascript.Scriptable
get, hasMethods inherited from interface org.htmlunit.corejs.javascript.SymbolScriptable
get, has
-
Constructor Details
-
NativeTypedArrayView
protected NativeTypedArrayView() -
NativeTypedArrayView
Construct a TypedArray view over an ArrayBuffer. If len is negative, creates an auto-length view (ES2025) that tracks the buffer's size dynamically.
-
-
Method Details
-
get
Description copied from class:ScriptableObjectReturns the value of the indexed property or NOT_FOUND.- Specified by:
getin interfacePropHolder<T>- 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:
-
get
Description copied from class:SlotMapOwnerReturns the value of the named property or NOT_FOUND.If the property was created using defineProperty, the appropriate getter method is called.
- Specified by:
getin interfacePropHolder<T>- Specified by:
getin interfaceScriptable- Overrides:
getin classSlotMapOwner<Scriptable>- Parameters:
name- the name of 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 interfacePropHolder<T>- 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:SlotMapOwnerReturns true if the named property is defined.- Specified by:
hasin interfacePropHolder<T>- Specified by:
hasin interfaceScriptable- Overrides:
hasin classSlotMapOwner<Scriptable>- Parameters:
name- the name of 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:ScriptableObjectSets the value of the indexed property, creating it if need be.- Specified by:
putin interfacePropHolder<T>- Specified by:
putin interfaceScriptable- Overrides:
putin classScriptableObject- Parameters:
index- the numeric index for the propertystart- the object whose property is being setval- value to set the property to- See Also:
-
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 interfacePropHolder<T>- Specified by:
putin interfaceScriptable- Overrides:
putin classScriptableObject- Parameters:
name- the name of 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: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 interfacePropHolder<T>- Specified by:
deletein interfaceScriptable- Overrides:
deletein classScriptableObject- Parameters:
index- the numeric index for the property- See Also:
-
delete
Description copied from class:ScriptableObjectRemoves a named property from the object.If the property is not found, or it has the PERMANENT attribute, no action is taken.
- Specified by:
deletein interfacePropHolder<T>- Specified by:
deletein interfaceScriptable- Overrides:
deletein classScriptableObject- Parameters:
name- the name of the property- See Also:
-
getIds
Description copied from class:SlotMapOwnerReturns an array of ids for the properties of the object.Any properties with the attribute DONTENUM are not listed.
- Specified by:
getIdsin interfacePropHolder<T>- Specified by:
getIdsin interfaceScriptable- Overrides:
getIdsin classSlotMapOwner<Scriptable>- 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.
-
preventExtensions
public boolean preventExtensions()- Overrides:
preventExtensionsin classScriptableObject
-
defineOwnProperty
protected boolean defineOwnProperty(Context cx, Object id, ScriptableObject.DescriptorInfo desc, boolean checkValid) Description copied from class:ScriptableObjectDefines a property on an object.Based on [[DefineOwnProperty]] from 8.12.10 of the spec. see [[DefineOwnProperty]]
- Overrides:
defineOwnPropertyin classScriptableObject- 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- Returns:
- always true at the moment
-
checkIndex
protected boolean checkIndex(int index) Returnstrue, if the index is wrong. -
ensureIndex
protected void ensureIndex(int index) Enusres that the index is in the given range- Throws:
IndexOutOfBoundsException- when index is out of range
-
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. -
js_get
-
js_set
-
toNumeric
-
js_constructor
protected static NativeTypedArrayView<?> js_constructor(Context cx, JSFunction f, Object nt, VarScope s, Object thisObj, Object[] args, NativeTypedArrayView.TypedArrayConstructable constructable, int bytesPerElement, TopLevel.Builtins type) -
js_constructor
protected static NativeTypedArrayView<?> js_constructor(Context cx, VarScope scope, Object[] args, NativeTypedArrayView.TypedArrayConstructable constructable, int bytesPerElement) -
isTypedArrayOutOfBounds
public boolean isTypedArrayOutOfBounds()Check if this TypedArray view is out of bounds (ES2025). For auto-length views, updates the length before checking. Returns true if the buffer is detached or the offset is out of range. -
validateAndGetLength
protected int validateAndGetLength()Method to allow implementation of https://tc39.es/ecma262/multipage/indexed-collections.html#sec-validatetypedarray, but only return the actual length since we don't really need to create a witness record. -
getArrayElement
Description copied from interface:ExternalArrayDataReturn 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:
getArrayElementin interfaceExternalArrayData
-
setArrayElement
Description copied from interface:ExternalArrayDataSet 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:
setArrayElementin interfaceExternalArrayData
-
getArrayLength
public int getArrayLength()Description copied from interface:ExternalArrayDataReturn the length of the array.- Specified by:
getArrayLengthin interfaceExternalArrayData
-
containsAll
- Specified by:
containsAllin interfaceCollection<T>- Specified by:
containsAllin interfaceList<T>
-
indexOf
-
lastIndexOf
- Specified by:
lastIndexOfin interfaceList<T>
-
toArray
-
toArray
public <U> U[] toArray(U[] ts) -
size
public int size()- Specified by:
sizein interfaceCollection<T>- Specified by:
sizein interfaceList<T>- Overrides:
sizein classScriptableObject
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection<T>- Specified by:
isEmptyin interfaceList<T>- Overrides:
isEmptyin classScriptableObject
-
contains
-
equals
-
hashCode
public int hashCode() -
iterator
-
listIterator
- Specified by:
listIteratorin interfaceList<T>
-
listIterator
- Specified by:
listIteratorin interfaceList<T>
-
subList
-
add
-
add
-
addAll
-
addAll
-
clear
public void clear() -
remove
-
remove
-
removeAll
-
retainAll
-