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>
A specialized NodeVisitor implementation which searches for a specific node in a hierarchy.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanA flag whether the node was found.private final TThe node to be searched for. -
Constructor Summary
ConstructorsConstructorDescriptionFindNodeVisitor(T node) Creates a new instance ofFindNodeVisitorand sets the node to be searched for. -
Method Summary
Modifier and TypeMethodDescriptionbooleanisFound()Returns a flag whether the search node was found in the last search operation.voidreset()Resets this visitor.booleanReturns a flag whether the current visit process should be aborted.voidvisitBeforeChildren(T node, NodeHandler<T> handler) 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
-
Field Details
-
searchNode
The node to be searched for. -
found
private boolean foundA flag whether the node was found.
-
-
Constructor Details
-
FindNodeVisitor
Creates a new instance ofFindNodeVisitorand sets the node to be searched for.- Parameters:
node- the search node
-
-
Method Details
-
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 thefoundproperty 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:
terminatein interfaceConfigurationNodeVisitor<T>- Overrides:
terminatein classConfigurationNodeVisitorAdapter<T>- Returns:
- a flag if the visit process should be stopped
-
visitBeforeChildren
Description copied from class:ConfigurationNodeVisitorAdapterVisits the specified node before the children of this node - if existing - are processed. Empty dummy implementation of this interface method.- Specified by:
visitBeforeChildrenin interfaceConfigurationNodeVisitor<T>- Overrides:
visitBeforeChildrenin classConfigurationNodeVisitorAdapter<T>- Parameters:
node- the node to be visitedhandler- theNodeHandler
-