Class NodeList

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, org.htmlunit.corejs.javascript.Callable, org.htmlunit.corejs.javascript.ConstProperties, org.htmlunit.corejs.javascript.debug.DebuggableObject, org.htmlunit.corejs.javascript.ExternalArrayData, org.htmlunit.corejs.javascript.Scriptable, org.htmlunit.corejs.javascript.SymbolScriptable
    Direct Known Subclasses:
    LabelsNodeList, RadioNodeList

    public class NodeList
    extends AbstractList
    implements org.htmlunit.corejs.javascript.Callable
    An array of elements. Used for the element arrays returned by document.all, document.all.tags('x'), document.forms, window.frames, etc. Note that this class must not be used for collections that can be modified, for example map.areas and select.options.
    See Also:
    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 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
      NodeList()
      Creates an instance.
      NodeList​(org.htmlunit.corejs.javascript.ScriptableObject parentScope)
      Creates an instance.
      NodeList​(DomNode domNode, boolean attributeChangeSensitive)
      Creates an instance.
      NodeList​(DomNode domNode, java.util.List<DomNode> initialElements)
      Constructs an instance with an initial cache value.
    • Constructor Detail

      • NodeList

        public NodeList()
        Creates an instance.
      • NodeList

        public NodeList​(DomNode domNode,
                        boolean attributeChangeSensitive)
        Creates an instance.
        Parameters:
        domNode - the DomNode
        attributeChangeSensitive - indicates if the content of the collection may change when an attribute of a descendant node of parentScope changes (attribute added, modified or removed)
      • NodeList

        public NodeList​(DomNode domNode,
                        java.util.List<DomNode> initialElements)
        Constructs an instance with an initial cache value.
        Parameters:
        domNode - the parent scope, on which we listen for changes
        initialElements - the initial content for the cache
      • NodeList

        NodeList​(org.htmlunit.corejs.javascript.ScriptableObject parentScope)
        Creates an instance.
        Parameters:
        parentScope - the parent scope
    • Method Detail

      • jsConstructor

        public void jsConstructor()
        JavaScript constructor.
      • staticNodeList

        public static NodeList staticNodeList​(HtmlUnitScriptable parentScope,
                                              java.util.List<DomNode> elements)
        Gets a static NodeList.
        Parameters:
        parentScope - the parent scope
        elements - the elements
        Returns:
        an empty collection
      • keys

        public org.htmlunit.corejs.javascript.Scriptable keys()
        Returns an Iterator allowing to go through all keys contained in this object.
        Returns:
        a NativeArrayIterator
      • values

        public org.htmlunit.corejs.javascript.Scriptable values()
        Returns an Iterator allowing to go through all keys contained in this object.
        Returns:
        a NativeArrayIterator
      • entries

        public org.htmlunit.corejs.javascript.Scriptable entries()
        Returns an Iterator allowing to go through all key/value pairs contained in this object.
        Returns:
        a NativeArrayIterator
      • forEach

        public void forEach​(java.lang.Object callback)
        Calls the callback given in parameter once for each value pair in the list, in insertion order.
        Parameters:
        callback - function to execute for each element
      • getLength

        public final int getLength()
        Returns the length.
        Overrides:
        getLength in class AbstractList
        Returns:
        the length
      • item

        public java.lang.Object item​(java.lang.Object index)
        Returns the item or items corresponding to the specified index or key.
        Parameters:
        index - the index or key corresponding to the element or elements to return
        Returns:
        the element or elements corresponding to the specified index or key
        See Also:
        MSDN doc
      • call

        public java.lang.Object call​(org.htmlunit.corejs.javascript.Context cx,
                                     org.htmlunit.corejs.javascript.Scriptable scope,
                                     org.htmlunit.corejs.javascript.Scriptable thisObj,
                                     java.lang.Object[] args)
        Specified by:
        call in interface org.htmlunit.corejs.javascript.Callable
      • create

        protected AbstractList create​(DomNode parentScope,
                                      java.util.List<DomNode> initialElements)
        Constructs a new instance with an initial cache value.
        Overrides:
        create in class AbstractList
        Parameters:
        parentScope - the parent scope, on which we listen for changes
        initialElements - the initial content for the cache
        Returns:
        the newly created instance