Class NativeArray

    • Constructor Detail

      • NativeArray

        public NativeArray​(long lengthArg)
      • NativeArray

        public NativeArray​(java.lang.Object[] array)
    • Method Detail

      • init

        static void init​(Scriptable scope,
                         boolean sealed)
      • getMaximumInitialCapacity

        static int getMaximumInitialCapacity()
      • setMaximumInitialCapacity

        static void setMaximumInitialCapacity​(int maximumInitialCapacity)
      • getClassName

        public java.lang.String getClassName()
        Description copied from class: ScriptableObject
        Return the name of the class. This is typically the same name as the constructor. Classes extending ScriptableObject must implement this abstract method.
        Specified by:
        getClassName in interface Scriptable
        Specified by:
        getClassName in class ScriptableObject
      • setInstanceIdAttributes

        protected void setInstanceIdAttributes​(int id,
                                               int attr)
        Description copied from class: IdScriptableObject
        Update 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:
        setInstanceIdAttributes in class IdScriptableObject
        Parameters:
        id - the instance property id
        attr - the new attribute bitset
      • 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 IdScriptableObject
      • setInstanceIdValue

        protected void setInstanceIdValue​(int id,
                                          java.lang.Object value)
        Description copied from class: IdScriptableObject
        Set or delete id value. If value == NOT_FOUND , the implementation should make sure that the following getInstanceIdValue return NOT_FOUND.
        Overrides:
        setInstanceIdValue in class IdScriptableObject
      • 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)
      • toArrayIndex

        private static long toArrayIndex​(java.lang.Object id)
      • toArrayIndex

        private static long toArrayIndex​(java.lang.String id)
      • toArrayIndex

        private static long toArrayIndex​(double d)
      • toDenseIndex

        private static int toDenseIndex​(java.lang.Object id)
      • ensureCapacity

        private boolean ensureCapacity​(int capacity)
      • getIds

        public java.lang.Object[] getIds​(boolean nonEnumerable,
                                         boolean getSymbols)
        Overrides:
        getIds in class IdScriptableObject
      • getIndexIds

        public java.util.List<java.lang.Integer> getIndexIds()
      • getDefaultValue

        public java.lang.Object getDefaultValue​(java.lang.Class<?> hint)
        Description copied from class: ScriptableObject
        Implements 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 hint of null means "no hint".

        Specified by:
        getDefaultValue in interface Scriptable
        Overrides:
        getDefaultValue in class ScriptableObject
        Parameters:
        hint - the type hint
        Returns:
        the default value for the object See ECMA 8.6.2.6.
      • defaultIndexPropertyDescriptor

        private ScriptableObject defaultIndexPropertyDescriptor​(java.lang.Object value)
      • defineOwnProperty

        protected void defineOwnProperty​(Context cx,
                                         java.lang.Object id,
                                         ScriptableObject desc,
                                         boolean checkValid)
        Description copied from class: ScriptableObject
        Defines a property on an object. Based on [[DefineOwnProperty]] from 8.12.10 of the spec.
        Overrides:
        defineOwnProperty in class ScriptableObject
        Parameters:
        cx - the current Context
        id - the name/index of the property
        desc - the new property descriptor, as described in 8.6.1
        checkValid - whether to perform validity checks
      • jsConstructor

        private static java.lang.Object jsConstructor​(Context cx,
                                                      Scriptable scope,
                                                      java.lang.Object[] args)
        See ECMA 15.4.1,2
      • getLength

        public long getLength()
      • jsGet_length

        @Deprecated
        public long jsGet_length()
        Deprecated.
        Use getLength() instead.
      • setDenseOnly

        void setDenseOnly​(boolean denseOnly)
        Change the value of the internal flag that determines whether all storage is handed by a dense backing array rather than an associative store.
        Parameters:
        denseOnly - new value for denseOnly flag
        Throws:
        java.lang.IllegalArgumentException - if an attempt is made to enable denseOnly after it was disabled; NativeArray code is not written to handle switching back to a dense representation
      • setLength

        private void setLength​(java.lang.Object val)
      • getLengthProperty

        static long getLengthProperty​(Context cx,
                                      Scriptable obj,
                                      boolean throwIfTooLarge)
      • setLengthProperty

        private static java.lang.Object setLengthProperty​(Context cx,
                                                          Scriptable target,
                                                          long length)
      • deleteElem

        private static void deleteElem​(Scriptable target,
                                       long index)
      • getElem

        private static java.lang.Object getElem​(Context cx,
                                                Scriptable target,
                                                long index)
      • getRawElem

        private static java.lang.Object getRawElem​(Scriptable target,
                                                   long index)
      • defineElem

        private static void defineElem​(Context cx,
                                       Scriptable target,
                                       long index,
                                       java.lang.Object value)
      • setElem

        private static void setElem​(Context cx,
                                    Scriptable target,
                                    long index,
                                    java.lang.Object value)
      • setRawElem

        private static void setRawElem​(Context cx,
                                       Scriptable target,
                                       long index,
                                       java.lang.Object value)
      • toStringHelper

        private static java.lang.String toStringHelper​(Context cx,
                                                       Scriptable scope,
                                                       Scriptable thisObj,
                                                       boolean toSource,
                                                       boolean toLocale)
      • js_join

        private static java.lang.String js_join​(Context cx,
                                                Scriptable scope,
                                                Scriptable thisObj,
                                                java.lang.Object[] args)
        See ECMA 15.4.4.3
      • js_shift

        private static java.lang.Object js_shift​(Context cx,
                                                 Scriptable scope,
                                                 Scriptable thisObj,
                                                 java.lang.Object[] args)
      • js_unshift

        private static java.lang.Object js_unshift​(Context cx,
                                                   Scriptable scope,
                                                   Scriptable thisObj,
                                                   java.lang.Object[] args)
      • js_splice

        private static java.lang.Object js_splice​(Context cx,
                                                  Scriptable scope,
                                                  Scriptable thisObj,
                                                  java.lang.Object[] args)
      • isConcatSpreadable

        private static boolean isConcatSpreadable​(Context cx,
                                                  Scriptable scope,
                                                  java.lang.Object val)
      • toSliceIndex

        private static long toSliceIndex​(double value,
                                         long length)
      • js_indexOf

        private static java.lang.Object js_indexOf​(Context cx,
                                                   Scriptable scope,
                                                   Scriptable thisObj,
                                                   java.lang.Object[] args)
      • js_lastIndexOf

        private static java.lang.Object js_lastIndexOf​(Context cx,
                                                       Scriptable scope,
                                                       Scriptable thisObj,
                                                       java.lang.Object[] args)
      • js_includes

        private static java.lang.Boolean js_includes​(Context cx,
                                                     Scriptable scope,
                                                     Scriptable thisObj,
                                                     java.lang.Object[] args)
      • js_copyWithin

        private static java.lang.Object js_copyWithin​(Context cx,
                                                      Scriptable scope,
                                                      Scriptable thisObj,
                                                      java.lang.Object[] args)
      • iterativeMethod

        private static java.lang.Object iterativeMethod​(Context cx,
                                                        IdFunctionObject idFunctionObject,
                                                        Scriptable scope,
                                                        Scriptable thisObj,
                                                        java.lang.Object[] args)
        Implements the methods "every", "filter", "forEach", "map", and "some".
      • reduceMethod

        private static java.lang.Object reduceMethod​(Context cx,
                                                     int id,
                                                     Scriptable scope,
                                                     Scriptable thisObj,
                                                     java.lang.Object[] args)
        Implements the methods "reduce" and "reduceRight".
      • js_isArray

        private static boolean js_isArray​(java.lang.Object o)
      • contains

        public boolean contains​(java.lang.Object o)
        Specified by:
        contains in interface java.util.Collection
        Specified by:
        contains in interface java.util.List
      • toArray

        public java.lang.Object[] toArray()
        Specified by:
        toArray in interface java.util.Collection
        Specified by:
        toArray in interface java.util.List
      • toArray

        public java.lang.Object[] toArray​(java.lang.Object[] a)
        Specified by:
        toArray in interface java.util.Collection
        Specified by:
        toArray in interface java.util.List
      • containsAll

        public boolean containsAll​(java.util.Collection c)
        Specified by:
        containsAll in interface java.util.Collection
        Specified by:
        containsAll in interface java.util.List
      • size

        public int size()
        Specified by:
        size in interface java.util.Collection
        Specified by:
        size in interface java.util.List
        Overrides:
        size in class ScriptableObject
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface java.util.Collection
        Specified by:
        isEmpty in interface java.util.List
        Overrides:
        isEmpty in class ScriptableObject
      • get

        public java.lang.Object get​(long index)
      • get

        public java.lang.Object get​(int index)
        Specified by:
        get in interface java.util.List
      • indexOf

        public int indexOf​(java.lang.Object o)
        Specified by:
        indexOf in interface java.util.List
      • lastIndexOf

        public int lastIndexOf​(java.lang.Object o)
        Specified by:
        lastIndexOf in interface java.util.List
      • iterator

        public java.util.Iterator iterator()
        Specified by:
        iterator in interface java.util.Collection
        Specified by:
        iterator in interface java.lang.Iterable
        Specified by:
        iterator in interface java.util.List
      • listIterator

        public java.util.ListIterator listIterator()
        Specified by:
        listIterator in interface java.util.List
      • listIterator

        public java.util.ListIterator listIterator​(int start)
        Specified by:
        listIterator in interface java.util.List
      • add

        public boolean add​(java.lang.Object o)
        Specified by:
        add in interface java.util.Collection
        Specified by:
        add in interface java.util.List
      • remove

        public boolean remove​(java.lang.Object o)
        Specified by:
        remove in interface java.util.Collection
        Specified by:
        remove in interface java.util.List
      • addAll

        public boolean addAll​(java.util.Collection c)
        Specified by:
        addAll in interface java.util.Collection
        Specified by:
        addAll in interface java.util.List
      • removeAll

        public boolean removeAll​(java.util.Collection c)
        Specified by:
        removeAll in interface java.util.Collection
        Specified by:
        removeAll in interface java.util.List
      • retainAll

        public boolean retainAll​(java.util.Collection c)
        Specified by:
        retainAll in interface java.util.Collection
        Specified by:
        retainAll in interface java.util.List
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Collection
        Specified by:
        clear in interface java.util.List
      • add

        public void add​(int index,
                        java.lang.Object element)
        Specified by:
        add in interface java.util.List
      • addAll

        public boolean addAll​(int index,
                              java.util.Collection c)
        Specified by:
        addAll in interface java.util.List
      • set

        public java.lang.Object set​(int index,
                                    java.lang.Object element)
        Specified by:
        set in interface java.util.List
      • remove

        public java.lang.Object remove​(int index)
        Specified by:
        remove in interface java.util.List
      • subList

        public java.util.List subList​(int fromIndex,
                                      int toIndex)
        Specified by:
        subList in interface java.util.List