public static class PathWatcher.Config
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected java.nio.file.Path |
dir |
protected boolean |
excludeHidden |
protected java.util.List<java.nio.file.PathMatcher> |
excludes |
protected java.util.List<java.nio.file.PathMatcher> |
includes |
protected int |
recurseDepth |
static int |
UNLIMITED_DEPTH |
Constructor and Description |
---|
Config(java.nio.file.Path path) |
Modifier and Type | Method and Description |
---|---|
void |
addExclude(java.nio.file.PathMatcher matcher)
Add an exclude PathMatcher
|
void |
addExclude(java.lang.String syntaxAndPattern)
Add an exclude PathMatcher.
|
void |
addExcludeGlobRelative(java.lang.String pattern)
Add a
glob: syntax pattern exclude reference in a directory relative, os neutral, pattern. |
void |
addExcludeHidden()
Exclude hidden files and hidden directories
|
void |
addExcludes(java.util.List<java.lang.String> syntaxAndPatterns)
Add multiple exclude PathMatchers
|
void |
addInclude(java.nio.file.PathMatcher matcher)
Add an include PathMatcher
|
void |
addInclude(java.lang.String syntaxAndPattern)
Add an include PathMatcher
|
void |
addIncludeGlobRelative(java.lang.String pattern)
Add a
glob: syntax pattern reference in a directory relative, os neutral, pattern. |
void |
addIncludes(java.util.List<java.lang.String> syntaxAndPatterns)
Add multiple include PathMatchers
|
PathWatcher.Config |
asSubConfig(java.nio.file.Path dir)
Build a new config from a this configuration.
|
java.nio.file.Path |
getPath() |
int |
getRecurseDepth() |
boolean |
isExcluded(java.nio.file.Path dir) |
boolean |
isIncluded(java.nio.file.Path dir) |
boolean |
isRecurseDepthUnlimited() |
boolean |
matches(java.nio.file.Path path) |
void |
setRecurseDepth(int depth)
Set the recurse depth for the directory scanning.
|
boolean |
shouldRecurseDirectory(java.nio.file.Path child)
Determine if the provided child directory should be recursed into based on the configured
setRecurseDepth(int) |
java.lang.String |
toString() |
public static final int UNLIMITED_DEPTH
protected final java.nio.file.Path dir
protected int recurseDepth
protected java.util.List<java.nio.file.PathMatcher> includes
protected java.util.List<java.nio.file.PathMatcher> excludes
protected boolean excludeHidden
public void addExclude(java.nio.file.PathMatcher matcher)
matcher
- the path matcher for this excludepublic void addExclude(java.lang.String syntaxAndPattern)
Note: this pattern is FileSystem specific (so use "/" for Linux and OSX, and "\\" for Windows)
syntaxAndPattern
- the PathMatcher syntax and pattern to usefor detail on syntax and pattern
public void addExcludeGlobRelative(java.lang.String pattern)
glob:
syntax pattern exclude reference in a directory relative, os neutral, pattern.
On Linux: Config config = new Config(Path("/home/user/example")); config.addExcludeGlobRelative("*.war") => "glob:/home/user/example/*.war" On Windows Config config = new Config(Path("D:/code/examples")); config.addExcludeGlobRelative("*.war") => "glob:D:\\code\\examples\\*.war"
pattern
- the pattern, in unixy format, relative to config.dirpublic void addExcludeHidden()
public void addExcludes(java.util.List<java.lang.String> syntaxAndPatterns)
syntaxAndPatterns
- the list of PathMatcher syntax and patterns to usefor detail on syntax and pattern
public void addInclude(java.nio.file.PathMatcher matcher)
matcher
- the path matcher for this includepublic void addInclude(java.lang.String syntaxAndPattern)
syntaxAndPattern
- the PathMatcher syntax and pattern to usefor detail on syntax and pattern
public void addIncludeGlobRelative(java.lang.String pattern)
glob:
syntax pattern reference in a directory relative, os neutral, pattern.
On Linux: Config config = new Config(Path("/home/user/example")); config.addIncludeGlobRelative("*.war") => "glob:/home/user/example/*.war" On Windows Config config = new Config(Path("D:/code/examples")); config.addIncludeGlobRelative("*.war") => "glob:D:\\code\\examples\\*.war"
pattern
- the pattern, in unixy format, relative to config.dirpublic void addIncludes(java.util.List<java.lang.String> syntaxAndPatterns)
syntaxAndPatterns
- the list of PathMatcher syntax and patterns to usefor detail on syntax and pattern
public PathWatcher.Config asSubConfig(java.nio.file.Path dir)
Useful for working with sub-directories that also need to be watched.
dir
- the directory to build new Config from (using this config as source of includes/excludes)public int getRecurseDepth()
public boolean isRecurseDepthUnlimited()
public java.nio.file.Path getPath()
public boolean isExcluded(java.nio.file.Path dir) throws java.io.IOException
java.io.IOException
public boolean isIncluded(java.nio.file.Path dir)
public boolean matches(java.nio.file.Path path)
public void setRecurseDepth(int depth)
-999 indicates arbitrarily deep recursion, 0 indicates no recursion, 1 is only one directory deep, and so on.
depth
- the number of directories deep to recursepublic boolean shouldRecurseDirectory(java.nio.file.Path child)
setRecurseDepth(int)
child
- the child directory to test againstpublic java.lang.String toString()
toString
in class java.lang.Object
Copyright © 1995–2017 Webtide. All rights reserved.