|
||||||||||
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 short |
ATTRIBUTE_NODE
Deprecated. use Node.ATTRIBUTE_NODE instead. |
static short |
COMMENT_NODE
Deprecated. use Node.COMMENT_NODE instead. |
static short |
DOCUMENT_NODE
Deprecated. use Node.DOCUMENT_NODE instead. |
static short |
ELEMENT_NODE
Deprecated. use Node.ELEMENT_NODE instead. |
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). |
static short |
TEXT_NODE
Deprecated. use Node.TEXT_NODE instead. |
Constructor Summary | |
---|---|
protected |
DomNode()
Deprecated. |
protected |
DomNode(Page page)
Creates an instance. |
Method Summary | |
---|---|
void |
addDomChangeListener(DomChangeListener listener)
Adds a DomChangeListener to the listener list. |
void |
addPropertyChangeListener(PropertyChangeListener listener)
Deprecated. Not used |
DomNode |
appendChild(DomNode node)
Deprecated. This method conflicts with the W3C DOM API since the return values are different. Use appendDomChild instead. |
DomNode |
appendDomChild(DomNode node)
append a child node to the end of the current list |
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. |
String |
asXml()
Return a string representation of the xml document from this element and all it's children (recursively). |
DomNode |
cloneDomNode(boolean deep)
Make a clone of this node |
DomNode |
cloneNode(boolean deep)
Deprecated. This method conflicts with the W3C DOM API since the return values are different. Use cloneDomNode instead. |
protected void |
fireNodeAdded(DomNode parentNode,
DomNode addedNode)
Support for reporting DOM changes. |
protected void |
fireNodeDeleted(DomNode parentNode,
DomNode deletedNode)
Support for reporting DOM changes. |
protected void |
firePropertyChange(String propertyName,
Object oldValue,
Object newValue)
Deprecated. Not used |
Iterator |
getAllHtmlChildElements()
Return an iterator that will recursively iterate over every child element below this one. |
List |
getByXPath(String xpathExpr)
Facility to evaluate an xpath from the current node. |
Iterator |
getChildIterator()
|
protected String |
getChildrenAsText()
Return a text string that represents all the child elements as they would be visible in a web browser |
int |
getEndColumnNumber()
Get the column number in the source page where the DOM node ends. |
int |
getEndLineNumber()
Get the line number in the source page where the DOM node ends. |
org.mozilla.javascript.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. |
Object |
getFirstByXPath(String xpathExpr)
Facility to evaluate an xpath from the current node and get the first result. |
DomNode |
getFirstChild()
Deprecated. This method conflicts with the W3C DOM API since the return values are different. Use getFirstDomChild instead. |
DomNode |
getFirstDomChild()
|
DomNode |
getLastChild()
Deprecated. This method conflicts with the W3C DOM API since the return values are different. Use getLastDomChild instead. |
DomNode |
getLastDomChild()
Get the last child DomNode. |
String |
getLocalName()
Returns the local part of the qualified name of this node. |
protected Log |
getLog()
Return the log object for this element. |
String |
getNamespaceURI()
The namespace URI of this node, or null if it is unspecified (see ). |
Page |
getNativePage()
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK. Returns the Page interface, should be removed, and use getPage() instead. |
DomNode |
getNextDomSibling()
|
DomNode |
getNextSibling()
Deprecated. This method conflicts with the W3C DOM API since the return values are different. Use getNextDomSibling instead. |
abstract String |
getNodeName()
Get the name for the current node. |
abstract short |
getNodeType()
Get the type of the current node. |
String |
getNodeValue()
Get the value for the current node. |
HtmlPage |
getPage()
Return the HtmlPage that contains this node |
DomNode |
getParentDomNode()
|
DomNode |
getParentNode()
Deprecated. This method conflicts with the W3C DOM API since the return values are different. Use getParentDomNode instead. |
String |
getPrefix()
The namespace prefix of this node, or null if it is unspecified. |
DomNode |
getPreviousDomSibling()
|
DomNode |
getPreviousSibling()
Deprecated. This method conflicts with the W3C DOM API since the return values are different. Use getPreviousDomSibling instead. |
String |
getReadyState()
Return 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. 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. |
int |
getStartColumnNumber()
Get the column number in the source page where the DOM node starts. |
int |
getStartLineNumber()
Get the line number in the source page where the DOM node starts. |
boolean |
hasAttributes()
Return whether this node has any attributes. |
void |
insertBefore(DomNode newNode)
Inserts a new child node before this node into the child relationship this node is a part of. |
boolean |
isAncestorOf(DomNode node)
Returns true if this node is an ancestor of the specified node. |
protected boolean |
isRenderedVisible()
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 |
protected boolean |
isTrimmedText()
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 |
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)
recursively write the XML data for the node tree starting at node |
protected void |
printXml(String indent,
PrintWriter printWriter)
recursively write 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()
Remove all the children of this node. |
void |
removeDomChangeListener(DomChangeListener listener)
Removes an DomChangeListener from the listener list. |
void |
removeEventHandler(String eventName)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK. Removes the specified event handler. |
void |
removePropertyChangeListener(PropertyChangeListener listener)
Deprecated. Not used |
void |
replace(DomNode newNode)
Replaces this node with another node. |
void |
setEventHandler(String eventName,
org.mozilla.javascript.Function eventHandler)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK. Register a Function as an event handler. |
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)
|
void |
setNodeValue(String x)
|
protected void |
setParentNode(DomNode parent)
Set the parent node |
void |
setPrefix(String prefix)
Set the namespace prefix of this node, or null if it is unspecified. |
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. Set the javascript object that corresponds to this node. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final short DOCUMENT_NODE
Node.DOCUMENT_NODE
instead.Document
node.
public static final short ELEMENT_NODE
Node.ELEMENT_NODE
instead.Element
nodes.
public static final short TEXT_NODE
Node.TEXT_NODE
instead.Text
nodes.
public static final short ATTRIBUTE_NODE
Node.ATTRIBUTE_NODE
instead.Attribute
nodes.
public static final short COMMENT_NODE
Node.COMMENT_NODE
instead.Comment
nodes.
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 |
---|
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 HtmlPage getPage()
public Page getNativePage()
getPage()
instead.
public void setScriptObject(org.mozilla.javascript.ScriptableObject scriptObject)
scriptObject
- The javascript object.public DomNode getLastChild()
public DomNode getLastDomChild()
public DomNode getParentNode()
null
if this
is the root nodepublic DomNode getParentDomNode()
null
if this
is the root nodeprotected void setParentNode(DomNode parent)
parent
- the parent nodepublic DomNode getPreviousSibling()
null
if this is
the first nodepublic DomNode getPreviousDomSibling()
null
if this is
the first nodepublic DomNode getNextSibling()
public DomNode getNextDomSibling()
public DomNode getFirstChild()
public DomNode getFirstDomChild()
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()
public abstract String getNodeName()
public String getNamespaceURI()
public String getLocalName()
public String getPrefix()
public void setPrefix(String prefix)
prefix
- The namespace prefix of this node, or null if it is unspecified.public boolean hasAttributes()
protected boolean isRenderedVisible()
protected boolean isTrimmedText()
public String asText()
protected final String getChildrenAsText()
asText()
protected static String reduceWhitespace(String text)
text
- The text to clean up.
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 writtenprotected void printChildrenAsXml(String indent, PrintWriter printWriter)
node
indent
- white space to indent child nodesprintWriter
- writer where child nodes are writtenpublic String getNodeValue()
public void setNodeValue(String x)
x
- The new valuepublic DomNode cloneNode(boolean deep)
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 DomNode cloneDomNode(boolean deep)
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(DomNode node)
node
- the node to append
public DomNode appendDomChild(DomNode node)
node
- the node to append
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 void remove() throws IllegalStateException
IllegalStateException
- if this node is not a child of any other nodepublic 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 Iterator getChildIterator()
public org.mozilla.javascript.Function getEventHandler(String eventName)
eventName
- Name of event such as "onclick" or "onblur", etc.
public void setEventHandler(String eventName, org.mozilla.javascript.Function eventHandler)
eventName
- Name of event such as "onclick" or "onblur", etc.eventHandler
- A rhino javascript executable Functionpublic void setEventHandler(String eventName, String jsSnippet)
eventName
- Name of event such as "onclick" or "onblur", etc.jsSnippet
- executable javascript codepublic void removeEventHandler(String eventName)
eventName
- Name of the event such as "onclick" or "onblur", etc.public final void addPropertyChangeListener(PropertyChangeListener listener)
listener
- The new listener.public final void removePropertyChangeListener(PropertyChangeListener listener)
listener
- The listener.protected final void firePropertyChange(String propertyName, Object oldValue, Object newValue)
propertyName
- The name of the property.oldValue
- The old value.newValue
- The new value.public Iterator getAllHtmlChildElements()
public String getReadyState()
public void setReadyState(String state)
state
- This node's ready state.public void removeAllChildren()
public List getByXPath(String xpathExpr) throws org.jaxen.JaxenException
xpathExpr
- the xpath expression
XPath#selectNodes(Object)
org.jaxen.JaxenException
- if the xpath expression can't be parsed/evaluatedpublic Object getFirstByXPath(String xpathExpr) throws org.jaxen.JaxenException
xpathExpr
- the xpath expression
null
if no result is found, the first one otherwise
org.jaxen.JaxenException
- if the xpath expression can't be parsed/evaluatedprotected void notifyIncorrectness(String message)
IncorrectnessListener
of something that is not fully correct.
message
- the notificationpublic void addDomChangeListener(DomChangeListener listener)
listener
- the dom structure change listener to be added.removeDomChangeListener(DomChangeListener)
public void removeDomChangeListener(DomChangeListener listener)
listener
- the dom structure change listener to be removed.addDomChangeListener(DomChangeListener)
protected void fireNodeAdded(DomNode parentNode, DomNode addedNode)
DomChangeEvent
to any registered DomChangeListener
s.
Note that this method recursively calls this node's parent's fireNodeAdded(DomNode, DomNode)
.
parentNode
- the parent of the node that was added.addedNode
- the node that was added.protected void fireNodeDeleted(DomNode parentNode, DomNode deletedNode)
DomChangeEvent
to any registered DomChangeListener
s.
Note that this method recursively calls this node's parent's fireNodeDeleted(DomNode, DomNode)
.
parentNode
- the parent of the node that was deleted.deletedNode
- the node that was deleted.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |