Package org.htmlunit.javascript.host.dom
Class AbstractList
java.lang.Object
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.debug.DebuggableObject
,org.htmlunit.corejs.javascript.ExternalArrayData
,org.htmlunit.corejs.javascript.Scriptable
,org.htmlunit.corejs.javascript.SymbolScriptable
- Direct Known Subclasses:
HTMLCollection
,NodeList
public class AbstractList
extends HtmlUnitScriptable
implements org.htmlunit.corejs.javascript.ExternalArrayData
The parent class of
NodeList
and HTMLCollection
.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
static enum
Cache effect of some changes.Nested classes/interfaces inherited from class org.htmlunit.corejs.javascript.ScriptableObject
org.htmlunit.corejs.javascript.ScriptableObject.KeyComparator
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private boolean
Cache collection elements when possible, so as to avoid expensive XPath expression evaluations.private boolean
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
ConstructorsModifierConstructorDescriptionCreates an instance.protected
AbstractList
(DomNode domNode, boolean attributeChangeSensitive, List<DomNode> initialElements) Creates an instance. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Only needed to make collections likedocument.all
available but "invisible" when simulating Firefox.protected AbstractList
Constructs a new instance with an initial cache value.void
defineProperty
(String propertyName, Object delegateTo, Method getter, Method setter, int attributes) protected Object
equivalentValues
(Object other) Called for the js "==".getArrayElement
(int index) int
Gets the HTML elements from cache or retrieve them at first call.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
getScriptableForElement
(Object object) Gets the scriptable for the provided element that may already be the right scriptable.protected Object
getWithPreemption
(String name) Returns the element or elements that match the specified key.protected Object
getWithPreemptionByName
(String name, List<DomNode> elements) Helper forgetWithPreemption(String)
when finding by id doesn't get results.private void
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
setEffectOnCacheFunction
(Function<HtmlAttributeChangeEvent, AbstractList.EffectOnCache> effectOnCacheFunction) void
setElementsSupplier
(Supplier<List<DomNode>> elementsSupplier) Returns the elements whose associated host objects are available through this collection.void
setIsMatchingPredicate
(Predicate<DomNode> isMatchingPredicate) Indicates if the node should belong to the collection.toString()
Methods inherited from class org.htmlunit.javascript.HtmlUnitScriptable
clone, get, getBrowserVersion, getClassName, getDefaultValue, getDomNodeOrDie, getDomNodeOrNull, getPrototype, getScriptableFor, getStartingScope, getWindow, getWindow, has, hasInstance, initParentScope, makeScriptableFor, put, setClassName, setDomNode, setParentScope, setupPromise, setupRejectedPromise
Methods inherited from class org.htmlunit.corejs.javascript.ScriptableObject
applyDescriptorToAttributeBitset, associateValue, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, delete, deleteProperty, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureSymbolScriptable, get, 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
-
Field Details
-
avoidObjectDetection_
private boolean avoidObjectDetection_ -
attributeChangeSensitive_
private boolean attributeChangeSensitive_ -
cachedElements_
Cache collection elements when possible, so as to avoid expensive XPath expression evaluations. -
listenerRegistered_
private boolean listenerRegistered_ -
effectOnCacheFunction_
-
isMatchingPredicate_
-
elementsSupplier_
-
-
Constructor Details
-
AbstractList
public AbstractList()Creates an instance. -
AbstractList
protected AbstractList(DomNode domNode, boolean attributeChangeSensitive, List<DomNode> initialElements) Creates an instance.- Parameters:
domNode
- theDomNode
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 likedocument.all
available but "invisible" when simulating Firefox.- Overrides:
avoidObjectDetection
in classorg.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
- Returns:
- elementSupplier
-
setElementsSupplier
Returns the elements whose associated host objects are available through this collection.- Parameters:
elementsSupplier
- the new supplier
-
getIsMatchingPredicate
- Returns:
- isMatchingPredicate
-
setIsMatchingPredicate
Indicates if the node should belong to the collection.- Parameters:
isMatchingPredicate
- the new predicate
-
getIt
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
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 classHtmlUnitScriptable
- Parameters:
domNode
- the DOM nodeassignScriptObject
- If true, callsetScriptObject
on domNode
-
getElements
Gets the HTML elements from cache or retrieve them at first call.- Returns:
- the list of
HtmlElement
contained in this collection
-
registerListener
private void registerListener() -
getWithPreemption
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 classHtmlUnitScriptable
- Parameters:
name
- the property name- Returns:
Scriptable.NOT_FOUND
if not found
-
create
Constructs a new instance with an initial cache value.- Parameters:
parentScope
- the parent scope, on which we listen for changesinitialElements
- the initial content for the cache- Returns:
- the newly created instance
-
getWithPreemptionByName
Helper forgetWithPreemption(String)
when finding by id doesn't get results.- Parameters:
name
- the property nameelements
- the children elements.- Returns:
Scriptable.NOT_FOUND
if not found
-
getLength
public int getLength()Returns the length.- Returns:
- the length
-
toString
-
equivalentValues
Called for the js "==".- Overrides:
equivalentValues
in classHtmlUnitScriptable
-
getScriptableForElement
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(String propertyName, Object delegateTo, Method getter, Method setter, int attributes) - Overrides:
defineProperty
in classorg.htmlunit.corejs.javascript.ScriptableObject
-
getArrayElement
- Specified by:
getArrayElement
in interfaceorg.htmlunit.corejs.javascript.ExternalArrayData
-
setArrayElement
- Specified by:
setArrayElement
in interfaceorg.htmlunit.corejs.javascript.ExternalArrayData
-
getArrayLength
public int getArrayLength()- Specified by:
getArrayLength
in interfaceorg.htmlunit.corejs.javascript.ExternalArrayData
-