public class DomElement extends DomNamespaceNode implements Element, ElementTraversal
| Modifier and Type | Class and Description |
|---|---|
protected static class |
DomElement.ChildElementsIterator
An iterator over the DomElement children.
|
DomNode.ChildIterator, DomNode.DescendantElementsIterator<T extends DomNode>| Modifier and Type | Field and Description |
|---|---|
static String |
ATTRIBUTE_NOT_DEFINED
Constant meaning that the specified attribute was not defined.
|
static String |
ATTRIBUTE_VALUE_EMPTY
Constant meaning that the specified attribute was found but its value was empty.
|
AS_TEXT_BLANK, AS_TEXT_BLOCK_SEPARATOR, AS_TEXT_NEW_LINE, AS_TEXT_TAB, PROPERTY_ELEMENT, READY_STATE_COMPLETE, READY_STATE_INTERACTIVE, READY_STATE_LOADED, READY_STATE_LOADING, READY_STATE_UNINITIALIZEDATTRIBUTE_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 and Description |
|---|
DomElement(String namespaceURI,
String qualifiedName,
SgmlPage page,
Map<String,DomAttr> attributes)
Creates an instance of a DOM element that can have a namespace.
|
| Modifier and Type | Method and Description |
|---|---|
void |
blur()
Removes focus from this element.
|
<P extends Page> |
click()
Simulates clicking on this element, returning the page in the window that has the focus
after the element has been clicked.
|
<P extends Page> |
click(boolean shiftKey,
boolean ctrlKey,
boolean altKey)
Simulates clicking on this element, returning the page in the window that has the focus
after the element has been clicked.
|
<P extends Page> |
click(Event event)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Simulates clicking on this element, returning the page in the window that has the focus after the element has been clicked. |
DomNode |
cloneNode(boolean deep) |
<P extends Page> |
dblClick()
Simulates double-clicking on this element, returning the page in the window that has the focus
after the element has been clicked.
|
<P extends Page> |
dblClick(boolean shiftKey,
boolean ctrlKey,
boolean altKey)
Simulates double-clicking on this element, returning the page in the window that has the focus
after the element has been clicked.
|
protected void |
doClickFireChangeEvent()
This method implements the control onchange handler call during the click action.
|
protected ScriptResult |
doClickFireClickEvent(Event event)
This method implements the control onclick handler call during the click action.
|
protected boolean |
doClickStateUpdate()
This method implements the control state update part of the click action.
|
ScriptResult |
fireEvent(Event event)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Fires the event on the element. |
ScriptResult |
fireEvent(String eventType)
|
void |
focus()
Sets the focus on this element.
|
String |
getAttribute(String attributeName)
Returns the value of the attribute specified by name or an empty string.
|
DomAttr |
getAttributeNode(String name) |
DomAttr |
getAttributeNodeNS(String namespaceURI,
String localName) |
String |
getAttributeNS(String namespaceURI,
String localName)
Returns the value of the attribute specified by namespace and local name or an empty
string.
|
NamedNodeMap |
getAttributes() |
Map<String,DomAttr> |
getAttributesMap()
Returns the map holding the attributes, keyed by name.
|
int |
getChildElementCount() |
Iterable<DomElement> |
getChildElements() |
DomNodeList<HtmlElement> |
getElementsByTagName(String tagName) |
DomNodeList<HtmlElement> |
getElementsByTagNameNS(String namespace,
String localName)
Not yet implemented.
|
protected DomNode |
getEventTargetElement()
Returns the event target element.
|
DomElement |
getFirstElementChild() |
String |
getId() |
DomElement |
getLastElementChild() |
DomElement |
getNextElementSibling() |
String |
getNodeName()
Returns this node's node name.
|
short |
getNodeType()
Returns this node's node type.
|
DomElement |
getPreviousElementSibling() |
TypeInfo |
getSchemaTypeInfo()
Not yet implemented.
|
String |
getTagName()
Returns the tag name of this element.
|
boolean |
hasAttribute(String attributeName)
Returns whether the attribute specified by name has a value.
|
boolean |
hasAttributeNS(String namespaceURI,
String localName)
Returns whether the attribute specified by namespace and local name has a value.
|
boolean |
hasAttributes() |
protected boolean |
isAttributeCaseSensitive()
Indicates if the attribute names are case sensitive.
|
protected boolean |
isEmptyXmlTagExpanded()
Indicates if a node without children should be written in expanded form as XML
(i.e.
|
boolean |
isMouseOver()
Returns whether the Mouse is currently over this element or not.
|
protected boolean |
isStateUpdateFirst()
Returns
true if state updates should be done before onclick event handling. |
Page |
mouseDown()
Simulates clicking the mouse on this element, returning the page which this element's window contains
after the mouse click.
|
Page |
mouseDown(boolean shiftKey,
boolean ctrlKey,
boolean altKey,
int button)
Simulates clicking the mouse on this element, returning the page which this element's window contains
after the mouse click.
|
Page |
mouseMove()
Simulates moving the mouse over this element, returning the page which this element's window contains
after the mouse move.
|
Page |
mouseMove(boolean shiftKey,
boolean ctrlKey,
boolean altKey,
int button)
Simulates moving the mouse over this element, returning the page which this element's window contains
after the mouse move.
|
Page |
mouseOut()
Simulates moving the mouse out of this element, returning the page which this element's window contains
after the mouse move.
|
Page |
mouseOut(boolean shiftKey,
boolean ctrlKey,
boolean altKey,
int button)
Simulates moving the mouse out of this element, returning the page which this element's window contains
after the mouse move.
|
Page |
mouseOver()
Simulates moving the mouse over this element, returning the page which this element's window contains
after the mouse move.
|
Page |
mouseOver(boolean shiftKey,
boolean ctrlKey,
boolean altKey,
int button)
Simulates moving the mouse over this element, returning the page which this element's window contains
after the mouse move.
|
Page |
mouseUp()
Simulates releasing the mouse click on this element, returning the page which this element's window contains
after the mouse click release.
|
Page |
mouseUp(boolean shiftKey,
boolean ctrlKey,
boolean altKey,
int button)
Simulates releasing the mouse click on this element, returning the page which this element's window contains
after the mouse click release.
|
protected Map<String,String> |
namespaces()
Returns namespaces.
|
protected void |
preventDefault()
This method is called if the current fired event is canceled by preventDefault() in FireFox,
or by returning
false in Internet Explorer. |
protected void |
printOpeningTagContentAsXml(PrintWriter printWriter)
Prints the content between "<" and ">" (or "/>") in the output of the tag name
and its attributes in XML format.
|
protected void |
printXml(String indent,
PrintWriter printWriter)
Recursively write the XML data for the node tree starting at
node. |
protected boolean |
propagateClickStateUpdateToParent() |
void |
removeAttribute(String attributeName)
Removes an attribute specified by name from this element.
|
Attr |
removeAttributeNode(Attr attribute)
Not yet implemented.
|
void |
removeAttributeNS(String namespaceURI,
String localName)
Removes an attribute specified by namespace and local name from this element.
|
void |
removeFocus()
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Gets notified that it has lost the focus. |
Page |
rightClick()
Simulates right clicking the mouse on this element, returning the page which this element's window
contains after the mouse click.
|
Page |
rightClick(boolean shiftKey,
boolean ctrlKey,
boolean altKey)
Simulates right clicking the mouse on this element, returning the page which this element's window
contains after the mouse click.
|
void |
setAttribute(String attributeName,
String attributeValue)
Sets the value of the attribute specified by name.
|
Attr |
setAttributeNode(Attr attribute) |
Attr |
setAttributeNodeNS(Attr attribute)
Not yet implemented.
|
void |
setAttributeNS(String namespaceURI,
String qualifiedName,
String attributeValue)
Sets the value of the attribute specified by namespace and qualified name.
|
void |
setIdAttribute(String name,
boolean isId)
Not yet implemented.
|
void |
setIdAttributeNode(Attr idAttr,
boolean isId)
Not yet implemented.
|
void |
setIdAttributeNS(String namespaceURI,
String localName,
boolean isId)
Not yet implemented.
|
String |
toString()
Returns a string representation of this element.
|
getLocalName, getNamespaceURI, getPrefix, getQualifiedName, processImportNode, setPrefixaddCharacterDataChangeListener, addDomChangeListener, appendChild, asText, asXml, checkChildHierarchy, compareDocumentPosition, detach, fireCharacterDataChanged, fireNodeAdded, fireNodeDeleted, getAncestors, getBaseURI, getByXPath, getByXPath, getCanonicalXPath, getChildNodes, getChildren, getDescendants, getDomElementDescendants, getEndColumnNumber, getEndLineNumber, getFeature, getFirstByXPath, getFirstByXPath, getFirstChild, getHtmlElementDescendants, getHtmlPageOrNull, getIndex, getLastChild, getNextSibling, getNodeValue, getOwnerDocument, getPage, getParentNode, getPreviousSibling, getReadyState, getScriptableObject, getStartColumnNumber, getStartLineNumber, getTextContent, getUserData, handles, hasChildNodes, hasFeature, insertBefore, insertBefore, isAncestorOf, isAncestorOfAny, isAttachedToPage, isDefaultNamespace, isDisplayed, isEqualNode, isSameNode, isSupported, isTrimmedText, lookupNamespaceURI, lookupPrefix, mayBeDisplayed, normalize, notifyIncorrectness, onAddedToDocumentFragment, onAddedToPage, onAllChildrenAddedToPage, printChildrenAsXml, querySelector, querySelectorAll, remove, removeAllChildren, removeCharacterDataChangeListener, removeChild, removeDomChangeListener, replace, replaceChild, setNextSibling, setNodeValue, setParentNode, setPreviousSibling, setReadyState, setScriptableObject, setTextContent, setUserDataclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitappendChild, 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, setNodeValue, setPrefix, setTextContent, setUserDatapublic static final String ATTRIBUTE_NOT_DEFINED
public static final String ATTRIBUTE_VALUE_EMPTY
public DomElement(String namespaceURI, String qualifiedName, SgmlPage page, Map<String,DomAttr> attributes)
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, or
null. The map will be stored as is, not copied.public String getNodeName()
getNodeName in interface NodegetNodeName in class DomNodepublic final short getNodeType()
getNodeType in interface NodegetNodeType in class DomNodepublic final String getTagName()
getTagName in interface Elementpublic final boolean hasAttributes()
hasAttributes in interface NodehasAttributes in class DomNodepublic boolean hasAttribute(String attributeName)
hasAttribute in interface ElementattributeName - the name of the attributeprotected void printOpeningTagContentAsXml(PrintWriter printWriter)
printWriter - the writer to print inprotected void printXml(String indent, PrintWriter printWriter)
node.protected boolean isEmptyXmlTagExpanded()
false by defaultpublic String getAttribute(String attributeName)
ATTRIBUTE_NOT_DEFINED
if the attribute wasn't specified or ATTRIBUTE_VALUE_EMPTY if the
attribute was specified but it was empty.getAttribute in interface ElementattributeName - the name of the attributeATTRIBUTE_NOT_DEFINED or ATTRIBUTE_VALUE_EMPTYpublic void removeAttribute(String attributeName)
removeAttribute in interface ElementattributeName - the attribute attributeNamepublic final void removeAttributeNS(String namespaceURI, String localName)
removeAttributeNS in interface ElementnamespaceURI - the URI that identifies an XML namespacelocalName - the name within the namespacepublic final Attr removeAttributeNode(Attr attribute)
removeAttributeNode in interface Elementpublic final boolean hasAttributeNS(String namespaceURI, String localName)
hasAttributeNS in interface ElementnamespaceURI - the URI that identifies an XML namespacelocalName - the name within the namespacepublic final Map<String,DomAttr> getAttributesMap()
public NamedNodeMap getAttributes()
getAttributes in interface NodegetAttributes in class DomNodepublic final void setAttribute(String attributeName, String attributeValue)
setAttribute in interface ElementattributeName - the name of the attributeattributeValue - the value of the attributepublic void setAttributeNS(String namespaceURI, String qualifiedName, String attributeValue)
setAttributeNS in interface ElementnamespaceURI - the URI that identifies an XML namespacequalifiedName - the qualified name (prefix:local) of the attributeattributeValue - the value of the attributeprotected boolean isAttributeCaseSensitive()
truepublic final String getAttributeNS(String namespaceURI, String localName)
ATTRIBUTE_NOT_DEFINED
if the attribute wasn't specified or ATTRIBUTE_VALUE_EMPTY if the
attribute was specified but it was empty.getAttributeNS in interface ElementnamespaceURI - the URI that identifies an XML namespacelocalName - the name within the namespaceATTRIBUTE_NOT_DEFINED or ATTRIBUTE_VALUE_EMPTYpublic DomAttr getAttributeNode(String name)
getAttributeNode in interface Elementpublic DomAttr getAttributeNodeNS(String namespaceURI, String localName)
getAttributeNodeNS in interface Elementpublic DomNodeList<HtmlElement> getElementsByTagName(String tagName)
getElementsByTagName in interface Elementpublic DomNodeList<HtmlElement> getElementsByTagNameNS(String namespace, String localName)
getElementsByTagNameNS in interface Elementpublic TypeInfo getSchemaTypeInfo()
getSchemaTypeInfo in interface Elementpublic void setIdAttribute(String name, boolean isId)
setIdAttribute in interface Elementpublic void setIdAttributeNS(String namespaceURI, String localName, boolean isId)
setIdAttributeNS in interface Elementpublic Attr setAttributeNode(Attr attribute)
setAttributeNode in interface Elementpublic Attr setAttributeNodeNS(Attr attribute)
setAttributeNodeNS in interface Elementpublic final void setIdAttributeNode(Attr idAttr, boolean isId)
setIdAttributeNode in interface Elementpublic DomNode cloneNode(boolean deep)
public final String getId()
public DomElement getFirstElementChild()
getFirstElementChild in interface ElementTraversalpublic DomElement getLastElementChild()
getLastElementChild in interface ElementTraversalpublic DomElement getPreviousElementSibling()
getPreviousElementSibling in interface ElementTraversalpublic DomElement getNextElementSibling()
getNextElementSibling in interface ElementTraversalpublic int getChildElementCount()
getChildElementCount in interface ElementTraversalpublic final Iterable<DomElement> getChildElements()
public String toString()
public <P extends Page> P click() throws IOException
P - the page typeWebClient.getCurrentWindow()IOException - if an IO error occurspublic <P extends Page> P click(boolean shiftKey, boolean ctrlKey, boolean altKey) throws IOException
P - the page typeshiftKey - true if SHIFT is pressed during the clickctrlKey - true if CTRL is pressed during the clickaltKey - true if ALT is pressed during the clickWebClient.getCurrentWindow()IOException - if an IO error occursprotected DomNode getEventTargetElement()
public <P extends Page> P click(Event event) throws IOException
P - the page typeevent - the click event usedWebClient.getCurrentWindow()IOException - if an IO error occursprotected boolean doClickStateUpdate()
throws IOException
The default implementation only calls doClickStateUpdate on parent's HtmlElement (if any).
Subclasses requiring different behavior (like HtmlSubmitInput) will override this method.
IOException - if an IO error occursprotected boolean propagateClickStateUpdateToParent()
Usually the click is propagated to the parent. Overwrite if you
like to disable this.protected void doClickFireChangeEvent()
protected ScriptResult doClickFireClickEvent(Event event)
event - the click event usedpublic <P extends Page> P dblClick() throws IOException
click() is automatically called first.P - the page typeIOException - if an IO error occurspublic <P extends Page> P dblClick(boolean shiftKey, boolean ctrlKey, boolean altKey) throws IOException
click(boolean, boolean, boolean) is automatically
called first.P - the page typeshiftKey - true if SHIFT is pressed during the double-clickctrlKey - true if CTRL is pressed during the double-clickaltKey - true if ALT is pressed during the double-clickIOException - if an IO error occurspublic Page mouseOver()
public Page mouseOver(boolean shiftKey, boolean ctrlKey, boolean altKey, int button)
shiftKey - true if SHIFT is pressed during the mouse movectrlKey - true if CTRL is pressed during the mouse movealtKey - true if ALT is pressed during the mouse movebutton - the button code, must be MouseEvent.BUTTON_LEFT, MouseEvent.BUTTON_MIDDLE
or MouseEvent.BUTTON_RIGHTpublic Page mouseMove()
public Page mouseMove(boolean shiftKey, boolean ctrlKey, boolean altKey, int button)
shiftKey - true if SHIFT is pressed during the mouse movectrlKey - true if CTRL is pressed during the mouse movealtKey - true if ALT is pressed during the mouse movebutton - the button code, must be MouseEvent.BUTTON_LEFT, MouseEvent.BUTTON_MIDDLE
or MouseEvent.BUTTON_RIGHTpublic Page mouseOut()
public Page mouseOut(boolean shiftKey, boolean ctrlKey, boolean altKey, int button)
shiftKey - true if SHIFT is pressed during the mouse movectrlKey - true if CTRL is pressed during the mouse movealtKey - true if ALT is pressed during the mouse movebutton - the button code, must be MouseEvent.BUTTON_LEFT, MouseEvent.BUTTON_MIDDLE
or MouseEvent.BUTTON_RIGHTpublic Page mouseDown()
public Page mouseDown(boolean shiftKey, boolean ctrlKey, boolean altKey, int button)
shiftKey - true if SHIFT is pressed during the mouse clickctrlKey - true if CTRL is pressed during the mouse clickaltKey - true if ALT is pressed during the mouse clickbutton - the button code, must be MouseEvent.BUTTON_LEFT, MouseEvent.BUTTON_MIDDLE
or MouseEvent.BUTTON_RIGHTpublic Page mouseUp()
public Page mouseUp(boolean shiftKey, boolean ctrlKey, boolean altKey, int button)
shiftKey - true if SHIFT is pressed during the mouse click releasectrlKey - true if CTRL is pressed during the mouse click releasealtKey - true if ALT is pressed during the mouse click releasebutton - the button code, must be MouseEvent.BUTTON_LEFT, MouseEvent.BUTTON_MIDDLE
or MouseEvent.BUTTON_RIGHTpublic Page rightClick()
public Page rightClick(boolean shiftKey, boolean ctrlKey, boolean altKey)
shiftKey - true if SHIFT is pressed during the mouse clickctrlKey - true if CTRL is pressed during the mouse clickaltKey - true if ALT is pressed during the mouse clickpublic ScriptResult fireEvent(String eventType)
eventType - the event type (like "load", "click")null if nothing is executedpublic ScriptResult fireEvent(Event event)
event - the event to firenull if nothing is executedprotected void preventDefault()
false in Internet Explorer.
The default implementation does nothing.public void focus()
public void blur()
public void removeFocus()
protected boolean isStateUpdateFirst()
true if state updates should be done before onclick event handling. This method
returns false by default, and is expected to be overridden to return true by
derived classes like HtmlCheckBoxInput.true if state updates should be done before onclick event handlingpublic boolean isMouseOver()
Copyright © 2002–2016 Gargoyle Software Inc.. All rights reserved.