Module org.htmlunit

Class AbstractList

java.lang.Object
org.htmlunit.corejs.javascript.SlotMapOwner<org.htmlunit.corejs.javascript.Scriptable>
org.htmlunit.corejs.javascript.ScriptableObject
org.htmlunit.javascript.HtmlUnitScriptable
org.htmlunit.javascript.host.dom.AbstractList
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:
HTMLAllCollection, HTMLCollection, NodeList

public class AbstractList extends HtmlUnitScriptable implements org.htmlunit.corejs.javascript.ExternalArrayData
The parent class of NodeList and HTMLCollection.
Author:
Daniel Gredler, Marc Guillemot, Chris Erskine, Ahmed Ashour, Frank Danek, Ronald Brill
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Cache effect of some changes.

    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
    Modifier
    Constructor
    Description
     
    Creates an instance.
    protected
    AbstractList(DomNode domNode, boolean attributeChangeSensitive, List<DomNode> initialElements)
    Creates an instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Only needed to make collections like document.all available but "invisible" when simulating Firefox.
    protected AbstractList
    create(DomNode parentScope, List<DomNode> initialElements)
    Constructs a new instance with an initial cache value.
    void
    defineProperty(org.htmlunit.corejs.javascript.VarScope scope, String propertyName, Object delegateTo, Method getter, Method setter, int attributes)
    protected Object
    Called for the js "==".
    getArrayElement(int index)
     
    int
     
    Gets the HTML elements from cache or retrieve them at first call.
    protected Supplier<List<DomNode>>
     
    protected Predicate<DomNode>
     
    protected Object
    Private helper that retrieves the item or items corresponding to the specified index or key.
    int
    Returns the length.
    protected org.htmlunit.corejs.javascript.Scriptable
    Gets the scriptable for the provided element that may already be the right scriptable.
    protected Object
    Returns the element or elements that match the specified key.
    protected Object
    Helper for getWithPreemption(String) when finding by id doesn't get results.
    void
    setArrayElement(int index, Object value)
     
    void
    setAvoidObjectDetection(boolean newValue)
     
    void
    setDomNode(DomNode domNode, boolean assignScriptObject)
    INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
    Sets the DOM node that corresponds to this JavaScript object.
    void
     
    void
    Returns the elements whose associated host objects are available through this collection.
    void
    Indicates if the node should belong to the collection.

    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

    • AbstractList

      public AbstractList()
      Creates an instance.
    • AbstractList

      protected AbstractList(DomNode domNode, boolean attributeChangeSensitive, List<DomNode> initialElements)
      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)
      initialElements - the initial content for the cache
  • Method Details

    • avoidObjectDetection

      public boolean avoidObjectDetection()
      Only needed to make collections like document.all available but "invisible" when simulating Firefox.
      Overrides:
      avoidObjectDetection in class org.htmlunit.corejs.javascript.ScriptableObject
    • setAvoidObjectDetection

      public void setAvoidObjectDetection(boolean newValue)
      Parameters:
      newValue - the new value
    • setEffectOnCacheFunction

      public void setEffectOnCacheFunction(Function<HtmlAttributeChangeEvent,AbstractList.EffectOnCache> effectOnCacheFunction)
      Parameters:
      effectOnCacheFunction - the new function
    • getElementSupplier

      protected Supplier<List<DomNode>> getElementSupplier()
      Returns:
      elementSupplier
    • setElementsSupplier

      public void setElementsSupplier(Supplier<List<DomNode>> elementsSupplier)
      Returns the elements whose associated host objects are available through this collection.
      Parameters:
      elementsSupplier - the new supplier
    • getIsMatchingPredicate

      protected Predicate<DomNode> getIsMatchingPredicate()
      Returns:
      isMatchingPredicate
    • setIsMatchingPredicate

      public void setIsMatchingPredicate(Predicate<DomNode> isMatchingPredicate)
      Indicates if the node should belong to the collection.
      Parameters:
      isMatchingPredicate - the new predicate
    • getIt

      protected Object getIt(Object o)
      Private helper that retrieves the item or items corresponding to the specified index or key.
      Parameters:
      o - the index or key corresponding to the element or elements to return
      Returns:
      the element or elements corresponding to the specified index or key
    • setDomNode

      public void setDomNode(DomNode domNode, boolean assignScriptObject)
      Description copied from class: HtmlUnitScriptable
      INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
      Sets the DOM node that corresponds to this JavaScript object.
      Overrides:
      setDomNode in class HtmlUnitScriptable
      Parameters:
      domNode - the DOM node
      assignScriptObject - If true, call setScriptObject on domNode
    • getElements

      public List<DomNode> getElements()
      Gets the HTML elements from cache or retrieve them at first call.
      Returns:
      the list of HtmlElement contained in this collection
    • getWithPreemption

      protected Object getWithPreemption(String name)
      Returns the element or elements that match the specified key. If it is the name of a property, the property value is returned. If it is the id of an element in the array, that element is returned. Finally, if it is the name of an element or elements in the array, then all those elements are returned. Otherwise, Scriptable.NOT_FOUND is returned.

      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
    • create

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

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

      public int getLength()
      Returns the length.
      Returns:
      the length
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equivalentValues

      protected Object equivalentValues(Object other)
      Called for the js "==".
      Overrides:
      equivalentValues in class HtmlUnitScriptable
    • getScriptableForElement

      protected org.htmlunit.corejs.javascript.Scriptable getScriptableForElement(Object object)
      Gets the scriptable for the provided element that may already be the right scriptable.
      Parameters:
      object - the object for which to get the scriptable
      Returns:
      the scriptable
    • defineProperty

      public void defineProperty(org.htmlunit.corejs.javascript.VarScope scope, String propertyName, Object delegateTo, Method getter, Method setter, int attributes)
      Overrides:
      defineProperty in class org.htmlunit.corejs.javascript.ScriptableObject
    • getArrayElement

      public Object getArrayElement(int index)
      Specified by:
      getArrayElement in interface org.htmlunit.corejs.javascript.ExternalArrayData
    • setArrayElement

      public void setArrayElement(int index, Object value)
      Specified by:
      setArrayElement in interface org.htmlunit.corejs.javascript.ExternalArrayData
    • getArrayLength

      public int getArrayLength()
      Specified by:
      getArrayLength in interface org.htmlunit.corejs.javascript.ExternalArrayData