Module org.htmlunit

Class HTMLCollection

java.lang.Object
org.htmlunit.corejs.javascript.SlotMapOwner<org.htmlunit.corejs.javascript.Scriptable>
org.htmlunit.corejs.javascript.ScriptableObject
All Implemented Interfaces:
Serializable, Cloneable, org.htmlunit.corejs.javascript.ConstProperties<org.htmlunit.corejs.javascript.Scriptable>, org.htmlunit.corejs.javascript.debug.DebuggableObject, org.htmlunit.corejs.javascript.ExternalArrayData, org.htmlunit.corejs.javascript.PropHolder<org.htmlunit.corejs.javascript.Scriptable>, org.htmlunit.corejs.javascript.Scriptable, org.htmlunit.corejs.javascript.SymbolScriptable
Direct Known Subclasses:
HTMLFormControlsCollection

public class HTMLCollection extends AbstractList
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.
This class (like all classes in this package) is specific for the JavaScript engine. Users of HtmlUnit shouldn't use it directly.
Author:
Daniel Gredler, Marc Guillemot, Chris Erskine, Ahmed Ashour, Frank Danek, Ronald Brill
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.htmlunit.javascript.host.dom.AbstractList

    AbstractList.EffectOnCache

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

    org.htmlunit.corejs.javascript.ScriptableObject.DescriptorInfo, org.htmlunit.corejs.javascript.ScriptableObject.KeyComparator, org.htmlunit.corejs.javascript.ScriptableObject.LambdaGetterFunction, org.htmlunit.corejs.javascript.ScriptableObject.LambdaSetterFunction
  • Field Summary

    Fields inherited from class org.htmlunit.corejs.javascript.ScriptableObject

    CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST

    Fields inherited from class org.htmlunit.corejs.javascript.SlotMapOwner

    isSealed

    Fields inherited from interface org.htmlunit.corejs.javascript.Scriptable

    NOT_FOUND
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an instance.
    HTMLCollection(DomNode domNode, boolean attributeChangeSensitive)
    Creates an instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected HTMLCollection
    create(DomNode parentScope, List<DomNode> initialElements)
    Constructs a new instance with an initial cache value.
    Gets an empty collection.
    final int
    Returns the length.
    protected Object
    Helper for AbstractList.getWithPreemption(String) when finding by id doesn't get results.
    protected boolean
    Returns whether AbstractList.getWithPreemption(String) should search by name or not.
    item(Object index)
    Returns the item or items corresponding to the specified index or key.
    org.htmlunit.corejs.javascript.Scriptable
     
    void
    JavaScript constructor.
    org.htmlunit.corejs.javascript.Scriptable
    Retrieves the item or items corresponding to the specified name (checks ids, and if that does not work, then names).

    Methods inherited from class org.htmlunit.corejs.javascript.ScriptableObject

    applyDescriptorToAttributeBitset, buildDataDescriptor, callMethod, callMethod, checkNotSealed, checkPropertyChangeForSlot, checkPropertyChangeForSlot, checkPropertyDefinition, checkPropertyDefinition, checkSlotRemoval, defineBuiltinProperty, defineBuiltinProperty, defineBuiltInProperty, defineBuiltInProperty, defineBuiltInProperty, defineBuiltInProperty, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, delete, deleteProperty, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureScriptableObjectButNotSymbol, ensureSymbolScriptable, ensureType, get, get, getAllIds, getAncestor, getArrayPrototype, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getSuperProperty, getSuperProperty, getSuperProperty, getThis, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, hasProperty, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGenericDescriptor, isGetterOrSetter, isGetterOrSetter, isTrue, preventExtensions, put, put, putConst, putConstProperty, putConstProperty, putOwnProperty, putOwnProperty, putOwnProperty, putProperty, putProperty, putProperty, putProperty, putSuperProperty, putSuperProperty, putSuperProperty, querySlot, redefineProperty, redefineProperty, sameValue, sealObject, setCommonDescriptorProperties, setExternalArrayData, setGetterOrSetter, setParentScope, setPrototype, size

    Methods inherited from class org.htmlunit.corejs.javascript.SlotMapOwner

    associateValue, checkNotSealed, copyAssociatedValue, createSlotMap, defineProperty, defineProperty, get, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getAttributes, getIds, has, has, isSealed, readMaps, setAttributes, setAttributes, setAttributes, setAttributes, setAttributes, writeMaps

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.htmlunit.corejs.javascript.Scriptable

    get, getIds, has, has

    Methods inherited from interface org.htmlunit.corejs.javascript.SymbolScriptable

    get, has
  • Constructor Details

    • HTMLCollection

      public HTMLCollection()
      Creates an instance.
    • HTMLCollection

      public HTMLCollection(DomNode domNode, boolean attributeChangeSensitive)
      Creates an instance.
      Parameters:
      domNode - parent scope
      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)
  • Method Details

    • jsConstructor

      public void jsConstructor()
      JavaScript constructor.
    • emptyCollection

      public static HTMLCollection emptyCollection(DomNode domNode)
      Gets an empty collection.
      Parameters:
      domNode - the DOM node
      Returns:
      an empty collection
    • create

      protected HTMLCollection create(DomNode parentScope, 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
    • iterator

      public org.htmlunit.corejs.javascript.Scriptable iterator()
      Returns:
      the Iterator symbol
    • getLength

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

      protected Object getWithPreemptionByName(String name, List<DomNode> elements)
      Helper for AbstractList.getWithPreemption(String) when finding by id doesn't get results.
      Overrides:
      getWithPreemptionByName in class AbstractList
      Parameters:
      name - the property name
      elements - the children elements.
      Returns:
      Scriptable.NOT_FOUND if not found
    • isGetWithPreemptionSearchName

      protected boolean isGetWithPreemptionSearchName()
      Returns whether AbstractList.getWithPreemption(String) should search by name or not.
      Returns:
      whether AbstractList.getWithPreemption(String) should search by name or not
    • item

      public Object item(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:
    • namedItem

      public org.htmlunit.corejs.javascript.Scriptable namedItem(String name)
      Retrieves the item or items corresponding to the specified name (checks ids, and if that does not work, then names).
      Parameters:
      name - the name or id the element or elements to return
      Returns:
      the element or elements corresponding to the specified name or id
      See Also: