public class HTMLCollection extends AbstractList
AbstractList.EffectOnCache
Constructor and Description |
---|
HTMLCollection()
Creates an instance.
|
HTMLCollection(DomNode parentScope,
boolean attributeChangeSensitive,
String description)
Creates an instance.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addElementIds(List<String> idList,
List<Object> elements)
Adds the ids of the collection's elements to the idList.
|
protected List<Object> |
computeElements()
Returns the elements whose associated host objects are available through this collection.
|
static HTMLCollection |
emptyCollection(Window window)
Gets an empty collection.
|
protected Object |
equivalentValues(Object other)
Called for the js "==".
|
Object[] |
getIds()
.
|
protected net.sourceforge.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 boolean |
isGetWithPreemptionSearchName()
Returns whether
getWithPreemption(String) should search by name or not. |
protected boolean |
isMatching(DomNode node)
Indicates if the node should belong to the collection.
|
Object |
item(Object index)
Returns the item or items corresponding to the specified index or key.
|
Object |
namedItem(String name)
Retrieves the item or items corresponding to the specified name (checks ids, and if
that does not work, then names).
|
Object |
nextNode()
Returns the next node in the collection (supporting iteration in IE only).
|
void |
reset()
Resets the node iterator accessed via
nextNode() . |
Object |
tags(String tagName)
Returns all the elements in this element array that have the specified tag name.
|
avoidObjectDetection, call, construct, get, getCandidates, getEffectOnCache, getElements, getLength, has, has, setAvoidObjectDetection, setDomNode, toString
clone, get, getBrowserVersion, getDefaultValue, getDomNodeOrDie, getDomNodeOrNull, getPrototype, getScriptableFor, getStartingScope, getTransformerScriptableFor, getWindow, getWindow, hasInstance, initParentScope, isReadOnlySettable, makeScriptableFor, setCaseSensitive, setDomNode, setHtmlElement
defineFunctionProperties, defineProperty, getClassName, setClassName, setParentScope
applyDescriptorToAttributeBitset, associateValue, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, delete, delete, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGetterOrSetter, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getPropertyIds, getPrototype, getSlot, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, put, putConst, putConstProperty, putProperty, putProperty, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setExternalArrayData, setGetterOrSetter, setPrototype, size
public HTMLCollection()
public HTMLCollection(DomNode parentScope, boolean attributeChangeSensitive, String description)
parentScope
- parent scopeattributeChangeSensitive
- indicates if the content of the collection may change when an attribute
of a descendant node of parentScope changes (attribute added, modified or removed)description
- a text useful for debuggingpublic static HTMLCollection emptyCollection(Window window)
window
- the current scopeprotected List<Object> computeElements()
computeElements
in class AbstractList
protected boolean isMatching(DomNode node)
isMatching
in class AbstractList
node
- the node to test. Will be a child node of the reference node.false
here as subclasses for concrete collections should decide it.protected Object getWithPreemption(String name)
Scriptable.NOT_FOUND
is returned.
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 SimpleScriptable.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!
getWithPreemption
in class AbstractList
name
- the property nameScriptable.NOT_FOUND
if not foundprotected boolean isGetWithPreemptionSearchName()
getWithPreemption(String)
should search by name or not.getWithPreemption(String)
should search by name or notpublic Object item(Object index)
item
in class AbstractList
index
- the index or key corresponding to the element or elements to returnpublic Object namedItem(String name)
name
- the name or id the element or elements to returnpublic Object nextNode()
public void reset()
nextNode()
.public Object tags(String tagName)
tagName
- the name of the tag of the elements to returnprotected Object equivalentValues(Object other)
equivalentValues
in class AbstractList
public Object[] getIds()
getIds
in interface net.sourceforge.htmlunit.corejs.javascript.Scriptable
getIds
in class AbstractList
protected void addElementIds(List<String> idList, List<Object> elements)
addElementIds
in class AbstractList
idList
- the list to add the ids toelements
- the collection's elementsprotected net.sourceforge.htmlunit.corejs.javascript.Scriptable getScriptableForElement(Object object)
getScriptableForElement
in class AbstractList
object
- the object for which to get the scriptableCopyright © 2002–2017 Gargoyle Software Inc.. All rights reserved.