|
||||||||||
| 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 | |
|---|---|
static String |
PROPERTY_ELEMENT
The name of the "element" property. |
static String |
READY_STATE_COMPLETE
A ready state constant for IE (state 5). |
static String |
READY_STATE_INTERACTIVE
A ready state constant for IE (state 4). |
static String |
READY_STATE_LOADED
A ready state constant for IE (state 3). |
static String |
READY_STATE_LOADING
A ready state constant for IE (state 2). |
static String |
READY_STATE_UNINITIALIZED
A ready state constant for IE (state 1). |
| Constructor Summary | |
|---|---|
protected |
DomNode()
Deprecated. |
protected |
DomNode(Page page)
Creates a new instance. |
| Method Summary | |
|---|---|
void |
addDomChangeListener(DomChangeListener listener)
Adds a DomChangeListener to the listener list. |
DomNode |
appendChild(Node node)
|
DomNode |
appendDomChild(DomNode node)
Deprecated. As of 2.0, please use appendChild(Node) instead. |
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. |
String |
asXml()
Returns a string representation of the XML document from this element and all it's children (recursively). |
protected void |
checkChildHierarchy(Node newChild)
Check for insertion errors for a new child node. |
DomNode |
cloneDomNode(boolean deep)
Deprecated. As of 2.0, please use cloneNode(boolean) instead. |
DomNode |
cloneNode(boolean deep)
|
short |
compareDocumentPosition(Node other)
Not yet implemented. |
protected void |
fireNodeAdded(DomNode parentNode,
DomNode addedNode)
Support for reporting DOM changes. |
protected void |
fireNodeDeleted(DomNode parentNode,
DomNode deletedNode)
Support for reporting DOM changes. |
Iterable<HtmlElement> |
getAllHtmlChildElements()
Returns an Iterable that will recursively iterate over all of this node's descendants. |
NamedNodeMap |
getAttributes()
|
String |
getBaseURI()
Not yet implemented. |
List<? extends Object> |
getByXPath(String xpathExpr)
Evaluates the specified XPath expression from this node, returning the matching elements. |
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]". |
Iterator<DomNode> |
getChildIterator()
Deprecated. As of 2.0, use getChildren(). |
NodeList |
getChildNodes()
|
Iterable<DomNode> |
getChildren()
|
protected String |
getChildrenAsText()
Returns a text string that represents all the child elements as they would be visible in a web browser. |
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. |
Object |
getFeature(String feature,
String version)
Not yet implemented. |
Object |
getFirstByXPath(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 |
getFirstDomChild()
Deprecated. As of 2.0, please use getFirstChild() instead. |
DomNode |
getLastChild()
|
DomNode |
getLastDomChild()
Deprecated. As of 2.0, please use getLastChild() instead. |
String |
getLocalName()
|
protected Log |
getLog()
Deprecated. As of 2.0, use local log variables enclosed in a conditional block. |
String |
getNamespaceURI()
|
DomNode |
getNextDomSibling()
Deprecated. As of 2.0, please use getNextSibling() instead. |
DomNode |
getNextSibling()
|
abstract String |
getNodeName()
Returns this node's node name. |
abstract short |
getNodeType()
Returns this node's node type. |
String |
getNodeValue()
|
Document |
getOwnerDocument()
|
Page |
getPage()
Returns the page that contains this node. |
DomNode |
getParentDomNode()
Deprecated. As of 2.0, please use getParentNode() instead. |
DomNode |
getParentNode()
|
String |
getPrefix()
|
DomNode |
getPreviousDomSibling()
Deprecated. As of 2.0, please use getPreviousSibling() instead. |
DomNode |
getPreviousSibling()
|
String |
getReadyState()
Returns this node's ready state (IE only). |
org.mozilla.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. |
String |
getTextContent()
|
Object |
getUserData(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. |
Node |
insertBefore(Node newChild,
Node refChild)
|
boolean |
isAncestorOf(DomNode node)
Returns true if this node is an ancestor of the specified node. |
boolean |
isDefaultNamespace(String namespaceURI)
Not yet implemented. |
boolean |
isEqualNode(Node arg)
Not yet implemented. |
protected boolean |
isRenderedVisible()
Returns a flag indicating whether or not this node itself results in any space taken up in browser windows; for instance, "<b>" affects the specified text, but does not use up any space itself. |
boolean |
isSameNode(Node other)
|
boolean |
isSupported(String namespace,
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. |
String |
lookupNamespaceURI(String prefix)
Not yet implemented. |
String |
lookupPrefix(String namespaceURI)
Not yet implemented. |
void |
normalize()
Not yet implemented. |
protected void |
notifyIncorrectness(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()
Lifecycle method invoked after a node and all its children have been added to a page, during parsing of the HTML. |
protected void |
printChildrenAsXml(String indent,
PrintWriter printWriter)
Recursively writes the XML data for the node tree starting at node. |
protected void |
printXml(String indent,
PrintWriter printWriter)
Recursively writes the XML data for the node tree starting at node. |
protected static String |
reduceWhitespace(String text)
Removes extra whitespace from a string, similar to what a browser does when it displays text. |
void |
remove()
Removes this node from all relationships with other nodes. |
void |
removeAllChildren()
Removes all of this node's children. |
Node |
removeChild(Node child)
|
void |
removeDomChangeListener(DomChangeListener listener)
Removes a DomChangeListener from the listener list. |
void |
replace(DomNode newNode)
Replaces this node with another node. |
Node |
replaceChild(Node newChild,
Node oldChild)
|
protected void |
setNextSibling(DomNode next)
|
void |
setNodeValue(String x)
|
protected void |
setParentNode(DomNode parent)
Sets the parent node. |
void |
setPrefix(String prefix)
|
protected void |
setPreviousSibling(DomNode previous)
|
void |
setReadyState(String state)
Sets this node's ready state (IE only). |
void |
setScriptObject(org.mozilla.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(String textContent)
|
Object |
setUserData(String key,
Object data,
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 |
|---|
public static final String READY_STATE_UNINITIALIZED
public static final String READY_STATE_LOADING
public static final String READY_STATE_LOADED
public static final String READY_STATE_INTERACTIVE
public static final String READY_STATE_COMPLETE
public static final String PROPERTY_ELEMENT
| Constructor Detail |
|---|
@Deprecated protected DomNode()
protected DomNode(Page page)
page - the page which contains this node| Method Detail |
|---|
public int getStartLineNumber()
public int getStartColumnNumber()
public int getEndLineNumber()
public int getEndColumnNumber()
public Page getPage()
public Document getOwnerDocument()
getOwnerDocument in interface Nodepublic void setScriptObject(org.mozilla.javascript.ScriptableObject scriptObject)
scriptObject - the JavaScript objectpublic DomNode getLastChild()
getLastChild in interface Node@Deprecated public DomNode getLastDomChild()
getLastChild() instead.
public DomNode getParentNode()
getParentNode in interface Node@Deprecated public DomNode getParentDomNode()
getParentNode() instead.
protected void setParentNode(DomNode parent)
parent - the parent nodepublic DomNode getPreviousSibling()
getPreviousSibling in interface Node@Deprecated public DomNode getPreviousDomSibling()
getPreviousSibling() instead.
public DomNode getNextSibling()
getNextSibling in interface Node@Deprecated public DomNode getNextDomSibling()
getNextSibling() instead.
public DomNode getFirstChild()
getFirstChild in interface Node@Deprecated public DomNode getFirstDomChild()
getFirstChild() instead.
public 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 Nodepublic abstract String getNodeName()
getNodeName in interface Nodepublic String getNamespaceURI()
getNamespaceURI in interface Nodepublic String getLocalName()
getLocalName in interface Nodepublic String getPrefix()
getPrefix in interface Nodepublic void setPrefix(String prefix)
setPrefix in interface Nodepublic boolean hasChildNodes()
hasChildNodes in interface Nodepublic NodeList getChildNodes()
getChildNodes in interface Node
public boolean isSupported(String namespace,
String featureName)
isSupported in interface Nodepublic void normalize()
normalize in interface Nodepublic String getBaseURI()
getBaseURI in interface Nodepublic short compareDocumentPosition(Node other)
compareDocumentPosition in interface Node
public String getTextContent()
throws DOMException
getTextContent in interface NodeDOMException
public void setTextContent(String textContent)
throws DOMException
setTextContent in interface NodeDOMExceptionpublic boolean isSameNode(Node other)
isSameNode in interface Nodepublic String lookupPrefix(String namespaceURI)
lookupPrefix in interface Nodepublic boolean isDefaultNamespace(String namespaceURI)
isDefaultNamespace in interface Nodepublic String lookupNamespaceURI(String prefix)
lookupNamespaceURI in interface Nodepublic boolean isEqualNode(Node arg)
isEqualNode in interface Node
public Object getFeature(String feature,
String version)
getFeature in interface Nodepublic Object getUserData(String key)
getUserData in interface Node
public Object setUserData(String key,
Object data,
UserDataHandler handler)
setUserData in interface Nodepublic boolean hasAttributes()
hasAttributes in interface Nodeprotected boolean isRenderedVisible()
protected 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 String asText()
protected final String getChildrenAsText()
asText()protected static String reduceWhitespace(String text)
text - the text to clean up
@Deprecated protected final Log getLog()
public String asXml()
protected void printXml(String indent,
PrintWriter printWriter)
node.
indent - white space to indent child nodesprintWriter - writer where child nodes are written
protected void printChildrenAsXml(String indent,
PrintWriter printWriter)
node.
indent - white space to indent child nodesprintWriter - writer where child nodes are writtenpublic String getNodeValue()
getNodeValue in interface Nodepublic void setNodeValue(String x)
setNodeValue in interface Nodepublic DomNode cloneNode(boolean deep)
cloneNode in interface Node@Deprecated public DomNode cloneDomNode(boolean deep)
cloneNode(boolean) instead.
deep - if true, the clone will be propagated to the whole subtree
below this one. Otherwise, the new node will not have any children. The page reference
will always be the same as this node's.
public org.mozilla.javascript.ScriptableObject getScriptObject()
public DomNode appendChild(Node node)
appendChild in interface Node@Deprecated public DomNode appendDomChild(DomNode node)
appendChild(Node) instead.
node - the node to append
protected void checkChildHierarchy(Node newChild)
throws DOMException
newChild - the new child node that is being inserted below this node
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 Node insertBefore(Node newChild,
Node refChild)
throws DOMException
insertBefore in interface NodeDOMException
public void insertBefore(DomNode newNode)
throws IllegalStateException
newNode - the new node to insert
IllegalStateException - if this node is not a child of any other nodepublic NamedNodeMap getAttributes()
getAttributes in interface Nodepublic Node removeChild(Node child)
removeChild in interface Nodepublic void remove()
public Node replaceChild(Node newChild,
Node oldChild)
replaceChild in interface Node
public void replace(DomNode newNode)
throws IllegalStateException
newNode - the node to replace this one
IllegalStateException - if this node is not a child of any other nodeprotected void onAddedToPage()
protected void onAllChildrenAddedToPage()
public final Iterable<DomNode> getChildren()
@Deprecated public Iterator<DomNode> getChildIterator()
getChildren().
public final 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 String getReadyState()
public void setReadyState(String state)
state - this node's ready statepublic void removeAllChildren()
public List<? extends Object> getByXPath(String xpathExpr)
xpathExpr - the XPath expression to evaluate
getFirstByXPath(String),
getCanonicalXPath()public Object getFirstByXPath(String xpathExpr)
xpathExpr - the XPath expression
getByXPath(String),
getCanonicalXPath()public 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(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 | |||||||||