Class SimpleArray

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, org.htmlunit.corejs.javascript.ConstProperties, org.htmlunit.corejs.javascript.debug.DebuggableObject, org.htmlunit.corejs.javascript.Scriptable, org.htmlunit.corejs.javascript.SymbolScriptable
    Direct Known Subclasses:
    MimeTypeArray, Plugin, PluginArray

    public class SimpleArray
    extends HtmlUnitScriptable
    A JavaScript object for SimpleArray allowing access per key and index (like MimeTypeArray).
    See Also:
    XUL Planet, Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class org.htmlunit.corejs.javascript.ScriptableObject

        org.htmlunit.corejs.javascript.ScriptableObject.KeyComparator
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.List<java.lang.Object> elements_  
      • Fields inherited from class org.htmlunit.corejs.javascript.ScriptableObject

        CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST
      • Fields inherited from interface org.htmlunit.corejs.javascript.Scriptable

        NOT_FOUND
    • Constructor Summary

      Constructors 
      Constructor Description
      SimpleArray()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) void add​(java.lang.Object element)
      Adds an element.
      java.lang.Object get​(int index, org.htmlunit.corejs.javascript.Scriptable start)
      Returns the element at the specified index, or null if the index is invalid.
      protected java.lang.String getItemName​(java.lang.Object element)
      Gets the name of the element.
      int getLength()
      Gets the array size.
      protected java.lang.Object getWithPreemption​(java.lang.String name)
      Called by HtmlUnitScriptable.get(String, Scriptable) to allow retrieval of the property before the prototype chain is searched.
      java.lang.Object item​(int index)
      Returns the item at the given index.
      java.lang.Object namedItem​(java.lang.String name)
      Returns the item at the given index.
      • Methods inherited from class org.htmlunit.corejs.javascript.ScriptableObject

        applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, delete, deleteProperty, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureSymbolScriptable, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, getIds, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, has, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, put, putConst, putConstProperty, putProperty, putProperty, putProperty, querySlot, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setAttributes, setCommonDescriptorProperties, setExternalArrayData, setGetterOrSetter, setPrototype, size
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • elements_

        private final java.util.List<java.lang.Object> elements_
    • Constructor Detail

      • SimpleArray

        public SimpleArray()
    • Method Detail

      • item

        public java.lang.Object item​(int index)
        Returns the item at the given index.
        Parameters:
        index - the index
        Returns:
        the item at the given position
      • getWithPreemption

        protected java.lang.Object getWithPreemption​(java.lang.String name)

        Called by HtmlUnitScriptable.get(String, Scriptable) to allow retrieval of the property before the prototype chain is searched.

        IMPORTANT: This method is invoked *very* often by Rhino. If you override this method, the implementation needs to be as fast as possible!

        Overrides:
        getWithPreemption in class HtmlUnitScriptable
        Parameters:
        name - the property name
        Returns:
        Scriptable.NOT_FOUND if not found
      • get

        public final java.lang.Object get​(int index,
                                          org.htmlunit.corejs.javascript.Scriptable start)
        Returns the element at the specified index, or null if the index is invalid.
        Specified by:
        get in interface org.htmlunit.corejs.javascript.Scriptable
        Overrides:
        get in class org.htmlunit.corejs.javascript.ScriptableObject
      • namedItem

        public java.lang.Object namedItem​(java.lang.String name)
        Returns the item at the given index.
        Parameters:
        name - the item name
        Returns:
        the item with the given name
      • getItemName

        protected java.lang.String getItemName​(java.lang.Object element)
        Gets the name of the element. Should be abstract but current implementation of prototype configuration doesn't allow it.
        Parameters:
        element - the array's element
        Returns:
        the element's name
      • getLength

        public int getLength()
        Gets the array size.
        Returns:
        the number elements
      • add

        void add​(java.lang.Object element)
        Adds an element.
        Parameters:
        element - the element to add