public final class JkPathTree
extends java.lang.Object
JkPathTree
may have some include/exclude filters to include only
or exclude specified files.JkPathTree
, we mean all
files contained in its root directory or sub-directories, matching positively
the filter defined on it.Modifier and Type | Method and Description |
---|---|
JkPathTree |
andMatcher(java.nio.file.PathMatcher pathMatcher)
Creates a copy of this
JkPathTree augmented with the specified JkPathMatcher |
JkPathTree |
andMatching(boolean positive,
java.lang.Iterable<java.lang.String> globPatterns)
Creates a copy of this
JkPathTree augmented with the specified pattern matcher. |
JkPathTree |
andMatching(boolean positive,
java.lang.String... globPatterns)
Creates a copy of this
JkPathTree augmented with the specified pattern matcher. |
JkPathTree |
andMatching(java.lang.String... globPatterns)
Shorthand to
andMatching(true, globPatterns...) . |
JkPathTree |
bring(java.lang.Iterable<java.nio.file.Path> files,
java.nio.file.StandardCopyOption... copyOptions)
Copies the specified files at the root of this tree.
|
int |
copyTo(java.nio.file.Path destinationDir,
java.nio.file.CopyOption... copyOptions)
Copies files contained in this
JkPathTree to the specified directory. |
int |
count(int max,
boolean includeDirectories)
Returns the file count contained in this
JkPathTree to concurrence to specified max count. |
JkPathTree |
createIfNotExist()
Creates root directory if not exists.
|
JkPathTree |
deleteContent()
Deletes each and every files in this tree except the root and files not matching this tree filter.
|
JkPathTree |
deleteRoot()
Deletes root directory of this tree.
|
boolean |
exists()
Returns
true if the root directory exists. |
java.nio.file.Path |
get(java.lang.String relativePath)
Returns path relative to this root of the specified relative path.
|
java.util.List<java.nio.file.Path> |
getFiles()
Returns list of paths returned by
stream(FileVisitOption...) but excluding directories from the result. |
JkPathMatcher |
getMatcher()
Returns the filter defined on this
JkPathTree , never null . |
java.util.List<java.nio.file.Path> |
getRelativeFiles()
Same as
getFiles() but returning paths relative to this tree root. |
java.nio.file.Path |
getRoot()
Returns the root directory.
|
java.nio.file.Path |
getRootDirOrZipFile()
Returns root directory if this tree is a directory tree and returns a zip file if this
tree has been created from a zip file.
|
JkPathTree |
goTo(java.lang.String relativePath)
Creates a
JkPathTree having the specified relative path to this root as getRoot directory. |
boolean |
isDefineMatcher()
Returns true if a matcher has explicitly been defined on this tree.
|
JkPathTree |
merge(JkPathTree tree,
java.nio.file.CopyOption... copyOptions)
Copies the content of the specified tree at the root of this one.
|
JkPathTree |
merge(java.nio.file.Path dirToCopy,
java.nio.file.CopyOption... copyOptions)
Short hand for
#merge(JkPathTree.of(dirToCopy, copyOptions) . |
static JkPathTree |
of(java.nio.file.Path rootDir)
Creates a
JkPathTree having the specified root directory. |
static JkPathTree |
ofZip(java.nio.file.Path zipFile)
Creates a
JkPathTree having the specified root directory. |
JkPathTree |
resolve(java.nio.file.Path path)
If the root of this tree is absolute then this method returns this tree.
|
java.util.stream.Stream<java.nio.file.Path> |
stream(java.nio.file.FileVisitOption... options)
Returns a path getOutputStream of all files of this tree.
|
JkPathTreeSet |
toSet()
Returns a
JkPathTreeSet containing this tree as its single
element. |
java.lang.String |
toString() |
JkPathTree |
withMatcher(JkPathMatcher pathMatcher)
Creates a
JkPathTree which is a copy of this JkPathTree
but the matcher is replaced with the specified one. |
JkPathTree |
zipTo(java.nio.file.Path destination)
Zips the content of this tree to the specified destination file.
|
public static JkPathTree of(java.nio.file.Path rootDir)
JkPathTree
having the specified root directory.public static JkPathTree ofZip(java.nio.file.Path zipFile)
JkPathTree
having the specified root directory.public java.nio.file.Path getRoot()
public java.nio.file.Path getRootDirOrZipFile()
public JkPathMatcher getMatcher()
JkPathTree
, never null
.public boolean isDefineMatcher()
public boolean exists()
true
if the root directory exists.public JkPathTree createIfNotExist()
public java.util.stream.Stream<java.nio.file.Path> stream(java.nio.file.FileVisitOption... options)
public java.util.List<java.nio.file.Path> getRelativeFiles()
getFiles()
but returning paths relative to this tree root.public java.util.List<java.nio.file.Path> getFiles()
stream(FileVisitOption...)
but excluding directories from the result.public JkPathTree goTo(java.lang.String relativePath)
JkPathTree
having the specified relative path to this root as getRoot directory.
Note that the returned tree has no filter even if this tree has one.public java.nio.file.Path get(java.lang.String relativePath)
public JkPathTree merge(java.nio.file.Path dirToCopy, java.nio.file.CopyOption... copyOptions)
#merge(JkPathTree.of(dirToCopy, copyOptions)
.public JkPathTree merge(JkPathTree tree, java.nio.file.CopyOption... copyOptions)
public JkPathTree bring(java.lang.Iterable<java.nio.file.Path> files, java.nio.file.StandardCopyOption... copyOptions)
public JkPathTree deleteContent()
public JkPathTree deleteRoot()
public JkPathTree zipTo(java.nio.file.Path destination)
public int copyTo(java.nio.file.Path destinationDir, java.nio.file.CopyOption... copyOptions)
JkPathTree
to the specified directory.public JkPathTree andMatcher(java.nio.file.PathMatcher pathMatcher)
JkPathTree
augmented with the specified JkPathMatcher
public JkPathTree withMatcher(JkPathMatcher pathMatcher)
JkPathTree
which is a copy of this JkPathTree
but the matcher is replaced with the specified one.public JkPathTree andMatching(boolean positive, java.lang.String... globPatterns)
JkPathTree
augmented with the specified pattern matcher.public JkPathTree andMatching(java.lang.String... globPatterns)
andMatching(true, globPatterns...)
.public JkPathTree andMatching(boolean positive, java.lang.Iterable<java.lang.String> globPatterns)
JkPathTree
augmented with the specified pattern matcher.public int count(int max, boolean includeDirectories)
JkPathTree
to concurrence to specified max count.
If the effective count is greater than max count, returns max + 1
.
This method is designed to stop file traversal as soon as count is greater than max.public JkPathTree resolve(java.nio.file.Path path)
public JkPathTreeSet toSet()
JkPathTreeSet
containing this tree as its single
element.public java.lang.String toString()
toString
in class java.lang.Object