Class NativeTypedArrayView<T>
java.lang.Object
org.htmlunit.corejs.javascript.ScriptableObject
org.htmlunit.corejs.javascript.IdScriptableObject
org.htmlunit.corejs.javascript.typedarrays.NativeArrayBufferView
org.htmlunit.corejs.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.htmlunit.corejs.javascript.ScriptableObject
ScriptableObject.KeyComparator -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprotected final intThe length, in elements, of the arrayprivate static final intprotected static final intprivate static final longprivate static final intFields inherited from class org.htmlunit.corejs.javascript.typedarrays.NativeArrayBufferView
arrayBuffer, byteLength, offsetFields inherited from class org.htmlunit.corejs.javascript.ScriptableObject
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONSTFields inherited from interface org.htmlunit.corejs.javascript.Scriptable
NOT_FOUND -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedprotectedNativeTypedArrayView(NativeArrayBuffer ab, int off, int len, int byteLen) -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleanbooleanaddAll(int i, Collection<? extends T> bytes) booleanaddAll(Collection<? extends T> bytes) protected booleancheckIndex(int index) voidclear()protected abstract NativeTypedArrayView<T> construct(NativeArrayBuffer ab, int off, int len) booleanbooleancontainsAll(Collection<?> objects) voiddelete(int index) Removes the indexed property from the object.voidRemoves a named property from the object.booleanexecIdCall(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, 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.protected StringgetInstanceIdName(int id) Map id back to property name it defines.protected ObjectgetInstanceIdValue(int id) Get id value.protected intGet maximum id findInstanceIdInfo can generate.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()intprotected voidinitPrototypeId(int id) booleanisEmpty()iterator()private Objectjs_at(Context cx, Scriptable scope, Scriptable thisObj, Object[] args) private NativeTypedArrayView<T> js_constructor(Context cx, Scriptable scope, Object[] args) protected abstract Objectjs_get(int index) protected abstract Objectprivate Objectjs_subarray(Context cx, Scriptable scope, int s, int e) intlistIterator(int start) private NativeArrayBuffermakeArrayBuffer(Context cx, Scriptable scope, int length) voidput(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.protected abstract NativeTypedArrayView<T> realThis(Scriptable thisObj, IdFunctionObject f) remove(int i) booleanbooleanremoveAll(Collection<?> objects) booleanretainAll(Collection<?> objects) voidsetArrayElement(int index, Object value) Set the element at the specified index.private voidsetRange(NativeArray a, int off) private voidsetRange(NativeTypedArrayView<T> v, int off) intsize()subList(int i, int i2) Object[]toArray()<U> U[]toArray(U[] ts) private static inttoIndex(double num) To aid in parsing: Return a positive (or zero) integer if the double is a valid array index, and -1 if not.Methods inherited from class org.htmlunit.corejs.javascript.typedarrays.NativeArrayBufferView
get, getBuffer, getByteLength, getByteOffset, isArg, useLittleEndianMethods inherited from class org.htmlunit.corejs.javascript.IdScriptableObject
activatePrototypeMap, addIdFunctionProperty, defaultGet, defaultHas, defaultPut, defineOwnProperty, delete, ensureType, exportAsJSClass, findInstanceIdInfo, getAttributes, getAttributes, getOwnPropertyDescriptor, has, hasPrototypeMap, initPrototypeConstructor, initPrototypeMethod, initPrototypeMethod, initPrototypeMethod, initPrototypeValue, initPrototypeValue, instanceIdInfo, put, setAttributes, setInstanceIdAttributes, setInstanceIdValueMethods inherited from class org.htmlunit.corejs.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, deleteProperty, 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, setPrototypeMethods 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
addFirst, addLast, get, getFirst, getLast, removeFirst, removeLast, replaceAll, reversed, set, sort, spliterator
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
length
protected final int lengthThe length, in elements, of the array -
Id_constructor
private static final int Id_constructor- See Also:
-
Id_toString
private static final int Id_toString- See Also:
-
Id_get
private static final int Id_get- See Also:
-
Id_set
private static final int Id_set- See Also:
-
Id_subarray
private static final int Id_subarray- See Also:
-
Id_at
private static final int Id_at- See Also:
-
SymbolId_iterator
private static final int SymbolId_iterator- See Also:
-
MAX_PROTOTYPE_ID
protected static final int MAX_PROTOTYPE_ID- See Also:
-
Id_length
private static final int Id_length- See Also:
-
Id_BYTES_PER_ELEMENT
private static final int Id_BYTES_PER_ELEMENT- See Also:
-
MAX_INSTANCE_ID
private static final int MAX_INSTANCE_ID- See Also:
-
-
Constructor Details
-
NativeTypedArrayView
protected NativeTypedArrayView() -
NativeTypedArrayView
-
-
Method Details
-
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:
-
get
Description copied from class:ScriptableObjectReturns 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 interfaceScriptable- Overrides:
getin classIdScriptableObject- 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 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:ScriptableObjectReturns true if the named property is defined.- Specified by:
hasin interfaceScriptable- Overrides:
hasin classIdScriptableObject- 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 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 interfaceScriptable- Overrides:
putin classIdScriptableObject- 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 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 interfaceScriptable- Overrides:
deletein classIdScriptableObject- Parameters:
name- the name of the property- See Also:
-
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.
-
toIndex
private static int toIndex(double num) To aid in parsing: Return a positive (or zero) integer if the double is a valid array index, and -1 if not. -
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
-
makeArrayBuffer
-
js_constructor
-
setRange
-
setRange
-
js_subarray
-
js_at
-
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
-
initPrototypeId
protected void initPrototypeId(int id) - Overrides:
initPrototypeIdin classIdScriptableObject
-
findPrototypeId
- Overrides:
findPrototypeIdin classIdScriptableObject
-
findPrototypeId
- Overrides:
findPrototypeIdin classIdScriptableObject
-
fillConstructorProperties
- Overrides:
fillConstructorPropertiesin classIdScriptableObject
-
getMaxInstanceId
protected int getMaxInstanceId()Description copied from class:IdScriptableObjectGet maximum id findInstanceIdInfo can generate.- Overrides:
getMaxInstanceIdin classNativeArrayBufferView
-
getInstanceIdName
Description copied from class:IdScriptableObjectMap id back to property name it defines.- Overrides:
getInstanceIdNamein classNativeArrayBufferView
-
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 classNativeArrayBufferView
-
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 classNativeArrayBufferView
-
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
-