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 boolean
A flag whether the node was found.private final T
The node to be searched for. -
Constructor Summary
ConstructorsConstructorDescriptionFindNodeVisitor
(T node) Creates a new instance ofFindNodeVisitor
and sets the node to be searched for. -
Method Summary
Modifier and TypeMethodDescriptionboolean
isFound()
Returns a flag whether the search node was found in the last search operation.void
reset()
Resets this visitor.boolean
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 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 ofFindNodeVisitor
and sets the node to be searched for.- Parameters:
node
- the search node
-
-
Method Details
-
visitBeforeChildren
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 interfaceConfigurationNodeVisitor<T>
- Overrides:
visitBeforeChildren
in classConfigurationNodeVisitorAdapter<T>
- Parameters:
node
- the node to be visitedhandler
- theNodeHandler
-
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 interfaceConfigurationNodeVisitor<T>
- Overrides:
terminate
in classConfigurationNodeVisitorAdapter<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 thefound
property to false again, so that this instance can be used to inspect another nodes hierarchy.
-