Class TreeVisitor


  • public abstract class TreeVisitor
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected boolean traverseDeeper  
    • Constructor Summary

      Constructors 
      Constructor Description
      TreeVisitor()  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      static javax.swing.tree.TreePath depthFirstSearch​(javax.swing.tree.TreeNode root, TreeVisitor visitor)
      Performs a depth first search starting at the root node provided.
      abstract boolean visit​(javax.swing.tree.TreeNode node)
      This will be called for each tree node in the tree.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • traverseDeeper

        protected boolean traverseDeeper
    • Constructor Detail

      • TreeVisitor

        public TreeVisitor()
    • Method Detail

      • visit

        public abstract boolean visit​(javax.swing.tree.TreeNode node)
        This will be called for each tree node in the tree. Returning true indicates a matching node. As an optional performance improvement, set the boolean field traverseDeeper to false if nothing under this node could be a match.
        Returns:
        If true, the search will stop and this node's TreePath will be considered as the match. If false, the search will continue.
      • depthFirstSearch

        public static javax.swing.tree.TreePath depthFirstSearch​(javax.swing.tree.TreeNode root,
                                                                 TreeVisitor visitor)
        Performs a depth first search starting at the root node provided. Returns the TreePath of the first node that the visitor returns true for.