Class AntPatternFileCollector
- java.lang.Object
-
- jetbrains.buildServer.util.pathMatcher.AntPatternFileCollector
-
public class AntPatternFileCollector extends Object
- Since:
- 8.1
- Author:
- Sergey.Pak Date: 6/24/13 Time: 7:19 PM
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AntPatternFileCollector.ScanOption
-
Constructor Summary
Constructors Constructor Description AntPatternFileCollector()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static List<File>
scanDir(File baseDir, String[] includeRules, String[] excludeRules, AntPatternFileCollector.ScanOption[] options)
Ant-style files collector (supports double-stars **).static List<File>
scanDir(File baseDir, String[] rules, AntPatternFileCollector.ScanOption[] options)
Ant-style files collector (supports double-stars **).static Iterator<File>
scanDirIteratively(File baseDir, String[] rules, AntPatternFileCollector.ScanOption[] options)
static String
validate(File baseDir, String[] includePatterns, String[] excludePatterns, AntPatternFileCollector.ScanOption... options)
Will not perform any scan.
-
-
-
Method Detail
-
scanDir
public static List<File> scanDir(@NotNull File baseDir, @NotNull String[] includeRules, @NotNull String[] excludeRules, @Nullable AntPatternFileCollector.ScanOption[] options)
Ant-style files collector (supports double-stars **).
Rules:
-
Rules are applied in the order they were provided. As soon as file matches the first rule, no further rules will apply to it (like iptables in Linux).
Only files (
File.isFile()
==true) are collected By default no rules at all results in no files are collected, but if there only exclude rules, all files except excluded ones will be collectedAvailable options:
-
PRIORITIZE_EXCLUDES - exclude rules are applied first.
Without this options rules are applied in the order they were submitted
USE_RULE_STRICTNESS - applies stricter rules first. Rule is considered stricter than other rule only if its
match area always lays completely within other rules match area, for example
- MATCH_DIRECTORIES - matches directories and includes them into the result. This applies only to directories that match the rule(s) completely. Intermediate directories are not included.
a*ba.xml
is stricter thana*ba.*
, but nota*cba.*
.
Rules are compared by pairs. If it cannot be determined which one is stricter, rules are applied in the order they were supplied INCLUDE_ALL_IF_NO_RULES - if no rules are provided all files under baseDir will be included into search results. ALLOW_EXTERNAL_SCAN - Allows scan outside of baseDir. This option is required if you'd like to use rules like ..\*\*.txt. It is also required for absolute path rules NOT_FOLLOW_SYMLINK_DIRS - while searching attempts to resolve symlink directories and if directory is a symlink - it will be skipped- Parameters:
baseDir
- - directory to start scan fromincludeRules
- - not null array of include rules. one string - one rule.excludeRules
- - not null array of exclude rules. one string - one rule. Exclude rules apply firstoptions
- - nullable array of options. See above for details- Returns:
- List of files that match search criteria
-
scanDir
public static List<File> scanDir(@NotNull File baseDir, @NotNull String[] rules, @Nullable AntPatternFileCollector.ScanOption[] options)
Ant-style files collector (supports double-stars **).
Rules:
-
Rules are applied in the order they were provided. As soon as file matches the first rule, no further rules will apply to it (like iptables in Linux).
Only files (
File.isFile()
==true) are collected By default no rules at all results in no files are collected, but if there only exclude rules, all files except excluded ones will be collectedAvailable options:
-
PRIORITIZE_EXCLUDES - exclude rules are applied first.
Without this options rules are applied in the order they were submitted
USE_RULE_STRICTNESS - applies stricter rules first. Rule is considered stricter than other rule only if its
match area always lays completely within other rules match area, for example
- MATCH_DIRECTORIES - matches directories and includes them into the result. This applies only to directories that match the rule(s) completely. Intermediate directories are not included.
a*ba.xml
is stricter thana*ba.*
, but nota*cba.*
.
Rules are compared by pairs. If it cannot be determined which one is stricter, rules are applied in the order they were supplied INCLUDE_ALL_IF_NO_RULES - if no rules are provided all files under baseDir will be included into search results. ALLOW_EXTERNAL_SCAN - Allows scan outside of baseDir. This option is required if you'd like to use rules like ..\*\*.txt. It is also required for absolute path rules NOT_FOLLOW_SYMLINK_DIRS - while searching attempts to resolve symlink directories and if directory is a symlink - it will be skipped- Parameters:
baseDir
- - directory to start scan fromrules
- - not null array of rules. one string - one rule.options
- - nullable array of options. See above for details- Returns:
- List of files that match search criteria
-
scanDirIteratively
public static Iterator<File> scanDirIteratively(@NotNull File baseDir, @NotNull String[] rules, @Nullable AntPatternFileCollector.ScanOption[] options)
-
validate
@Nullable public static String validate(@NotNull File baseDir, @NotNull String[] includePatterns, @NotNull String[] excludePatterns, @Nullable AntPatternFileCollector.ScanOption... options)
Will not perform any scan. Will only check parameters returning error message if any.
- Parameters:
includePatterns
- - not null array of include rules. one string - one rule.excludePatterns
- - not null array of exclude rules. one string - one rule. Exclude rules apply firstoptions
- - nullable array of options. See above for details- Returns:
- Error if any, null if rules are applicable
-
-