Package org.apache.sling.api.resource
Class AbstractResourceVisitor
java.lang.Object
org.apache.sling.api.resource.AbstractResourceVisitor
This visitor will traverse the given resource and all its children in a depth-first approach
and call the
visit(Resource)
method for each visited resource.
It decouples the actual traversal code from application code.
Concrete subclasses must implement the visit(Resource)
method.
There is no possibility to stop traversal in this visitor. If you want to skip certain
parts of the subtree or stop traversal at a certain point rather use
ResourceStream
or
ResourceFilterStream
.- Since:
- 2.2 (Sling API Bundle 2.2.0)
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Visit the given resource and all its descendants.protected void
traverseChildren
(@NotNull Iterator<Resource> children) Visit the given resources.protected abstract void
Implement this method to do actual work on the resources.
-
Constructor Details
-
AbstractResourceVisitor
public AbstractResourceVisitor()
-
-
Method Details
-
accept
Visit the given resource and all its descendants.- Parameters:
res
- The resource
-
traverseChildren
Visit the given resources.- Parameters:
children
- The list of resources
-
visit
Implement this method to do actual work on the resources.- Parameters:
res
- The resource
-