Class DTMTreeWalker

  • Direct Known Subclasses:
    TreeWalker2Result

    public class DTMTreeWalker
    extends java.lang.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.
    • Constructor Summary

      Constructors 
      Constructor Description
      DTMTreeWalker()
      Constructor.
      DTMTreeWalker​(org.xml.sax.ContentHandler contentHandler, DTM dtm)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.xml.sax.ContentHandler getcontentHandler()
      Get the ContentHandler used for the tree walk.
      void setcontentHandler​(org.xml.sax.ContentHandler ch)
      Set the ContentHandler used for the tree walk.
      void setDTM​(DTM dtm)
      Set the DTM to be traversed.
      void traverse​(int pos)
      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.
      void traverse​(int pos, int top)
      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.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DTMTreeWalker

        public DTMTreeWalker()
        Constructor.
      • DTMTreeWalker

        public DTMTreeWalker​(org.xml.sax.ContentHandler contentHandler,
                             DTM dtm)
        Constructor.
        Parameters:
        contentHandler - The implemention of the contentHandler operation (toXMLString, digest, ...)
    • Method Detail

      • setDTM

        public void setDTM​(DTM dtm)
        Set the DTM to be traversed.
        Parameters:
        dtm - The Document Table Model to be used.
      • getcontentHandler

        public org.xml.sax.ContentHandler getcontentHandler()
        Get the ContentHandler used for the tree walk.
        Returns:
        the ContentHandler used for the tree walk
      • setcontentHandler

        public void setcontentHandler​(org.xml.sax.ContentHandler ch)
        Set the ContentHandler used for the tree walk.
        Parameters:
        ch - the ContentHandler to be the result of the tree walk.
      • traverse

        public void traverse​(int pos)
                      throws org.xml.sax.SAXException
        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:
        TransformerException
        org.xml.sax.SAXException
      • traverse

        public void traverse​(int pos,
                             int top)
                      throws org.xml.sax.SAXException
        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 traversal
        top - Node in the tree where to end traversal. If top==DTM.NULL, run through end of document.
        Throws:
        TransformerException
        org.xml.sax.SAXException