Package io.quarkus.paths
Interface PathTree
- All Known Subinterfaces:
OpenPathTree
- All Known Implementing Classes:
ArchivePathTree,ArchivePathTree.OpenArchivePathTree,DirectoryPathTree,EmptyPathTree,FilteredPathTree,MultiRootPathTree,OpenContainerPathTree,PathTreeWithManifest
public interface PathTree
-
Method Summary
Modifier and TypeMethodDescriptionvoidConsumes a given path relative to the root of the tree.default voidConsumes a given path relative to the root of the tree.<T> TApplies a function to a given path relative to the root of the tree.booleanChecks whether the tree contains a relative path.default PathTreefilter(PathFilter filter) IfMETA-INF/MANIFEST.MFfound, reads it and returns an instance ofManifestAttributes, a trimmed down version of the Manifest, otherwise returns null.getRoots()The roots of the path tree.booleanWhether the content of this tree comes from an archive or not.default booleanisEmpty()Checks whether the tree is emptystatic PathTreeCreates a newPathTreefor an existing path that is expected to be a ZIP-based archive.static PathTreeofArchive(Path archive, PathFilter filter) Creates a newPathTreefor an existing path that is expected to be a ZIP-based archive applying a providedPathFilterunless it isnull.static PathTreeCreates a newPathTreefor a given existing path which is expected to be either a directory or a ZIP-based archive.static PathTreeofDirectoryOrArchive(Path p, PathFilter filter) Creates a newPathTreefor a given existing path which is expected to be either a directory or a ZIP-based archive applying a providedPathFilterunless it isnull.static PathTreestatic PathTreeofDirectoryOrFile(Path p, PathFilter filter) open()Returns anOpenPathTreefor this tree, which is supposed to be closed at the end of processing.voidwalk(PathVisitor visitor) Walks the tree.voidwalkIfContains(String relativePath, PathVisitor visitor) Walks a subtree of this tree that begins with a passed inrelativePath, if the tree containsrelativePath.
-
Method Details
-
ofDirectoryOrFile
-
ofDirectoryOrFile
-
ofDirectoryOrArchive
Creates a newPathTreefor a given existing path which is expected to be either a directory or a ZIP-based archive.- Parameters:
p- path to a directory or an archive- Returns:
- an instance of
PathTreefor a given existing directory or an archive
-
ofDirectoryOrArchive
Creates a newPathTreefor a given existing path which is expected to be either a directory or a ZIP-based archive applying a providedPathFilterunless it isnull.- Parameters:
p- path to a directory or an archivefilter- path filter to apply, could benull- Returns:
- an instance of
PathTreefor a given existing directory or an archive
-
ofArchive
Creates a newPathTreefor an existing path that is expected to be a ZIP-based archive.- Parameters:
archive- path to an archive- Returns:
- an instance of
PathTreefor a given archive
-
ofArchive
Creates a newPathTreefor an existing path that is expected to be a ZIP-based archive applying a providedPathFilterunless it isnull.- Parameters:
archive- path to an archivefilter- path filter to apply, could benull- Returns:
- an instance of
PathTreefor a given archive
-
isArchiveOrigin
boolean isArchiveOrigin()Whether the content of this tree comes from an archive or not.This is useful for instance when you want to determine if the resources can be updated in dev mode.
-
getRoots
Collection<Path> getRoots()The roots of the path tree.Note that you shouldn't use these roots for browsing except if the PathTree is open.
- Returns:
- roots of the path tree
-
isEmpty
default boolean isEmpty()Checks whether the tree is empty- Returns:
- true, if the tree is empty, otherwise - false
-
getManifestAttributes
ManifestAttributes getManifestAttributes()IfMETA-INF/MANIFEST.MFfound, reads it and returns an instance ofManifestAttributes, a trimmed down version of the Manifest, otherwise returns null.- Returns:
- parsed
META-INF/MANIFEST.MFif it's found, otherwisenull
-
walk
Walks the tree.- Parameters:
visitor- path visitor
-
walkIfContains
Walks a subtree of this tree that begins with a passed inrelativePath, if the tree containsrelativePath. If the tree does not containrelativePaththen the method returns without an error.This method does not create a new
PathTreewith the root atrelativePath. It simply applies an inclusion filter to thisPathTreeinstance, keeping the same root.- Parameters:
relativePath- relative path from which the walk should beginvisitor- path visitor
-
apply
Applies a function to a given path relative to the root of the tree. If the path isn't found in the tree, thePathVisitargument passed to the function will benull.- Type Parameters:
T- resulting type- Parameters:
relativePath- relative path to processfunc- processing function- Returns:
- result of the function
-
accept
Consumes a given path relative to the root of the tree. If the path isn't found in the tree, thePathVisitargument passed to the consumer will benull.- Parameters:
relativePath- relative path to consumeconsumer- path consumer
-
acceptAll
Consumes a given path relative to the root of the tree. If the path isn't found in the tree, thePathVisitargument passed to the consumer will benull. If multiple items match then the consumer will be called multiple times.- Parameters:
relativePath- relative path to consumeconsumer- path consumer
-
contains
Checks whether the tree contains a relative path.- Parameters:
relativePath- path relative to the root of the tree- Returns:
- true, in case the tree contains the path, otherwise - false
-
open
OpenPathTree open()Returns anOpenPathTreefor this tree, which is supposed to be closed at the end of processing. It is meant to be an optimization when processing multiple paths of path trees that represent archives. If a path tree does not represent an archive but a directory, for example, this method is expected to be a no-op, returning the original tree as an instance ofOpenPathTree.- Returns:
- an instance of
OpenPathTreefor this path tree
-
filter
-