Package org.apache.xml.dtm.ref
Class DTMTreeWalker
java.lang.Object
org.apache.xml.dtm.ref.DTMTreeWalker
- Direct Known Subclasses:
TreeWalker2Result
public class DTMTreeWalker extends Object
This class does a pre-order walk of the DTM tree, calling a ContentHandler
interface as it goes. As such, it's more like the Visitor design pattern
than like the DOM's TreeWalker.
I think normally this class should not be needed, because
of DTM#dispatchToEvents.
-
Field Summary
-
Constructor Summary
Constructors Constructor Description DTMTreeWalker()Constructor.DTMTreeWalker(ContentHandler contentHandler, DTM dtm)Constructor. -
Method Summary
Modifier and Type Method Description protected voidendNode(int node)End processing of given nodeContentHandlergetcontentHandler()Get the ContentHandler used for the tree walk.voidsetcontentHandler(ContentHandler ch)Set the ContentHandler used for the tree walk.voidsetDTM(DTM dtm)Set the DTM to be traversed.protected voidstartNode(int node)Start processing given nodevoidtraverse(int pos)Perform a non-recursive pre-order/post-order traversal, operating as a Visitor.voidtraverse(int pos, int top)Perform a non-recursive pre-order/post-order traversal, operating as a Visitor.
-
Field Details
-
m_dtm
DomHelper for this TreeWalker
-
-
Constructor Details
-
DTMTreeWalker
public DTMTreeWalker()Constructor. -
DTMTreeWalker
Constructor.- Parameters:
contentHandler- The implemention of the contentHandler operation (toXMLString, digest, ...)
-
-
Method Details
-
setDTM
Set the DTM to be traversed.- Parameters:
dtm- The Document Table Model to be used.
-
getcontentHandler
Get the ContentHandler used for the tree walk.- Returns:
- the ContentHandler used for the tree walk
-
setcontentHandler
Set the ContentHandler used for the tree walk.- Parameters:
ch- the ContentHandler to be the result of the tree walk.
-
traverse
Perform a non-recursive pre-order/post-order traversal, operating as a Visitor. startNode (preorder) and endNode (postorder) are invoked for each node as we traverse over them, with the result that the node is written out to m_contentHandler.- Parameters:
pos- Node in the tree at which to start (and end) traversal -- in other words, the root of the subtree to traverse over.- Throws:
TransformerExceptionSAXException
-
traverse
Perform a non-recursive pre-order/post-order traversal, operating as a Visitor. startNode (preorder) and endNode (postorder) are invoked for each node as we traverse over them, with the result that the node is written out to m_contentHandler.- Parameters:
pos- Node in the tree where to start traversaltop- Node in the tree where to end traversal. If top==DTM.NULL, run through end of document.- Throws:
TransformerExceptionSAXException
-
startNode
Start processing given node- Parameters:
node- Node to process- Throws:
SAXException
-
endNode
End processing of given node- Parameters:
node- Node we just finished processing- Throws:
SAXException
-