Package org.apache.sling.api.resource
Class AbstractResourceVisitor
- java.lang.Object
-
- org.apache.sling.api.resource.AbstractResourceVisitor
-
public abstract class AbstractResourceVisitor extends Object
This visitor will traverse the given resource and all its children in a breadth-first approach and call thevisit(Resource)
method for each visited resource. It decouples the actual traversal code from application code. Concrete subclasses must implement thevisit(Resource)
method.- Since:
- 2.2 (Sling API Bundle 2.2.0)
- See Also:
- Breadth-First-Search
-
-
Constructor Summary
Constructors Constructor Description AbstractResourceVisitor()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
accept(Resource res)
Visit the given resource and all its descendants.protected void
traverseChildren(@NotNull Iterator<Resource> children)
Visit the given resources.protected abstract void
visit(@NotNull Resource res)
Implement this method to do actual work on the resources.
-
-
-
Method Detail
-
accept
public void accept(Resource res)
Visit the given resource and all its descendants.- Parameters:
res
- The resource
-
traverseChildren
protected void traverseChildren(@NotNull @NotNull Iterator<Resource> children)
Visit the given resources.- Parameters:
children
- The list of resources
-
visit
protected abstract void visit(@NotNull @NotNull Resource res)
Implement this method to do actual work on the resources.- Parameters:
res
- The resource
-
-