|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.gargoylesoftware.htmlunit.html.DomNode
public abstract class DomNode
Base class for nodes in the HTML DOM tree. This class is modeled after the W3C DOM specification, but does not implement it.
| Nested Class Summary | |
|---|---|
protected class |
DomNode.ChildIterator
An iterator over all children of this node. |
protected class |
DomNode.DescendantElementsIterator
An iterator over all HtmlElement descendants in document order. |
| Field Summary | |
|---|---|
protected static java.lang.String |
AS_TEXT_BLANK
Indicates a non blank that can't be trimmed or reduced. |
protected static java.lang.String |
AS_TEXT_BLOCK_SEPARATOR
Indicates a block. |
protected static java.lang.String |
AS_TEXT_NEW_LINE
Indicates a new line. |
protected static java.lang.String |
AS_TEXT_TAB
Indicates a tab. |
static java.lang.String |
PROPERTY_ELEMENT
The name of the "element" property. |
static java.lang.String |
READY_STATE_COMPLETE
A ready state constant for IE (state 5). |
static java.lang.String |
READY_STATE_INTERACTIVE
A ready state constant for IE (state 4). |
static java.lang.String |
READY_STATE_LOADED
A ready state constant for IE (state 3). |
static java.lang.String |
READY_STATE_LOADING
A ready state constant for IE (state 2). |
static java.lang.String |
READY_STATE_UNINITIALIZED
A ready state constant for IE (state 1). |
| 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 | |
|---|---|
protected |
DomNode()
Deprecated. |
protected |
DomNode(SgmlPage page)
Creates a new instance. |
| Method Summary | ||
|---|---|---|
void |
addDomChangeListener(DomChangeListener listener)
Adds a DomChangeListener to the listener list. |
|
DomNode |
appendChild(org.w3c.dom.Node node)
|
|
java.lang.String |
asText()
Returns a textual representation of this element that represents what would be visible to the user if this page was shown in a web browser. |
|
java.lang.String |
asXml()
Returns a string representation of the XML document from this element and all it's children (recursively). |
|
protected void |
checkChildHierarchy(org.w3c.dom.Node newChild)
Check for insertion errors for a new child node. |
|
DomNode |
cloneNode(boolean deep)
|
|
short |
compareDocumentPosition(org.w3c.dom.Node other)
|
|
protected void |
fireNodeAdded(DomNode parentNode,
DomNode addedNode)
Support for reporting DOM changes. |
|
protected void |
fireNodeDeleted(DomNode parentNode,
DomNode deletedNode)
Support for reporting DOM changes. |
|
java.lang.Iterable<HtmlElement> |
getAllHtmlChildElements()
Returns an Iterable that will recursively iterate over all of this node's descendants. |
|
protected java.util.List<org.w3c.dom.Node> |
getAncestors(boolean includeSelf)
Gets the ancestors of the node. |
|
org.w3c.dom.NamedNodeMap |
getAttributes()
|
|
java.lang.String |
getBaseURI()
Not yet implemented. |
|
|
getByXPath(java.lang.String xpathExpr)
Evaluates the specified XPath expression from this node, returning the matching elements. |
|
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]". |
|
DomNodeList<DomNode> |
getChildNodes()
|
|
java.lang.Iterable<DomNode> |
getChildren()
|
|
int |
getEndColumnNumber()
Returns the column number in the source page where the DOM node ends. |
|
int |
getEndLineNumber()
Returns the line number in the source page where the DOM node ends. |
|
java.lang.Object |
getFeature(java.lang.String feature,
java.lang.String version)
Not yet implemented. |
|
|
getFirstByXPath(java.lang.String xpathExpr)
Evaluates the specified XPath expression from this node, returning the first matching element, or null if no node matches the specified XPath expression. |
|
DomNode |
getFirstChild()
|
|
DomNode |
getLastChild()
|
|
java.lang.String |
getLocalName()
|
|
java.lang.String |
getNamespaceURI()
|
|
DomNode |
getNextSibling()
|
|
abstract java.lang.String |
getNodeName()
Returns this node's node name. |
|
abstract short |
getNodeType()
Returns this node's node type. |
|
java.lang.String |
getNodeValue()
|
|
org.w3c.dom.Document |
getOwnerDocument()
|
|
SgmlPage |
getPage()
Returns the page that contains this node. |
|
DomNode |
getParentNode()
|
|
java.lang.String |
getPrefix()
|
|
DomNode |
getPreviousSibling()
|
|
java.lang.String |
getReadyState()
Returns this node's ready state (IE only). |
|
net.sourceforge.htmlunit.corejs.javascript.ScriptableObject |
getScriptObject()
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK. Returns the JavaScript object that corresponds to this node, lazily initializing a new one if necessary. |
|
int |
getStartColumnNumber()
Returns the column number in the source page where the DOM node starts. |
|
int |
getStartLineNumber()
Returns the line number in the source page where the DOM node starts. |
|
java.lang.String |
getTextContent()
|
|
java.lang.Object |
getUserData(java.lang.String key)
Not yet implemented. |
|
boolean |
hasAttributes()
|
|
boolean |
hasChildNodes()
|
|
void |
insertBefore(DomNode newNode)
Inserts a new child node before this node into the child relationship this node is a part of. |
|
org.w3c.dom.Node |
insertBefore(org.w3c.dom.Node newChild,
org.w3c.dom.Node refChild)
|
|
boolean |
isAncestorOf(DomNode node)
Returns true if this node is an ancestor of the specified node. |
|
protected boolean |
isBlock()
Indicates if the text representation of this element is made as a block, ie if new lines need to be inserted before and after it. |
|
boolean |
isDefaultNamespace(java.lang.String namespaceURI)
Not yet implemented. |
|
boolean |
isDisplayed()
Returns true if this node is displayed and can be visible to the user (ignoring screen size, scrolling limitations, color, font-size, or overlapping nodes). |
|
boolean |
isEqualNode(org.w3c.dom.Node arg)
Not yet implemented. |
|
boolean |
isSameNode(org.w3c.dom.Node other)
|
|
boolean |
isSupported(java.lang.String namespace,
java.lang.String featureName)
Not yet implemented. |
|
protected boolean |
isTrimmedText()
Returns a flag indicating whether or not this node should have any leading and trailing whitespace removed when asText() is called. |
|
java.lang.String |
lookupNamespaceURI(java.lang.String prefix)
Not yet implemented. |
|
java.lang.String |
lookupPrefix(java.lang.String namespaceURI)
Not yet implemented. |
|
void |
normalize()
|
|
protected void |
notifyIncorrectness(java.lang.String message)
Notifies the registered IncorrectnessListener of something that is not fully correct. |
|
protected void |
onAddedToPage()
Lifecycle method invoked whenever a node is added to a page. |
|
protected void |
onAllChildrenAddedToPage(boolean postponed)
Lifecycle method invoked after a node and all its children have been added to a page, during parsing of the HTML. |
|
protected void |
printChildrenAsXml(java.lang.String indent,
java.io.PrintWriter printWriter)
Recursively writes the XML data for the node tree starting at node. |
|
protected void |
printXml(java.lang.String indent,
java.io.PrintWriter printWriter)
Recursively writes the XML data for the node tree starting at node. |
|
void |
remove()
Removes this node from all relationships with other nodes. |
|
void |
removeAllChildren()
Removes all of this node's children. |
|
org.w3c.dom.Node |
removeChild(org.w3c.dom.Node child)
|
|
void |
removeDomChangeListener(DomChangeListener listener)
Removes a DomChangeListener from the listener list. |
|
void |
replace(DomNode newNode)
Replaces this node with another node. |
|
org.w3c.dom.Node |
replaceChild(org.w3c.dom.Node newChild,
org.w3c.dom.Node oldChild)
|
|
|
selectNodes(java.lang.String xpathExpr)
|
|
|
selectSingleNode(java.lang.String xpathExpr)
|
|
protected void |
setNextSibling(DomNode next)
|
|
void |
setNodeValue(java.lang.String x)
|
|
protected void |
setParentNode(DomNode parent)
Sets the parent node. |
|
void |
setPrefix(java.lang.String prefix)
|
|
protected void |
setPreviousSibling(DomNode previous)
|
|
void |
setReadyState(java.lang.String state)
Sets this node's ready state (IE only). |
|
void |
setScriptObject(net.sourceforge.htmlunit.corejs.javascript.ScriptableObject scriptObject)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK. Sets the JavaScript object that corresponds to this node. |
|
void |
setTextContent(java.lang.String textContent)
|
|
java.lang.Object |
setUserData(java.lang.String key,
java.lang.Object data,
org.w3c.dom.UserDataHandler handler)
Not yet implemented. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final java.lang.String AS_TEXT_BLOCK_SEPARATOR
protected static final java.lang.String AS_TEXT_NEW_LINE
protected static final java.lang.String AS_TEXT_BLANK
protected static final java.lang.String AS_TEXT_TAB
public static final java.lang.String READY_STATE_UNINITIALIZED
public static final java.lang.String READY_STATE_LOADING
public static final java.lang.String READY_STATE_LOADED
public static final java.lang.String READY_STATE_INTERACTIVE
public static final java.lang.String READY_STATE_COMPLETE
public static final java.lang.String PROPERTY_ELEMENT
| Constructor Detail |
|---|
@Deprecated protected DomNode()
protected DomNode(SgmlPage page)
page - the page which contains this node| Method Detail |
|---|
public int getStartLineNumber()
public int getStartColumnNumber()
public int getEndLineNumber()
public int getEndColumnNumber()
public SgmlPage getPage()
public org.w3c.dom.Document getOwnerDocument()
getOwnerDocument in interface org.w3c.dom.Nodepublic void setScriptObject(net.sourceforge.htmlunit.corejs.javascript.ScriptableObject scriptObject)
scriptObject - the JavaScript objectpublic DomNode getLastChild()
getLastChild in interface org.w3c.dom.Nodepublic DomNode getParentNode()
getParentNode in interface org.w3c.dom.Nodeprotected void setParentNode(DomNode parent)
parent - the parent nodepublic DomNode getPreviousSibling()
getPreviousSibling in interface org.w3c.dom.Nodepublic DomNode getNextSibling()
getNextSibling in interface org.w3c.dom.Nodepublic DomNode getFirstChild()
getFirstChild in interface org.w3c.dom.Nodepublic boolean isAncestorOf(DomNode node)
node - the node to check
protected void setPreviousSibling(DomNode previous)
previous - set the previousSibling field valueprotected void setNextSibling(DomNode next)
next - set the nextSibling field valuepublic abstract short getNodeType()
getNodeType in interface org.w3c.dom.Nodepublic abstract java.lang.String getNodeName()
getNodeName in interface org.w3c.dom.Nodepublic java.lang.String getNamespaceURI()
getNamespaceURI in interface org.w3c.dom.Nodepublic java.lang.String getLocalName()
getLocalName in interface org.w3c.dom.Nodepublic java.lang.String getPrefix()
getPrefix in interface org.w3c.dom.Nodepublic void setPrefix(java.lang.String prefix)
setPrefix in interface org.w3c.dom.Nodepublic boolean hasChildNodes()
hasChildNodes in interface org.w3c.dom.Nodepublic DomNodeList<DomNode> getChildNodes()
getChildNodes in interface org.w3c.dom.Node
public boolean isSupported(java.lang.String namespace,
java.lang.String featureName)
isSupported in interface org.w3c.dom.Nodepublic void normalize()
normalize in interface org.w3c.dom.Nodepublic java.lang.String getBaseURI()
getBaseURI in interface org.w3c.dom.Nodepublic short compareDocumentPosition(org.w3c.dom.Node other)
compareDocumentPosition in interface org.w3c.dom.Nodeprotected java.util.List<org.w3c.dom.Node> getAncestors(boolean includeSelf)
includeSelf - should this node be returned too
public java.lang.String getTextContent()
getTextContent in interface org.w3c.dom.Nodepublic void setTextContent(java.lang.String textContent)
setTextContent in interface org.w3c.dom.Nodepublic boolean isSameNode(org.w3c.dom.Node other)
isSameNode in interface org.w3c.dom.Nodepublic java.lang.String lookupPrefix(java.lang.String namespaceURI)
lookupPrefix in interface org.w3c.dom.Nodepublic boolean isDefaultNamespace(java.lang.String namespaceURI)
isDefaultNamespace in interface org.w3c.dom.Nodepublic java.lang.String lookupNamespaceURI(java.lang.String prefix)
lookupNamespaceURI in interface org.w3c.dom.Nodepublic boolean isEqualNode(org.w3c.dom.Node arg)
isEqualNode in interface org.w3c.dom.Node
public java.lang.Object getFeature(java.lang.String feature,
java.lang.String version)
getFeature in interface org.w3c.dom.Nodepublic java.lang.Object getUserData(java.lang.String key)
getUserData in interface org.w3c.dom.Node
public java.lang.Object setUserData(java.lang.String key,
java.lang.Object data,
org.w3c.dom.UserDataHandler handler)
setUserData in interface org.w3c.dom.Nodepublic boolean hasAttributes()
hasAttributes in interface org.w3c.dom.Nodeprotected boolean isTrimmedText()
asText() is called. This method should usually return
true, but must return false for such things as text formatting tags.
asText() is calledpublic boolean isDisplayed()
public java.lang.String asText()
protected boolean isBlock()
true if this element represents a blockpublic java.lang.String asXml()
protected void printXml(java.lang.String indent,
java.io.PrintWriter printWriter)
node.
indent - white space to indent child nodesprintWriter - writer where child nodes are written
protected void printChildrenAsXml(java.lang.String indent,
java.io.PrintWriter printWriter)
node.
indent - white space to indent child nodesprintWriter - writer where child nodes are writtenpublic java.lang.String getNodeValue()
getNodeValue in interface org.w3c.dom.Nodepublic void setNodeValue(java.lang.String x)
setNodeValue in interface org.w3c.dom.Nodepublic DomNode cloneNode(boolean deep)
cloneNode in interface org.w3c.dom.Nodepublic net.sourceforge.htmlunit.corejs.javascript.ScriptableObject getScriptObject()
public DomNode appendChild(org.w3c.dom.Node node)
appendChild in interface org.w3c.dom.Node
protected void checkChildHierarchy(org.w3c.dom.Node newChild)
throws org.w3c.dom.DOMException
newChild - the new child node that is being inserted below this node
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.
public org.w3c.dom.Node insertBefore(org.w3c.dom.Node newChild,
org.w3c.dom.Node refChild)
insertBefore in interface org.w3c.dom.Node
public void insertBefore(DomNode newNode)
throws java.lang.IllegalStateException
newNode - the new node to insert
java.lang.IllegalStateException - if this node is not a child of any other nodepublic org.w3c.dom.NamedNodeMap getAttributes()
getAttributes in interface org.w3c.dom.Nodepublic org.w3c.dom.Node removeChild(org.w3c.dom.Node child)
removeChild in interface org.w3c.dom.Nodepublic void remove()
public org.w3c.dom.Node replaceChild(org.w3c.dom.Node newChild,
org.w3c.dom.Node oldChild)
replaceChild in interface org.w3c.dom.Node
public void replace(DomNode newNode)
throws java.lang.IllegalStateException
newNode - the node to replace this one
java.lang.IllegalStateException - if this node is not a child of any other nodeprotected void onAddedToPage()
protected void onAllChildrenAddedToPage(boolean postponed)
postponed - whether to use PostponedAction or nopublic final java.lang.Iterable<DomNode> getChildren()
public final java.lang.Iterable<HtmlElement> getAllHtmlChildElements()
Iterable that will recursively iterate over all of this node's descendants.
Iterable that will recursively iterate over all of this node's descendantspublic java.lang.String getReadyState()
public void setReadyState(java.lang.String state)
state - this node's ready statepublic void removeAllChildren()
public <E> java.util.List<E> getByXPath(java.lang.String xpathExpr)
xpathExpr - the XPath expression to evaluate
getFirstByXPath(String),
getCanonicalXPath()public <E> java.util.List<E> selectNodes(java.lang.String xpathExpr)
public <X> X getFirstByXPath(java.lang.String xpathExpr)
X - the expression typexpathExpr - the XPath expression
getByXPath(String),
getCanonicalXPath()public <X> X selectSingleNode(java.lang.String xpathExpr)
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.
getByXPath(String)protected void notifyIncorrectness(java.lang.String message)
IncorrectnessListener of something that is not fully correct.
message - the notification to send to the registered IncorrectnessListenerpublic void addDomChangeListener(DomChangeListener listener)
DomChangeListener to the listener list. The listener is registered for
all descendants of this node.
listener - the DOM structure change listener to be addedremoveDomChangeListener(DomChangeListener)public void removeDomChangeListener(DomChangeListener listener)
DomChangeListener from the listener list. The listener is deregistered for
all descendants of this node.
listener - the DOM structure change listener to be removedaddDomChangeListener(DomChangeListener)
protected void fireNodeAdded(DomNode parentNode,
DomNode addedNode)
DomChangeEvent to any registered DomChangeListeners.
Note that this method recursively calls this node's parent's fireNodeAdded(DomNode, DomNode).
parentNode - the parent of the node that was addedaddedNode - the node that was added
protected void fireNodeDeleted(DomNode parentNode,
DomNode deletedNode)
DomChangeEvent to any registered DomChangeListeners.
Note that this method recursively calls this node's parent's fireNodeDeleted(DomNode, DomNode).
parentNode - the parent of the node that was deleteddeletedNode - the node that was deleted
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||