Class HtmlElement
- java.lang.Object
-
- org.htmlunit.html.DomNode
-
- org.htmlunit.html.DomNamespaceNode
-
- org.htmlunit.html.DomElement
-
- org.htmlunit.html.HtmlElement
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,org.w3c.dom.Element,org.w3c.dom.Node
- Direct Known Subclasses:
BaseFrameElement,HtmlAbbreviated,HtmlAcronym,HtmlAddress,HtmlAnchor,HtmlApplet,HtmlArea,HtmlArticle,HtmlAside,HtmlBackgroundSound,HtmlBase,HtmlBaseFont,HtmlBidirectionalIsolation,HtmlBidirectionalOverride,HtmlBig,HtmlBlink,HtmlBlockQuote,HtmlBody,HtmlBold,HtmlBreak,HtmlButton,HtmlCanvas,HtmlCaption,HtmlCenter,HtmlCitation,HtmlCode,HtmlCommand,HtmlData,HtmlDataList,HtmlDefinition,HtmlDefinitionDescription,HtmlDefinitionList,HtmlDefinitionTerm,HtmlDeletedText,HtmlDetails,HtmlDialog,HtmlDirectory,HtmlDivision,HtmlEmbed,HtmlEmphasis,HtmlExample,HtmlFieldSet,HtmlFigure,HtmlFigureCaption,HtmlFont,HtmlFooter,HtmlForm,HtmlFrameSet,HtmlHead,HtmlHeader,HtmlHeading1,HtmlHeading2,HtmlHeading3,HtmlHeading4,HtmlHeading5,HtmlHeading6,HtmlHorizontalRule,HtmlHtml,HtmlImage,HtmlInlineQuotation,HtmlInput,HtmlInsertedText,HtmlIsIndex,HtmlItalic,HtmlKeyboard,HtmlLabel,HtmlLayer,HtmlLegend,HtmlLink,HtmlListing,HtmlListItem,HtmlMain,HtmlMap,HtmlMark,HtmlMarquee,HtmlMedia,HtmlMenu,HtmlMenuItem,HtmlMeta,HtmlMultiColumn,HtmlNav,HtmlNextId,HtmlNoBreak,HtmlNoEmbed,HtmlNoFrames,HtmlNoLayer,HtmlNoScript,HtmlObject,HtmlOption,HtmlOptionGroup,HtmlOrderedList,HtmlOutput,HtmlParagraph,HtmlParameter,HtmlPicture,HtmlPlainText,HtmlPreformattedText,HtmlProgress,HtmlRp,HtmlRt,HtmlRuby,HtmlS,HtmlSample,HtmlScript,HtmlSection,HtmlSelect,HtmlSlot,HtmlSmall,HtmlSource,HtmlSpan,HtmlStrike,HtmlStrong,HtmlStyle,HtmlSubscript,HtmlSummary,HtmlSuperscript,HtmlSvg,HtmlTable,HtmlTableCell,HtmlTableColumn,HtmlTableColumnGroup,HtmlTableRow,HtmlTeletype,HtmlTemplate,HtmlTextArea,HtmlTime,HtmlTitle,HtmlTrack,HtmlUnderlined,HtmlUnknownElement,HtmlUnorderedList,HtmlVariable,HtmlWordBreak,TableRowGroup
public abstract class HtmlElement extends DomElement
An abstract wrapper for HTML elements.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classHtmlElement.DisplayStyleEnum for the different display styles.-
Nested classes/interfaces inherited from class org.htmlunit.html.DomElement
DomElement.ChildElementsIterator
-
Nested classes/interfaces inherited from class org.htmlunit.html.DomNode
DomNode.ChildIterator, DomNode.DescendantElementsIterator<T extends DomNode>
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.StringATTRIBUTE_CHECKEDConstant 'checked'.protected static java.lang.StringATTRIBUTE_REQUIREDConstant 'required'.static java.lang.ShortTAB_INDEX_OUT_OF_BOUNDSConstant indicating that a tab index value is out of bounds (less than0or greater than32767).-
Fields inherited from class org.htmlunit.html.DomElement
ATTRIBUTE_NOT_DEFINED, ATTRIBUTE_VALUE_EMPTY, SRC_ATTRIBUTE
-
Fields inherited from class org.htmlunit.html.DomNode
PROPERTY_ELEMENT, READY_STATE_COMPLETE, READY_STATE_INTERACTIVE, READY_STATE_LOADED, READY_STATE_LOADING, READY_STATE_UNINITIALIZED
-
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedHtmlElement(java.lang.String namespaceURI, java.lang.String qualifiedName, SgmlPage page, java.util.Map<java.lang.String,DomAttr> attributes)Creates an instance of a DOM element that can have a namespace.protectedHtmlElement(java.lang.String qualifiedName, SgmlPage page, java.util.Map<java.lang.String,DomAttr> attributes)Creates an instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanacceptChar(char c)Indicates if the provided character can by "typed" in the element.voidaddHtmlAttributeChangeListener(HtmlAttributeChangeListener listener)Adds an HtmlAttributeChangeListener to the listener list.HtmlElementappendChildIfNoneExists(java.lang.String tagName)Appends a child element to this HTML element with the specified tag name if this HTML element does not already have a child with that tag name.protected voidcheckChildHierarchy(org.w3c.dom.Node childNode)Check for insertion errors for a new child node.DomNodecloneNode(boolean deep)protected voiddetach()INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Detach this node from all relationships with other nodes.protected voiddoType(char c, boolean lastType)Performs the effective type action, called after the keyPress event and before the keyUp event.protected voiddoType(int keyCode, boolean lastType)Performs the effective type action, called after the keyPress event and before the keyUp event.protected voidfireHtmlAttributeAdded(HtmlAttributeChangeEvent event)Support for reporting HTML attribute changes.protected voidfireHtmlAttributeRemoved(HtmlAttributeChangeEvent event)Support for reporting HTML attribute changes.protected voidfireHtmlAttributeReplaced(HtmlAttributeChangeEvent event)Support for reporting HTML attribute changes.java.lang.StringgetCanonicalXPath()Returns the canonical XPath expression which identifies this node, for instance"/html/body/table[3]/tbody/tr[5]/td[2]/span/a[3]".HtmlElement.DisplayStylegetDefaultStyleDisplay()INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Returns the default display style.<E extends HtmlElement>
java.util.List<E>getElementsByAttribute(java.lang.String elementName, java.lang.String attributeName, java.lang.String attributeValue)Returns all elements which are descendants of this element and match the specified search criteria.HtmlElementgetEnclosingElement(java.lang.String tagName)Returns the first element with the specified tag name that is an ancestor to this element, ornullif no such element is found.HtmlFormgetEnclosingForm()Returns the form which contains this element, ornullif this element is not inside of a form.HtmlFormgetEnclosingFormOrDie()Returns the form which contains this element.java.lang.StringgetLangAttribute()Returns the value of the attributelang.java.lang.StringgetNodeName()java.lang.StringgetOnClickAttribute()Returns the value of the attributeonclick.java.lang.StringgetOnDblClickAttribute()Returns the value of the attributeondblclick.<E extends HtmlElement>
EgetOneHtmlElementByAttribute(java.lang.String elementName, java.lang.String attributeName, java.lang.String attributeValue)Searches for an element based on the specified criteria, returning the first element which matches said criteria.java.lang.StringgetOnKeyDownAttribute()Returns the value of the attributeonkeydown.java.lang.StringgetOnKeyPressAttribute()Returns the value of the attributeonkeypress.java.lang.StringgetOnKeyUpAttribute()Returns the value of the attributeonkeyup.java.lang.StringgetOnMouseDownAttribute()Returns the value of the attributeonmousedown.java.lang.StringgetOnMouseMoveAttribute()Returns the value of the attributeonmousemove.java.lang.StringgetOnMouseOutAttribute()Returns the value of the attributeonmouseout.java.lang.StringgetOnMouseOverAttribute()Returns the value of the attributeonmouseover.java.lang.StringgetOnMouseUpAttribute()Returns the value of the attributeonmouseup.protected java.lang.StringgetSrcAttributeNormalized()Helper for src retrieval and normalization.java.lang.ShortgetTabIndex()Returns this element's tab index, if it has one.java.lang.StringgetTextDirectionAttribute()Returns the value of the attributedir.java.lang.StringgetXmlLangAttribute()Returns the value of the attributexml:lang.booleanhandles(org.htmlunit.javascript.host.event.Event event)Indicates if the provided event can be applied to this node.booleanhasEventHandlers(java.lang.String eventName)INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Returnstrueif this element has any JavaScript functions that need to be executed when the specified event occurs.booleanisAltPressed()Returns whether theALTis currently pressed.protected booleanisAttributeCaseSensitive()Indicates if the attribute names are case sensitive.booleanisCtrlPressed()Returns whether theCTRLis currently pressed.booleanisDisplayed()Returnstrueif this node is displayed and can be visible to the user (ignoring screen size, scrolling limitations, color, font-size, or overlapping nodes).booleanisHidden()booleanisOptional()booleanisRequired()protected booleanisRequiredSupported()Returns whether this element supports therequiredconstraint.protected booleanisShiftPressed()Returns whether theSHIFTis currently pressed.protected booleanisSubmittableByEnter()Returnstrueif clicking Enter (ASCII 10, or '\n') should submit the enclosed form (if any).booleanisValid()Returns whether this element satisfies all form validation constraints set.protected static voidnotifyAttributeChangeListeners(HtmlAttributeChangeEvent event, HtmlElement element, java.lang.String oldAttributeValue, boolean notifyMutationObservers)Recursively notifies allHtmlAttributeChangeListeners.voidremoveAttribute(java.lang.String attributeName)Removes an attribute specified by name from this element.voidremoveChild(java.lang.String tagName, int i)Removes theith child element with the specified tag name from all relationships, if possible.voidremoveHtmlAttributeChangeListener(HtmlAttributeChangeListener listener)Removes an HtmlAttributeChangeListener from the listener list.org.w3c.dom.AttrsetAttributeNode(org.w3c.dom.Attr attribute)Sets the specified attribute.protected voidsetAttributeNS(java.lang.String namespaceURI, java.lang.String qualifiedName, java.lang.String attributeValue, boolean notifyAttributeChangeListeners, boolean notifyMutationObservers)Sets the value of the attribute specified by namespace and qualified name.voidsetRequired(boolean required)Sets therequiredattribute.Pagetype(char c)Simulates typing the specified character while this element has focus, returning the page contained by this element's window after typing.Pagetype(int keyCode)Simulates typing the specified key code while this element has focus, returning the page contained by this element's window after typing.voidtype(java.lang.String text)Simulates typing the specified text while this element has focus.Pagetype(Keyboard keyboard)Simulates typing the specifiedKeyboardwhile this element has focus, returning the page contained by this element's window after typing.protected voidtypeDone(java.lang.String newValue, boolean notifyAttributeChangeListeners)Called fromDoTypeProcessor.-
Methods inherited from class org.htmlunit.html.DomElement
blur, click, click, click, click, click, dblClick, dblClick, doClickFireChangeEvent, doClickFireClickEvent, doClickStateUpdate, fireEvent, fireEvent, focus, getAttribute, getAttributeDirect, getAttributeNode, getAttributeNodeNS, getAttributeNS, getAttributes, getAttributesMap, getChildElementCount, getChildElements, getElementsByTagName, getElementsByTagNameNS, getEventTargetElement, getFirstElementChild, getId, getLastElementChild, getNodeType, getSchemaTypeInfo, getStyleElement, getStyleElementCaseInSensitive, getStyleMap, getTagName, hasAttribute, hasAttributeNS, hasAttributes, isDisabledElementAndDisabled, isEmptyXmlTagExpanded, isMouseOver, isStateUpdateFirst, matches, mouseDown, mouseDown, mouseMove, mouseMove, mouseOut, mouseOut, mouseOver, mouseOver, mouseUp, mouseUp, preventDefault, printOpeningTagContentAsXml, printXml, propagateClickStateUpdateToParent, removeAttributeNode, removeAttributeNS, removeFocus, removeStyleAttribute, replaceStyleAttribute, rightClick, rightClick, setAttribute, setAttributeNodeNS, setAttributeNS, setDefaults, setId, setIdAttribute, setIdAttributeNode, setIdAttributeNS, setInnerHtml, setNodeValue, toString, writeStyleToElement
-
Methods inherited from class org.htmlunit.html.DomNamespaceNode
getLocalName, getLowercaseName, getNamespaceURI, getPrefix, getQualifiedName, processImportNode, setPrefix
-
Methods inherited from class org.htmlunit.html.DomNode
addCharacterDataChangeListener, addDomChangeListener, appendChild, asNormalizedText, asXml, basicRemove, closest, compareDocumentPosition, fireCharacterDataChanged, fireNodeAdded, fireNodeDeleted, getAncestors, getBaseURI, getByXPath, getByXPath, getChildNodes, getChildren, getDescendants, getDomElementDescendants, getEndColumnNumber, getEndLineNumber, getFeature, getFirstByXPath, getFirstByXPath, getFirstChild, getHtmlElementDescendants, getHtmlPageOrNull, getIndex, getLastChild, getNextElementSibling, getNextSibling, getNodeValue, getOwnerDocument, getPage, getParentNode, getPreviousElementSibling, getPreviousSibling, getReadyState, getScriptableObject, getSelectorList, getStartColumnNumber, getStartLineNumber, getTextContent, getUserData, getVisibleText, hasChildNodes, hasFeature, insertBefore, insertBefore, isAncestorOf, isAncestorOfAny, isAttachedToPage, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, mayBeDisplayed, normalize, notifyIncorrectness, onAddedToDocumentFragment, onAddedToPage, onAllChildrenAddedToPage, parseHtmlSnippet, printChildrenAsXml, querySelector, querySelectorAll, quietlyRemoveAndMoveChildrenTo, remove, removeAllChildren, removeCharacterDataChangeListener, removeChild, removeDomChangeListener, replace, replaceChild, setEndLocation, setParentNode, setReadyState, setScriptableObject, setStartLocation, setTextContent, setUserData
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.w3c.dom.Node
appendChild, compareDocumentPosition, getBaseURI, getChildNodes, getFeature, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, getTextContent, getUserData, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setPrefix, setTextContent, setUserData
-
-
-
-
Field Detail
-
TAB_INDEX_OUT_OF_BOUNDS
public static final java.lang.Short TAB_INDEX_OUT_OF_BOUNDS
Constant indicating that a tab index value is out of bounds (less than0or greater than32767).- See Also:
getTabIndex()
-
ATTRIBUTE_REQUIRED
protected static final java.lang.String ATTRIBUTE_REQUIRED
Constant 'required'.- See Also:
- Constant Field Values
-
ATTRIBUTE_CHECKED
protected static final java.lang.String ATTRIBUTE_CHECKED
Constant 'checked'.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
HtmlElement
protected HtmlElement(java.lang.String qualifiedName, SgmlPage page, java.util.Map<java.lang.String,DomAttr> attributes)Creates an instance.- Parameters:
qualifiedName- the qualified name of the element type to instantiatepage- the page that contains this elementattributes- a map ready initialized with the attributes for this element, ornull. The map will be stored as is, not copied.
-
HtmlElement
protected HtmlElement(java.lang.String namespaceURI, java.lang.String qualifiedName, SgmlPage page, java.util.Map<java.lang.String,DomAttr> attributes)Creates an instance of a DOM element that can have a namespace.- Parameters:
namespaceURI- the URI that identifies an XML namespacequalifiedName- the qualified name of the element type to instantiatepage- the page that contains this elementattributes- a map ready initialized with the attributes for this element, ornull. The map will be stored as is, not copied.
-
-
Method Detail
-
setAttributeNS
protected void setAttributeNS(java.lang.String namespaceURI, java.lang.String qualifiedName, java.lang.String attributeValue, boolean notifyAttributeChangeListeners, boolean notifyMutationObservers)Sets the value of the attribute specified by namespace and qualified name.- Overrides:
setAttributeNSin classDomElement- Parameters:
namespaceURI- the URI that identifies an XML namespacequalifiedName- the qualified name (prefix:local) of the attributeattributeValue- the value of the attributenotifyAttributeChangeListeners- to notify the associatedHtmlAttributeChangeListenersnotifyMutationObservers- to notifyMutationObservers or not
-
notifyAttributeChangeListeners
protected static void notifyAttributeChangeListeners(HtmlAttributeChangeEvent event, HtmlElement element, java.lang.String oldAttributeValue, boolean notifyMutationObservers)
Recursively notifies allHtmlAttributeChangeListeners.- Parameters:
event- the eventelement- the elementoldAttributeValue- the old attribute valuenotifyMutationObservers- whether to notifyMutationObservers or not
-
setAttributeNode
public org.w3c.dom.Attr setAttributeNode(org.w3c.dom.Attr attribute)
Sets the specified attribute. This method may be overridden by subclasses which are interested in specific attribute value changes, but such methods must invokesuper.setAttributeNode(), and should consider the value of thecloningparameter when deciding whether or not to execute custom logic.- Specified by:
setAttributeNodein interfaceorg.w3c.dom.Element- Overrides:
setAttributeNodein classDomElement- Parameters:
attribute- the attribute to set- Returns:
-
removeAttribute
public void removeAttribute(java.lang.String attributeName)
Removes an attribute specified by name from this element.- Specified by:
removeAttributein interfaceorg.w3c.dom.Element- Overrides:
removeAttributein classDomElement- Parameters:
attributeName- the attribute attributeName
-
fireHtmlAttributeAdded
protected void fireHtmlAttributeAdded(HtmlAttributeChangeEvent event)
Support for reporting HTML attribute changes. This method can be called when an attribute has been added and it will send the appropriateHtmlAttributeChangeEventto any registeredHtmlAttributeChangeListeners.Note that this method recursively calls this element's parent's
fireHtmlAttributeAdded(HtmlAttributeChangeEvent)method.- Parameters:
event- the event- See Also:
addHtmlAttributeChangeListener(HtmlAttributeChangeListener)
-
fireHtmlAttributeReplaced
protected void fireHtmlAttributeReplaced(HtmlAttributeChangeEvent event)
Support for reporting HTML attribute changes. This method can be called when an attribute has been replaced and it will send the appropriateHtmlAttributeChangeEventto any registeredHtmlAttributeChangeListeners.Note that this method recursively calls this element's parent's
fireHtmlAttributeReplaced(HtmlAttributeChangeEvent)method.- Parameters:
event- the event- See Also:
addHtmlAttributeChangeListener(HtmlAttributeChangeListener)
-
fireHtmlAttributeRemoved
protected void fireHtmlAttributeRemoved(HtmlAttributeChangeEvent event)
Support for reporting HTML attribute changes. This method can be called when an attribute has been removed and it will send the appropriateHtmlAttributeChangeEventto any registeredHtmlAttributeChangeListeners.Note that this method recursively calls this element's parent's
fireHtmlAttributeRemoved(HtmlAttributeChangeEvent)method.- Parameters:
event- the event- See Also:
addHtmlAttributeChangeListener(HtmlAttributeChangeListener)
-
getNodeName
public java.lang.String getNodeName()
Description copied from class:DomElement- Specified by:
getNodeNamein interfaceorg.w3c.dom.Node- Overrides:
getNodeNamein classDomElement- Returns:
- the same value as returned by
DomElement.getTagName()
-
getTabIndex
public java.lang.Short getTabIndex()
Returns this element's tab index, if it has one. If the tab index is outside of the valid range (less than0or greater than32767), this method returnsTAB_INDEX_OUT_OF_BOUNDS. If this element does not have a tab index, or its tab index is otherwise invalid, this method returnsnull.- Returns:
- this element's tab index
-
getEnclosingElement
public HtmlElement getEnclosingElement(java.lang.String tagName)
Returns the first element with the specified tag name that is an ancestor to this element, ornullif no such element is found.- Parameters:
tagName- the name of the tag searched (case insensitive)- Returns:
- the first element with the specified tag name that is an ancestor to this element
-
getEnclosingForm
public HtmlForm getEnclosingForm()
Returns the form which contains this element, ornullif this element is not inside of a form.- Returns:
- the form which contains this element
-
getEnclosingFormOrDie
public HtmlForm getEnclosingFormOrDie()
Returns the form which contains this element. If this element is not inside a form, this method throws anIllegalStateException.- Returns:
- the form which contains this element
-
type
public void type(java.lang.String text) throws java.io.IOExceptionSimulates typing the specified text while this element has focus. Note that for some elements, typing '\n' submits the enclosed form.- Parameters:
text- the text you with to simulate typing- Throws:
java.io.IOException- If an IO error occurs
-
type
public Page type(char c) throws java.io.IOException
Simulates typing the specified character while this element has focus, returning the page contained by this element's window after typing. Note that it may or may not be the same as the original page, depending on the JavaScript event handlers, etc. Note also that for some elements, typing'\n'submits the enclosed form.- Parameters:
c- the character you wish to simulate typing- Returns:
- the page that occupies this window after typing
- Throws:
java.io.IOException- if an IO error occurs
-
type
public Page type(int keyCode)
Simulates typing the specified key code while this element has focus, returning the page contained by this element's window after typing. Note that it may or may not be the same as the original page, depending on the JavaScript event handlers, etc. Note also that for some elements, typingXXXXXXXXXXXsubmits the enclosed form.An example of predefined values is
KeyboardEvent.DOM_VK_PAGE_DOWN.- Parameters:
keyCode- the key code to simulate typing- Returns:
- the page that occupies this window after typing
-
type
public Page type(Keyboard keyboard) throws java.io.IOException
Simulates typing the specifiedKeyboardwhile this element has focus, returning the page contained by this element's window after typing. Note that it may or may not be the same as the original page, depending on the JavaScript event handlers, etc. Note also that for some elements, typingXXXXXXXXXXXsubmits the enclosed form.- Parameters:
keyboard- the keyboard- Returns:
- the page that occupies this window after typing
- Throws:
java.io.IOException- if an IO error occurs
-
doType
protected void doType(char c, boolean lastType)Performs the effective type action, called after the keyPress event and before the keyUp event.- Parameters:
c- the character you with to simulate typinglastType- is this the last character to type
-
doType
protected void doType(int keyCode, boolean lastType)Performs the effective type action, called after the keyPress event and before the keyUp event.An example of predefined values is
KeyboardEvent.DOM_VK_PAGE_DOWN.- Parameters:
keyCode- the key code wish to simulate typinglastType- is this the last to type
-
typeDone
protected void typeDone(java.lang.String newValue, boolean notifyAttributeChangeListeners)Called fromDoTypeProcessor.- Parameters:
newValue- the new valuenotifyAttributeChangeListeners- to notify the associatedHtmlAttributeChangeListeners
-
acceptChar
protected boolean acceptChar(char c)
Indicates if the provided character can by "typed" in the element.- Parameters:
c- the character- Returns:
trueif it is accepted
-
isSubmittableByEnter
protected boolean isSubmittableByEnter()
Returnstrueif clicking Enter (ASCII 10, or '\n') should submit the enclosed form (if any). The default implementation returnsfalse.- Returns:
trueif clicking Enter should submit the enclosed form (if any)
-
getOneHtmlElementByAttribute
public final <E extends HtmlElement> E getOneHtmlElementByAttribute(java.lang.String elementName, java.lang.String attributeName, java.lang.String attributeValue) throws ElementNotFoundException
Searches for an element based on the specified criteria, returning the first element which matches said criteria. Only elements which are descendants of this element are included in the search.- Type Parameters:
E- the sub-element type- Parameters:
elementName- the name of the element to search forattributeName- the name of the attribute to search forattributeValue- the value of the attribute to search for- Returns:
- the first element which matches the specified search criteria
- Throws:
ElementNotFoundException- if no element matches the specified search criteria
-
getElementsByAttribute
public final <E extends HtmlElement> java.util.List<E> getElementsByAttribute(java.lang.String elementName, java.lang.String attributeName, java.lang.String attributeValue)
Returns all elements which are descendants of this element and match the specified search criteria.- Type Parameters:
E- the sub-element type- Parameters:
elementName- the name of the element to search forattributeName- the name of the attribute to search forattributeValue- the value of the attribute to search for- Returns:
- all elements which are descendants of this element and match the specified search criteria
-
appendChildIfNoneExists
public final HtmlElement appendChildIfNoneExists(java.lang.String tagName)
Appends a child element to this HTML element with the specified tag name if this HTML element does not already have a child with that tag name. Returns the appended child element, or the first existent child element with the specified tag name if none was appended.- Parameters:
tagName- the tag name of the child to append- Returns:
- the added child, or the first existing child if none was added
-
removeChild
public final void removeChild(java.lang.String tagName, int i)Removes theith child element with the specified tag name from all relationships, if possible.- Parameters:
tagName- the tag name of the child to removei- the index of the child to remove
-
hasEventHandlers
public final boolean hasEventHandlers(java.lang.String eventName)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Returnstrueif this element has any JavaScript functions that need to be executed when the specified event occurs.- Parameters:
eventName- the name of the event, such as "onclick" or "onblur", etc- Returns:
- true if an event handler has been defined otherwise false
-
addHtmlAttributeChangeListener
public void addHtmlAttributeChangeListener(HtmlAttributeChangeListener listener)
Adds an HtmlAttributeChangeListener to the listener list. The listener is registered for all attributes of this HtmlElement, as well as descendant elements.- Parameters:
listener- the attribute change listener to be added- See Also:
removeHtmlAttributeChangeListener(HtmlAttributeChangeListener)
-
removeHtmlAttributeChangeListener
public void removeHtmlAttributeChangeListener(HtmlAttributeChangeListener listener)
Removes an HtmlAttributeChangeListener from the listener list. This method should be used to remove HtmlAttributeChangeListener that were registered for all attributes of this HtmlElement, as well as descendant elements.- Parameters:
listener- the attribute change listener to be removed- See Also:
addHtmlAttributeChangeListener(HtmlAttributeChangeListener)
-
checkChildHierarchy
protected void checkChildHierarchy(org.w3c.dom.Node childNode) throws org.w3c.dom.DOMExceptionCheck for insertion errors for a new child node. This is overridden by derived classes to enforce which types of children are allowed.- Overrides:
checkChildHierarchyin classDomNode- Parameters:
childNode- the new child node that is being inserted below this node- Throws:
org.w3c.dom.DOMException- HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not allow children of the type of the newChild node, or if the node to insert is one of this node's ancestors or this node itself, or if this node is of type Document and the DOM application attempts to insert a second DocumentType or Element node. WRONG_DOCUMENT_ERR: Raised if newChild was created from a different document than the one that created this node.
-
isAttributeCaseSensitive
protected boolean isAttributeCaseSensitive()
Indicates if the attribute names are case sensitive.- Overrides:
isAttributeCaseSensitivein classDomElement- Returns:
false
-
getLangAttribute
public final java.lang.String getLangAttribute()
Returns the value of the attributelang. Refer to the HTML 4.01 documentation for details on the use of this attribute.- Returns:
- the value of the attribute
langor an empty string if that attribute isn't defined
-
getXmlLangAttribute
public final java.lang.String getXmlLangAttribute()
Returns the value of the attributexml:lang. Refer to the HTML 4.01 documentation for details on the use of this attribute.- Returns:
- the value of the attribute
xml:langor an empty string if that attribute isn't defined
-
getTextDirectionAttribute
public final java.lang.String getTextDirectionAttribute()
Returns the value of the attributedir. Refer to the HTML 4.01 documentation for details on the use of this attribute.- Returns:
- the value of the attribute
diror an empty string if that attribute isn't defined
-
getOnClickAttribute
public final java.lang.String getOnClickAttribute()
Returns the value of the attributeonclick. Refer to the HTML 4.01 documentation for details on the use of this attribute.- Returns:
- the value of the attribute
onclickor an empty string if that attribute isn't defined
-
getOnDblClickAttribute
public final java.lang.String getOnDblClickAttribute()
Returns the value of the attributeondblclick. Refer to the HTML 4.01 documentation for details on the use of this attribute.- Returns:
- the value of the attribute
ondblclickor an empty string if that attribute isn't defined
-
getOnMouseDownAttribute
public final java.lang.String getOnMouseDownAttribute()
Returns the value of the attributeonmousedown. Refer to the HTML 4.01 documentation for details on the use of this attribute.- Returns:
- the value of the attribute
onmousedownor an empty string if that attribute isn't defined
-
getOnMouseUpAttribute
public final java.lang.String getOnMouseUpAttribute()
Returns the value of the attributeonmouseup. Refer to the HTML 4.01 documentation for details on the use of this attribute.- Returns:
- the value of the attribute
onmouseupor an empty string if that attribute isn't defined
-
getOnMouseOverAttribute
public final java.lang.String getOnMouseOverAttribute()
Returns the value of the attributeonmouseover. Refer to the HTML 4.01 documentation for details on the use of this attribute.- Returns:
- the value of the attribute
onmouseoveror an empty string if that attribute isn't defined
-
getOnMouseMoveAttribute
public final java.lang.String getOnMouseMoveAttribute()
Returns the value of the attributeonmousemove. Refer to the HTML 4.01 documentation for details on the use of this attribute.- Returns:
- the value of the attribute
onmousemoveor an empty string if that attribute isn't defined
-
getOnMouseOutAttribute
public final java.lang.String getOnMouseOutAttribute()
Returns the value of the attributeonmouseout. Refer to the HTML 4.01 documentation for details on the use of this attribute.- Returns:
- the value of the attribute
onmouseoutor an empty string if that attribute isn't defined
-
getOnKeyPressAttribute
public final java.lang.String getOnKeyPressAttribute()
Returns the value of the attributeonkeypress. Refer to the HTML 4.01 documentation for details on the use of this attribute.- Returns:
- the value of the attribute
onkeypressor an empty string if that attribute isn't defined
-
getOnKeyDownAttribute
public final java.lang.String getOnKeyDownAttribute()
Returns the value of the attributeonkeydown. Refer to the HTML 4.01 documentation for details on the use of this attribute.- Returns:
- the value of the attribute
onkeydownor an empty string if that attribute isn't defined
-
getOnKeyUpAttribute
public final java.lang.String getOnKeyUpAttribute()
Returns the value of the attributeonkeyup. Refer to the HTML 4.01 documentation for details on the use of this attribute.- Returns:
- the value of the attribute
onkeyupor an empty string if that attribute isn't defined
-
getCanonicalXPath
public java.lang.String getCanonicalXPath()
Returns the canonical XPath expression which identifies this node, for instance
"/html/body/table[3]/tbody/tr[5]/td[2]/span/a[3]".WARNING: This sort of automated XPath expression is often quite bad at identifying a node, as it is highly sensitive to changes in the DOM tree.
- Overrides:
getCanonicalXPathin classDomNode- Returns:
- the canonical XPath expression which identifies this node
- See Also:
DomNode.getByXPath(String)
-
isHidden
public boolean isHidden()
- Returns:
- true if the hidden attribute is set.
-
isDisplayed
public boolean isDisplayed()
Returns
trueif this node is displayed and can be visible to the user (ignoring screen size, scrolling limitations, color, font-size, or overlapping nodes).NOTE: If CSS is
Overwritten to support the hidden attribute (html5).disabled, this method does not take this element's style into consideration!- Overrides:
isDisplayedin classDomNode- Returns:
trueif the node is visible to the user,falseotherwise- See Also:
- CSS2 Visibility,
CSS2 Display,
MSDN Documentation,
DomNode.mayBeDisplayed()
-
getDefaultStyleDisplay
public HtmlElement.DisplayStyle getDefaultStyleDisplay()
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Returns the default display style.- Returns:
- the default display style
-
getSrcAttributeNormalized
protected final java.lang.String getSrcAttributeNormalized()
Helper for src retrieval and normalization.- Returns:
- the value of the attribute
srcwith all line breaks removed or an empty string if that attribute isn't defined.
-
detach
protected void detach()
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Detach this node from all relationships with other nodes. This is the first step of a move.
-
handles
public boolean handles(org.htmlunit.javascript.host.event.Event event)
Indicates if the provided event can be applied to this node. Overwrite this.
-
isShiftPressed
protected boolean isShiftPressed()
Returns whether theSHIFTis currently pressed.- Returns:
- whether the
SHIFTis currently pressed
-
isCtrlPressed
public boolean isCtrlPressed()
Returns whether theCTRLis currently pressed.- Returns:
- whether the
CTRLis currently pressed
-
isAltPressed
public boolean isAltPressed()
Returns whether theALTis currently pressed.- Returns:
- whether the
ALTis currently pressed
-
isValid
public boolean isValid()
Returns whether this element satisfies all form validation constraints set.- Returns:
- whether this element satisfies all form validation constraints set
-
isRequiredSupported
protected boolean isRequiredSupported()
Returns whether this element supports therequiredconstraint.- Returns:
- whether this element supports the
requiredconstraint
-
isRequired
public boolean isRequired()
- Returns:
- the true if the required attribute is set
-
isOptional
public boolean isOptional()
- Returns:
- the true if the required attribute is supported and set
-
setRequired
public void setRequired(boolean required)
Sets therequiredattribute.- Parameters:
required- the new attribute value
-
cloneNode
public DomNode cloneNode(boolean deep)
- Specified by:
cloneNodein interfaceorg.w3c.dom.Node- Overrides:
cloneNodein classDomElement
-
-