| java.lang.Object com.gargoylesoftware.htmlunit.html.DomNode
All known Subclasses: com.gargoylesoftware.htmlunit.SgmlPage, com.gargoylesoftware.htmlunit.html.DomNamespaceNode, com.gargoylesoftware.htmlunit.html.DomDocumentFragment, com.gargoylesoftware.htmlunit.html.DomCharacterData,
DomNode | abstract public class DomNode implements Cloneable,Serializable(Code) | | Base class for nodes in the HTML DOM tree. This class is modeled after the
W3C DOM specification, but does not implement it.
version: $Revision: 2132 $ author: Mike Bowler author: Mike J. Bresnahan author: David K. Taylor author: Christian Sell author: Chris Erskine author: Mike Williams author: Marc Guillemot author: Denis N. Antonioli author: Daniel Gredler author: Ahmed Ashour author: Rodney Gitzel |
Inner Class :protected class ChildIterator implements Iterator | |
Inner Class :protected class DescendantElementsIterator implements Iterator | |
Constructor Summary | |
protected | DomNode() Never call this, used for Serialization. | protected | DomNode(Page page) Creates an instance. |
Method Summary | |
public void | addDomChangeListener(DomChangeListener listener) Adds a DomChangeListener to the listener list. | final public synchronized void | addPropertyChangeListener(PropertyChangeListener listener) Add a property change listener to this node. | public DomNode | appendChild(DomNode node) | public DomNode | appendDomChild(DomNode node) | public String | asText() Returns a text representation of this element that represents what would
be visible to the user if this page was shown in a web browser. | public String | asXml() Return a string representation of the xml document from this element and all
it's children (recursively). | public DomNode | cloneDomNode(boolean deep) Make a clone of this node
Parameters: deep - if true , the clone will be propagated to the whole subtreebelow this one. | public DomNode | cloneNode(boolean deep) Make a clone of this node
Parameters: deep - if true , the clone will be propagated to the whole subtreebelow this one. | protected void | fireNodeAdded(DomNode parentNode, DomNode addedNode) Support for reporting DOM changes. | protected void | fireNodeDeleted(DomNode parentNode, DomNode deletedNode) Support for reporting DOM changes. | final protected synchronized void | firePropertyChange(String propertyName, Object oldValue, Object newValue) | public Iterator | getAllHtmlChildElements() Return an iterator that will recursively iterate over every child element
below this one. | public List | getByXPath(String xpathExpr) Facility to evaluate an xpath from the current node. | public Iterator | getChildIterator() | final protected String | getChildrenAsText() | public int | getEndColumnNumber() Get the column number in the source page where the DOM node ends. | public int | getEndLineNumber() Get the line number in the source page where the DOM node ends. | public Function | getEventHandler(String eventName) INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Return a Function to be executed when a given event occurs.
Parameters: eventName - Name of event such as "onclick" or "onblur", etc. | public Object | getFirstByXPath(String xpathExpr) Facility to evaluate an xpath from the current node and get the first result. | public DomNode | getFirstChild() | public DomNode | getFirstDomChild() | public DomNode | getLastChild() Get the last child node. | public DomNode | getLastDomChild() Get the last child DomNode. | public String | getLocalName() Returns the local part of the qualified name of this node. | final protected Log | getLog() Return the log object for this element. | public String | getNamespaceURI() The namespace URI of this node, or null if it is unspecified (see ). | public Page | getNativePage() INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Returns the Page interface, should be removed, and use
DomNode.getPage() instead. | public DomNode | getNextDomSibling() | public DomNode | getNextSibling() | abstract public String | getNodeName() Get the name for the current node. | abstract public short | getNodeType() Get the type of the current node. | public String | getNodeValue() Get the value for the current node. | public HtmlPage | getPage() | public DomNode | getParentDomNode() | public DomNode | getParentNode() | public String | getPrefix() The namespace prefix of this node, or null if it is unspecified. | public DomNode | getPreviousDomSibling() | public DomNode | getPreviousSibling() | public String | getReadyState() Return this node's ready state (IE only). | public ScriptableObject | getScriptObject() INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
The logic of when and where the js object is created needs a clean up: functions using
a js object of a dom node should not have to look if they should create it first
Return the javascript object that corresponds to this node. | public int | getStartColumnNumber() Get the column number in the source page where the DOM node starts. | public int | getStartLineNumber() Get the line number in the source page where the DOM node starts. | public boolean | hasAttributes() Return whether this node has any attributes. | public void | insertBefore(DomNode newNode) Inserts a new child node before this node into the child relationship this node is a
part of. | public boolean | isAncestorOf(DomNode node) Returns true if this node is an ancestor of the specified node. | protected boolean | isRenderedVisible() | protected boolean | isTrimmedText() | protected void | notifyIncorrectness(String message) Facility to notify 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) | protected void | printXml(String indent, PrintWriter printWriter) | protected static String | reduceWhitespace(String text) Removes extra whitespace from a string similar to what a browser does
when it displays text.
Parameters: text - The text to clean up. | public void | remove() Removes this node from all relationships with other nodes. | public void | removeAllChildren() Remove all the children of this node. | public void | removeDomChangeListener(DomChangeListener listener) Removes an DomChangeListener from the listener list. | public void | removeEventHandler(String eventName) INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Removes the specified event handler. | final public synchronized void | removePropertyChangeListener(PropertyChangeListener listener) Remove a property change listener from this node. | public void | replace(DomNode newNode) Replaces this node with another node. | void | setEndLocation(int endLineNumber, int endColumnNumber) Set the line and column numbers in the source page where the
DOM node ends. | public void | setEventHandler(String eventName, Function eventHandler) INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Register a Function as an event handler. | public void | setEventHandler(String eventName, String jsSnippet) INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Register a snippet of javascript code as an event handler. | protected void | setNextSibling(DomNode next) | public void | setNodeValue(String x) | protected void | setParentNode(DomNode parent) | public void | setPrefix(String prefix) Set the namespace prefix of this node, or null if it is unspecified. | protected void | setPreviousSibling(DomNode previous) | public void | setReadyState(String state) Sets this node's ready state (IE only). | public void | setScriptObject(ScriptableObject scriptObject) INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Set the javascript object that corresponds to this node. | void | setStartLocation(int startLineNumber, int startColumnNumber) Set the line and column numbers in the source page where the
DOM node starts. |
PROPERTY_ELEMENT | final public static String PROPERTY_ELEMENT(Code) | | The name of the "element" property. Used when watching property change events.
|
READY_STATE_COMPLETE | final public static String READY_STATE_COMPLETE(Code) | | A ready state constant for IE (state 5).
|
READY_STATE_INTERACTIVE | final public static String READY_STATE_INTERACTIVE(Code) | | A ready state constant for IE (state 4).
|
READY_STATE_LOADED | final public static String READY_STATE_LOADED(Code) | | A ready state constant for IE (state 3).
|
READY_STATE_LOADING | final public static String READY_STATE_LOADING(Code) | | A ready state constant for IE (state 2).
|
READY_STATE_UNINITIALIZED | final public static String READY_STATE_UNINITIALIZED(Code) | | A ready state constant for IE (state 1).
|
DomNode | protected DomNode()(Code) | | Never call this, used for Serialization.
|
DomNode | protected DomNode(Page page)(Code) | | Creates an instance.
Parameters: page - The page which contains this node. |
addPropertyChangeListener | final public synchronized void addPropertyChangeListener(PropertyChangeListener listener)(Code) | | Add a property change listener to this node.
Parameters: listener - The new listener. |
appendChild | public DomNode appendChild(DomNode node)(Code) | | append a child node to the end of the current list
Parameters: node - the node to append the node added |
appendDomChild | public DomNode appendDomChild(DomNode node)(Code) | | append a child node to the end of the current list
Parameters: node - the node to append the node added |
asText | public String asText()(Code) | | Returns a text representation of this element that represents what would
be visible to the user if this page was shown in a web browser. For
example, a single-selection select element would return the currently selected
value as text.
The element as text. |
asXml | public String asXml()(Code) | | Return a string representation of the xml document from this element and all
it's children (recursively).
The xml string. |
cloneDomNode | public DomNode cloneDomNode(boolean deep)(Code) | | Make a clone of this node
Parameters: deep - if true , the clone will be propagated to the whole subtreebelow this one. Otherwise, the new node will not have any children. The page referencewill always be the same as this node's. a new node |
cloneNode | public DomNode cloneNode(boolean deep)(Code) | | Make a clone of this node
Parameters: deep - if true , the clone will be propagated to the whole subtreebelow this one. Otherwise, the new node will not have any children. The page referencewill always be the same as this node's. a new node |
fireNodeAdded | protected void fireNodeAdded(DomNode parentNode, DomNode addedNode)(Code) | | Support for reporting DOM changes. This method can be called when a node has been added and it
will send the appropriate
DomChangeEvent to any registered
DomChangeListener s.
Note that this method recursively calls this node's parent's
DomNode.fireNodeAdded(DomNode,DomNode) .
Parameters: parentNode - the parent of the node that was added. Parameters: addedNode - the node that was added. |
fireNodeDeleted | protected void fireNodeDeleted(DomNode parentNode, DomNode deletedNode)(Code) | | Support for reporting DOM changes. This method can be called when a node has been deleted and it
will send the appropriate
DomChangeEvent to any registered
DomChangeListener s.
Note that this method recursively calls this node's parent's
DomNode.fireNodeDeleted(DomNode,DomNode) .
Parameters: parentNode - the parent of the node that was deleted. Parameters: deletedNode - the node that was deleted. |
firePropertyChange | final protected synchronized void firePropertyChange(String propertyName, Object oldValue, Object newValue)(Code) | | Fire a property change event
Parameters: propertyName - The name of the property. Parameters: oldValue - The old value. Parameters: newValue - The new value. |
getAllHtmlChildElements | public Iterator getAllHtmlChildElements()(Code) | | Return an iterator that will recursively iterate over every child element
below this one.
The iterator. |
getByXPath | public List getByXPath(String xpathExpr) throws JaxenException(Code) | | Facility to evaluate an xpath from the current node. The current node is considered as the
document root for the evaluation therefore parent nodes can't be reached.
Parameters: xpathExpr - the xpath expression See XPath.selectNodes(Object) throws: JaxenException - if the xpath expression can't be parsed/evaluated |
getChildIterator | public Iterator getChildIterator()(Code) | | an iterator over the children of this node |
getChildrenAsText | final protected String getChildrenAsText()(Code) | | Return a text string that represents all the child elements as they
would be visible in a web browser
See above See Also: DomNode.asText() |
getEndColumnNumber | public int getEndColumnNumber()(Code) | | Get the column number in the source page where the DOM node ends.
See above. |
getEndLineNumber | public int getEndLineNumber()(Code) | | Get the line number in the source page where the DOM node ends.
See above. |
getEventHandler | public Function getEventHandler(String eventName)(Code) | | INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Return a Function to be executed when a given event occurs.
Parameters: eventName - Name of event such as "onclick" or "onblur", etc. A rhino javascript executable Function, or null if no eventhandler has been defined |
getFirstByXPath | public Object getFirstByXPath(String xpathExpr) throws JaxenException(Code) | | Facility to evaluate an xpath from the current node and get the first result.
The current node is considered as the document root for the evaluation
therefore parent nodes can't be reached.
Parameters: xpathExpr - the xpath expression null if no result is found, the first one otherwise throws: JaxenException - if the xpath expression can't be parsed/evaluated |
getFirstChild | public DomNode getFirstChild()(Code) | | the previous sibling |
getFirstDomChild | public DomNode getFirstDomChild()(Code) | | the previous sibling |
getLastChild | public DomNode getLastChild()(Code) | | Get the last child node.
The last child node or null if the current node hasno children. |
getLastDomChild | public DomNode getLastDomChild()(Code) | | Get the last child DomNode.
The last child node or null if the current node hasno children. |
getLocalName | public String getLocalName()(Code) | | Returns the local part of the qualified name of this node. For nodes of any
type other than ELEMENT_NODE and ATTRIBUTE_NODE and nodes created with a DOM Level 1
method, such as Document.createElement(), this is always null.
The local name (without prefix). |
getLog | final protected Log getLog()(Code) | | Return the log object for this element.
The log object for this element. |
getNamespaceURI | public String getNamespaceURI()(Code) | | The namespace URI of this node, or null if it is unspecified (see ). This is not a
computed value that is the result of a namespace lookup based on an examination of the
namespace declarations in scope. It is merely the namespace URI given at creation time.
For nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE and nodes created with
a DOM Level 1 method, such as Document.createElement(), this is always null.
The URI that identifies an XML namespace. |
getNativePage | public Page getNativePage()(Code) | | INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Returns the Page interface, should be removed, and use
DomNode.getPage() instead.
the Page interface. |
getNextDomSibling | public DomNode getNextDomSibling()(Code) | | the next sibling |
getNextSibling | public DomNode getNextSibling()(Code) | | the next sibling |
getNodeName | abstract public String getNodeName()(Code) | | Get the name for the current node.
The node name |
getNodeType | abstract public short getNodeType()(Code) | | Get the type of the current node.
The node type |
getNodeValue | public String getNodeValue()(Code) | | Get the value for the current node.
The node value |
getPage | public HtmlPage getPage()(Code) | | Return the HtmlPage that contains this node
See above |
getParentDomNode | public DomNode getParentDomNode()(Code) | | the parent DomNode of this node, which may be null if thisis the root node |
getParentNode | public DomNode getParentNode()(Code) | | the parent of this node, which may be null if thisis the root node |
getPrefix | public String getPrefix()(Code) | | The namespace prefix of this node, or null if it is unspecified.
The Namespace prefix. |
getPreviousDomSibling | public DomNode getPreviousDomSibling()(Code) | | the previous sibling of this node, or null if this isthe first node |
getPreviousSibling | public DomNode getPreviousSibling()(Code) | | the previous sibling of this node, or null if this isthe first node |
getReadyState | public String getReadyState()(Code) | | Return this node's ready state (IE only).
This node's ready state. |
getScriptObject | public ScriptableObject getScriptObject()(Code) | | INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
The logic of when and where the js object is created needs a clean up: functions using
a js object of a dom node should not have to look if they should create it first
Return the javascript object that corresponds to this node.
The javascript object that corresponds to this node building it if necessary. |
getStartColumnNumber | public int getStartColumnNumber()(Code) | | Get the column number in the source page where the DOM node starts.
See above. |
getStartLineNumber | public int getStartLineNumber()(Code) | | Get the line number in the source page where the DOM node starts.
See above. |
hasAttributes | public boolean hasAttributes()(Code) | | Return whether this node has any attributes.
true if the node has attributes, false otherwise. |
insertBefore | public void insertBefore(DomNode newNode) throws IllegalStateException(Code) | | Inserts a new child node before this node into the child relationship this node is a
part of. If the specified node is this node, this method is a no-op.
Parameters: newNode - the new node to insert throws: IllegalStateException - if this node is not a child of any other node |
isAncestorOf | public boolean isAncestorOf(DomNode node)(Code) | | Returns true if this node is an ancestor of the specified node.
Parameters: node - the node to check true if this node is an ancestor of the specified node |
isRenderedVisible | protected boolean isRenderedVisible()(Code) | | Returns a flag indicating whether or not this node itself results
in any space taken up in the browser windows; for instance, ""
affects the specified text, but does not use up any space itself
The flag |
isTrimmedText | protected boolean isTrimmedText()(Code) | | Returns a flag indicating whether or not this node should
have any leading and trailing whitespace removed when asText()
is called; mostly this should be true, but must be false for
such things as text formatting tags
The flag |
notifyIncorrectness | protected void notifyIncorrectness(String message)(Code) | | Facility to notify the registered
IncorrectnessListener of something that is not fully correct.
Parameters: message - the notification |
onAddedToPage | protected void onAddedToPage()(Code) | | Lifecycle method invoked whenever a node is added to a page. Intended to
be overridden by nodes which need to perform custom logic when they are
added to a page. This method is recursive, so if you override it, please
be sure to call super.onAddedToPage().
|
onAllChildrenAddedToPage | protected void onAllChildrenAddedToPage()(Code) | | Lifecycle method invoked after a node and all its children have been added to a page, during
parsing of the HTML. Intended to be overridden by nodes which need to perform custom logic
after they and all their child nodes have been processed by the HTML parser. This method is
not recursive, and the default implementation is empty, so there is no need to call
super.onAllChildrenAddedToPage() if you implement this method.
|
printChildrenAsXml | protected void printChildrenAsXml(String indent, PrintWriter printWriter)(Code) | | recursively write the XML data for the node tree starting at node
Parameters: indent - white space to indent child nodes Parameters: printWriter - writer where child nodes are written |
printXml | protected void printXml(String indent, PrintWriter printWriter)(Code) | | recursively write the XML data for the node tree starting at node
Parameters: indent - white space to indent child nodes Parameters: printWriter - writer where child nodes are written |
reduceWhitespace | protected static String reduceWhitespace(String text)(Code) | | Removes extra whitespace from a string similar to what a browser does
when it displays text.
Parameters: text - The text to clean up. The cleaned up text. |
removeAllChildren | public void removeAllChildren()(Code) | | Remove all the children of this node.
|
removeDomChangeListener | public void removeDomChangeListener(DomChangeListener listener)(Code) | | Removes an DomChangeListener from the listener list.
This method should be used to remove DomChangeListener that were registered
for all children nodes and descendant nodes of this DomNode.
Parameters: listener - the dom structure change listener to be removed. See Also: DomNode.addDomChangeListener(DomChangeListener) |
removeEventHandler | public void removeEventHandler(String eventName)(Code) | | INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Removes the specified event handler.
Parameters: eventName - Name of the event such as "onclick" or "onblur", etc. |
removePropertyChangeListener | final public synchronized void removePropertyChangeListener(PropertyChangeListener listener)(Code) | | Remove a property change listener from this node.
Parameters: listener - The listener. |
replace | public void replace(DomNode newNode) throws IllegalStateException(Code) | | Replaces this node with another node. If the specified node is this node, this
method is a no-op.
Parameters: newNode - the node to replace this one throws: IllegalStateException - if this node is not a child of any other node |
setEndLocation | void setEndLocation(int endLineNumber, int endColumnNumber)(Code) | | Set the line and column numbers in the source page where the
DOM node ends.
Parameters: endLineNumber - The line number where the DOM node ends. Parameters: endColumnNumber - The column number where the DOM node ends. |
setEventHandler | public void setEventHandler(String eventName, Function eventHandler)(Code) | | INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Register a Function as an event handler.
Parameters: eventName - Name of event such as "onclick" or "onblur", etc. Parameters: eventHandler - A rhino javascript executable Function |
setEventHandler | public void setEventHandler(String eventName, String jsSnippet)(Code) | | INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Register a snippet of javascript code as an event handler. The javascript code will
be wrapped inside a unique function declaration which provides one argument named
"event"
Parameters: eventName - Name of event such as "onclick" or "onblur", etc. Parameters: jsSnippet - executable javascript code |
setNextSibling | protected void setNextSibling(DomNode next)(Code) | | Parameters: next - set the nextSibling field value |
setNodeValue | public void setNodeValue(String x)(Code) | | Parameters: x - The new value |
setParentNode | protected void setParentNode(DomNode parent)(Code) | | Set the parent node
Parameters: parent - the parent node |
setPrefix | public void setPrefix(String prefix)(Code) | | Set the namespace prefix of this node, or null if it is unspecified. When it is defined
to be null, setting it has no effect, including if the node is read-only. Note that setting
this attribute, when permitted, changes the nodeName attribute, which holds the qualified
name, as well as the tagName and name attributes of the Element and Attr interfaces, when
applicable. Setting the prefix to null makes it unspecified, setting it to an empty string
is implementation dependent. Note also that changing the prefix of an attribute that is
known to have a default value, does not make a new attribute with the default value and the
original prefix appear, since the namespaceURI and localName do not change. For nodes of
any type other than ELEMENT_NODE and ATTRIBUTE_NODE and nodes created with a DOM Level 1
method, such as createElement from the Document interface, this is always null.
Parameters: prefix - The namespace prefix of this node, or null if it is unspecified. |
setPreviousSibling | protected void setPreviousSibling(DomNode previous)(Code) | | Parameters: previous - set the previousSibling field value |
setReadyState | public void setReadyState(String state)(Code) | | Sets this node's ready state (IE only).
Parameters: state - This node's ready state. |
setScriptObject | public void setScriptObject(ScriptableObject scriptObject)(Code) | | INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Set the javascript object that corresponds to this node. This is not
guaranteed to be set even if there is a javascript object for this
DOM node.
Parameters: scriptObject - The javascript object. |
setStartLocation | void setStartLocation(int startLineNumber, int startColumnNumber)(Code) | | Set the line and column numbers in the source page where the
DOM node starts.
Parameters: startLineNumber - The line number where the DOM node starts. Parameters: startColumnNumber - The column number where the DOM node starts. |
|
|