Class FindNodeVisitor<T>

java.lang.Object
org.apache.commons.configuration2.tree.ConfigurationNodeVisitorAdapter<T>
org.apache.commons.configuration2.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
    A flag whether the node was found.
    private final T
    The node to be searched for.
  • Constructor Summary

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

    Modifier and Type
    Method
    Description
    boolean
    Returns a flag whether the search node was found in the last search operation.
    void
    Resets this visitor.
    boolean
    Returns a flag whether the current visit process should be aborted.
    void
    Visits the specified node before the children of this node - if existing - are processed.

    Methods inherited from class org.apache.commons.configuration2.tree.ConfigurationNodeVisitorAdapter

    visitAfterChildren

    Methods inherited from class java.lang.Object

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

    • searchNode

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

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

    • 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 Details

    • visitBeforeChildren

      public void visitBeforeChildren(T node, NodeHandler<T> handler)
      Description copied from class: ConfigurationNodeVisitorAdapter
      Visits the specified node before the children of this node - if existing - are processed. Empty dummy implementation of this interface method.
      Specified by:
      visitBeforeChildren in interface ConfigurationNodeVisitor<T>
      Overrides:
      visitBeforeChildren in class ConfigurationNodeVisitorAdapter<T>
      Parameters:
      node - the node to be visited
      handler - the NodeHandler
    • 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
    • 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.