publicinterfaceHashTreeTraverser { /** * The tree traverses itself depth-first, calling addNode for each object it * encounters as it goes. This is a callback method, and should not be * called except by a HashTree during traversal. * * @param node * the node currently encountered * @param subTree * the HashTree under the node encountered */ voidaddNode(Object node, HashTree subTree);
/** * Indicates traversal has moved up a step, and the visitor should remove * the top node from its stack structure. This is a callback method, and * should not be called except by a HashTree during traversal. */ voidsubtractNode();
/** * Process path is called when a leaf is reached. If a visitor wishes to * generate Lists of path elements to each leaf, it should keep a Stack data * structure of nodes passed to it with addNode, and removing top items for * every {@link #subtractNode()} call. This is a callback method, and should * not be called except by a HashTree during traversal. */ voidprocessPath();
/** * Creates an instance of SearchByClass, and sets the Class to be searched * for. * * @param searchClass * class to be searched for */ publicSearchByClass(Class<T> searchClass) { this.searchClass = searchClass; }
/** * After traversing the HashTree, call this method to get a collection of * the nodes that were found. * * @return Collection All found nodes of the requested type */ public Collection<T> getSearchResults() { // TODO specify collection type without breaking callers return objectsOfClass; }
/** * Given a specific found node, this method will return the sub tree of that * node. * * @param root * the node for which the sub tree is requested * @return HashTree */ public HashTree getSubTree(Object root) { return subTrees.get(root); }