Class FindNodeVisitor<T>

  • Type Parameters:
    T - the type of the nodes to be visited
    All Implemented Interfaces:
    ConfigurationNodeVisitor<T>

    final class FindNodeVisitor<T>
    extends ConfigurationNodeVisitorAdapter<T>

    A specialized NodeVisitor implementation which searches for a specific node in a hierarchy.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private boolean found
      A flag whether the node was found.
      private T searchNode
      The node to be searched for.
    • Constructor Summary

      Constructors 
      Constructor Description
      FindNodeVisitor​(T node)
      Creates a new instance of FindNodeVisitor and sets the node to be searched for.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean isFound()
      Returns a flag whether the search node was found in the last search operation.
      void reset()
      Resets this visitor.
      boolean terminate()
      Returns a flag whether the current visit process should be aborted.
      void visitBeforeChildren​(T node, NodeHandler<T> handler)
      Visits the specified node before the children of this node - if existing - are processed.
      • Methods inherited from class java.lang.Object

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

      • searchNode

        private final T searchNode
        The node to be searched for.
      • found

        private boolean found
        A flag whether the node was found.
    • Constructor Detail

      • FindNodeVisitor

        public FindNodeVisitor​(T node)
        Creates a new instance of FindNodeVisitor and sets the node to be searched for.
        Parameters:
        node - the search node
    • Method Detail

      • isFound

        public boolean isFound()
        Returns a flag whether the search node was found in the last search operation.
        Returns:
        true if the search node was found; false otherwise
      • reset

        public void reset()
        Resets this visitor. This method sets the found property to false again, so that this instance can be used to inspect another nodes hierarchy.
      • terminate

        public boolean terminate()
        Returns a flag whether the current visit process should be aborted. This method allows a visitor implementation to state that it does not need any further data. It may be used e.g. by visitors that search for a certain node in the hierarchy. After that node was found, there is no need to process the remaining nodes, too. This method is called after each visited node. A result of true indicates that the current iteration is to be aborted. This implementation returns always false; this means that all nodes in the current hierarchy are traversed. This implementation returns true as soon as the node was found.
        Specified by:
        terminate in interface ConfigurationNodeVisitor<T>
        Overrides:
        terminate in class ConfigurationNodeVisitorAdapter<T>
        Returns:
        a flag if the visit process should be stopped