public class XMLTreeWalker extends Object implements org.w3c.dom.traversal.TreeWalker
TreeWalker.| Modifier and Type | Field and Description |
|---|---|
static int |
MODE_ROOT
The mode for traversing under the root node.
|
static int |
MODE_SLICE
The mode for traversing from the root node to another node.
|
| Constructor and Description |
|---|
XMLTreeWalker(Document doc)
Create a new XMLTreeWalker.
|
XMLTreeWalker(Node rootNode)
Create a new XMLTreeWalker, in the default
MODE_ROOT mode. |
XMLTreeWalker(Node rootNode,
Node lastNode)
Create a new XMLTreeWalker, in the
MODE_SLICE mode. |
| Modifier and Type | Method and Description |
|---|---|
Node |
firstChild()
Moves the TreeWalker to the first visible child of the current node, and returns the new node.
|
Node |
getCurrentNode()
Return the node at which the TreeWalker is currently positioned.
|
boolean |
getExpandEntityReferences()
Return the value of this flag determines whether the children of entity reference nodes are visible to the TreeWalker.
|
org.w3c.dom.traversal.NodeFilter |
getFilter()
Return the filter used to screen nodes.
|
Node |
getLastNode()
Return the last Node of the DOM tree to traverse (more specifically, the DOM tree, the walker will stop the iteration just before this
Node.
|
int |
getLevel()
Return the level in the XML subtree, the 0 value designing the root Node.
|
Node |
getRoot()
The root node of the TreeWalker, as specified when it was created.
|
int |
getTraversalMode()
Return the mode used to traverse the DOM tree.
|
int |
getWhatToShow()
This attribute determines which node types are presented via the TreeWalker.
|
Node |
lastChild()
Moves the TreeWalker to the last visible child of the current node, and returns the new node.
|
Node |
nextNode()
Moves the TreeWalker to the next visible node in document order relative to the current node, and returns the new node.
|
Node |
nextSibling()
Moves the TreeWalker to the next sibling of the current node, and returns the new node.
|
Node |
parentNode()
Moves to and returns the closest visible ancestor node of the current node.
|
Node |
previousNode()
Moves the TreeWalker to the previous visible node in document order relative to the current node, and returns the new node.
|
Node |
previousSibling()
Moves the TreeWalker to the previous sibling of the current node, and returns the new node.
|
void |
setCurrentNode(Node node) |
void |
setExpandEntityReferences(boolean expand)
Not used for the moment.
|
void |
setFilter(org.w3c.dom.traversal.NodeFilter filter)
Set the node filter.
|
void |
setNodeType(int type)
Not used for the moment.
|
public static final int MODE_ROOT
public static final int MODE_SLICE
public XMLTreeWalker(Node rootNode)
MODE_ROOT mode.rootNode - the root Node of this walkerpublic XMLTreeWalker(Node rootNode, Node lastNode)
MODE_SLICE mode. The DOM hierarchy from the rootNode to the Node previous to the lastNode
will be traversed. If the lastNode is null, the DOM tree will be traversed up to the last DOM Node.rootNode - the root Node of this walkerlastNode - the last Node of this walkerpublic XMLTreeWalker(Document doc)
doc - the Document whose DocumentElement will be used as root Nodepublic int getTraversalMode()
MODE_ROOT : only the Nodes under the getRoot() Node are traversedMODE_SLICE : the hierarchy from the getRoot() Node to the Node previous to getLastNode() is
traversedpublic void setNodeType(int type)
public void setFilter(org.w3c.dom.traversal.NodeFilter filter)
filter - public void setExpandEntityReferences(boolean expand)
public void setCurrentNode(Node node)
setCurrentNode in interface org.w3c.dom.traversal.TreeWalkerpublic org.w3c.dom.traversal.NodeFilter getFilter()
getFilter in interface org.w3c.dom.traversal.TreeWalkerpublic int getLevel()
MODE_ROOT
mode, but it can be < 0 in the MODE_SLICE mode, as the last Node can be higher in the DOM hierarchy than the root node.public Node firstChild()
firstChild in interface org.w3c.dom.traversal.TreeWalkerpublic Node getCurrentNode()
getCurrentNode in interface org.w3c.dom.traversal.TreeWalkerpublic boolean getExpandEntityReferences()
getExpandEntityReferences in interface org.w3c.dom.traversal.TreeWalkerpublic Node getRoot()
getRoot in interface org.w3c.dom.traversal.TreeWalkerpublic Node getLastNode()
MODE_ROOT, this is guaranteed to be null.public int getWhatToShow()
getWhatToShow in interface org.w3c.dom.traversal.TreeWalkerpublic Node lastChild()
lastChild in interface org.w3c.dom.traversal.TreeWalkerpublic Node nextNode()
MODE_ROOT, we traverse the DOM tree under the getRoot() nodeMODE_SLICE, we traverse the DOM tree beginning from the getRoot() node,
nextNode in interface org.w3c.dom.traversal.TreeWalkerpublic Node nextSibling()
nextSibling in interface org.w3c.dom.traversal.TreeWalkerpublic Node previousSibling()
previousSibling in interface org.w3c.dom.traversal.TreeWalkerpublic Node parentNode()
parentNode in interface org.w3c.dom.traversal.TreeWalkerpublic Node previousNode()
previousNode in interface org.w3c.dom.traversal.TreeWalker