本文整理汇总了Java中org.apache.tools.ant.types.selectors.SelectorUtils类的典型用法代码示例。如果您正苦于以下问题:Java SelectorUtils类的具体用法?Java SelectorUtils怎么用?Java SelectorUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SelectorUtils类属于org.apache.tools.ant.types.selectors包,在下文中一共展示了SelectorUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findStrayThirdPartyBinaries
import org.apache.tools.ant.types.selectors.SelectorUtils; //导入依赖的package包/类
private void findStrayThirdPartyBinaries(File dir, String prefix, Set<String> violations, List<String> ignoredPatterns) throws IOException {
for (String n : findHgControlledFiles(dir)) {
File f = new File(dir, n);
if (f.isDirectory()) {
findStrayThirdPartyBinaries(f, prefix + n + "/", violations, ignoredPatterns);
} else if (n.matches(".*\\.(jar|zip)")) {
String path = prefix + n;
boolean ignored = false;
for (String pattern : ignoredPatterns) {
if (SelectorUtils.matchPath(pattern, path)) {
ignored = true;
break;
}
}
if (!ignored && dir.getName().equals("external") &&
new File(new File(dir.getParentFile(), "nbproject"), "project.xml").isFile()) {
ignored = true;
}
if (!ignored) {
violations.add(path);
} else {
//System.err.println("accepted: " + path);
}
}
}
}
示例2: scanForExtraFiles
import org.apache.tools.ant.types.selectors.SelectorUtils; //导入依赖的package包/类
private void scanForExtraFiles(File d, String prefix, Set<String> files, String cluster, StringBuilder extraFiles) {
if (prefix.equals("update_tracking/")) {
return;
}
for (String n : d.list()) {
File f = new File(d, n);
if (f.getName().equals(".lastModified")) {
continue;
}
if (f.isDirectory()) {
scanForExtraFiles(f, prefix + n + "/", files, cluster, extraFiles);
} else {
String path = prefix + n;
if ( patterns != null )
for( String p: patterns.getExcludePatterns(getProject()) )
if (SelectorUtils.matchPath(p, path)) return;
if (!files.contains(path)) {
extraFiles.append("\n" + cluster + ": untracked file " + path);
f.delete();
}
}
}
}
示例3: matchesArtifactPattern
import org.apache.tools.ant.types.selectors.SelectorUtils; //导入依赖的package包/类
public synchronized boolean matchesArtifactPattern( String relativePath )
{
// Correct the slash pattern.
relativePath = relativePath.replace( '\\', '/' );
if ( artifactPatterns == null )
{
artifactPatterns = getFileTypePatterns( ARTIFACTS );
}
for ( String pattern : artifactPatterns )
{
if ( SelectorUtils.matchPath( pattern, relativePath, false ) )
{
// Found match
return true;
}
}
// No match.
return false;
}
示例4: matchesDefaultExclusions
import org.apache.tools.ant.types.selectors.SelectorUtils; //导入依赖的package包/类
public boolean matchesDefaultExclusions( String relativePath )
{
// Correct the slash pattern.
relativePath = relativePath.replace( '\\', '/' );
for ( String pattern : DEFAULT_EXCLUSIONS )
{
if ( SelectorUtils.matchPath( pattern, relativePath, false ) )
{
// Found match
return true;
}
}
// No match.
return false;
}
示例5: isIgnored
import org.apache.tools.ant.types.selectors.SelectorUtils; //导入依赖的package包/类
private static boolean isIgnored(
final String[] patterns,
final String resource) {
for (String pattern : patterns) {
if (SelectorUtils.match(pattern, resource)) {
return true;
}
}
return false;
}
示例6: excluded
import org.apache.tools.ant.types.selectors.SelectorUtils; //导入依赖的package包/类
private boolean excluded(File f, String prefix) { // #68929
String pathAbs = f.getAbsolutePath();
if (!pathAbs.startsWith(prefix)) {
throw new BuildException("Examined file " + f + " should have a path starting with " + prefix, getLocation());
}
// Cannot just call matchPath on the pathAbs because a relative pattern will *never* match an absolute path!
String path = pathAbs.substring(prefix.length());
for (String exclude : DirectoryScanner.getDefaultExcludes()) {
if (SelectorUtils.matchPath(exclude.replace('/', File.separatorChar), path)) {
return true;
}
}
return false;
}
示例7: matchesPattern
import org.apache.tools.ant.types.selectors.SelectorUtils; //导入依赖的package包/类
/**
* Tests whitelist and blacklist patterns against path.
*
* @param path the path to test.
* @param patterns the list of patterns to check.
* @return true if the path matches at least 1 pattern in the provided patterns list.
*/
private boolean matchesPattern( String path, List<String> patterns )
{
if ( CollectionUtils.isEmpty( patterns ) )
{
return false;
}
if ( !path.startsWith( "/" ) )
{
path = "/" + path;
}
for ( String pattern : patterns )
{
if ( !pattern.startsWith( "/" ) )
{
pattern = "/" + pattern;
}
if ( SelectorUtils.matchPath( pattern, path, false ) )
{
return true;
}
}
return false;
}
示例8: isCandidate
import org.apache.tools.ant.types.selectors.SelectorUtils; //导入依赖的package包/类
/**
* flow:
*
* 0. no match for extension -> return false
* 1. no include, no exclude -> don't filter. return true
* 2. no include, yes exclude -> return isExcludeMatch(file) ? false : true
* 3. yes include, no exclude -> return isIncludeMatch(file) ? true : false
*
* 4. yes include, yes exclude ->
* if(isExcludeMatch(file)) {
* return false
* }
*
* return isIncludeMatch(file))
*
* @param relativePath
* @return
*/
private boolean isCandidate(String relativePath, String[] extensions, List<String> includeFilter, List<String> excludeFilter) {
relativePath = relativePath.replaceAll("\\\\", "/");
boolean isMatch = true;
if(!isExtension(relativePath, extensions)) {
return false;
}
if(excludeFilter != null) {
for (String exclusion : excludeFilter) {
if(SelectorUtils.matchPath(exclusion, relativePath, false)) {
return false;
}
}
}
if(includeFilter.size() > 0) {
for (String inclusion : includeFilter) {
if(SelectorUtils.matchPath(inclusion, relativePath, false)) {
return true;
}
}
isMatch = false;
}
return isMatch;
}
示例9: isExcluded
import org.apache.tools.ant.types.selectors.SelectorUtils; //导入依赖的package包/类
@Override
public boolean isExcluded(String name) {
boolean excluded = false;
for (int p = 0; !excluded && p < patterns.size(); p++) {
excluded = SelectorUtils.match(patterns.get(p), name);
}
return excluded;
}
示例10: match
import org.apache.tools.ant.types.selectors.SelectorUtils; //导入依赖的package包/类
/**
* Convert the paths into absolute normalized paths and match or test for prefix equality.
*
* @param pattern the path representing the pattern
* @param path the path to be matched
* @param prefix do a prefix check of <code>pattern</code> in <code>path</code> or match
* <code>pattern</code> as ANT pattern in <code>path</code>
* @return <code>true</code> if <code>path</code> matches <code>pattern</code>, <code>false</code> else
*/
private static boolean match(Path pattern, Path path, boolean prefix) {
boolean result;
// just use the ANT stuff / prefix but use the absolute paths
String sPattern = PathUtils.normalize(pattern.getAbsolutePath().getAbsolutePath());
String sPath = PathUtils.normalize(path.getAbsolutePath().getAbsolutePath());
if (prefix) {
result = sPath.startsWith(sPattern);
} else {
result = SelectorUtils.matchPath(sPattern, sPath);
}
return result;
}
示例11: preparePattern
import org.apache.tools.ant.types.selectors.SelectorUtils; //导入依赖的package包/类
/**
* Prepares the given pattern conventions.
*
* @param pattern the pattern to be prepared
* @return the prepared pattern, may be <code>pattern</code> if nothing is changed
*/
private static String preparePattern(String pattern) {
pattern = pattern.trim();
// shall already be normalized but just to be sure
pattern = pattern.replace('\\', NORMALIZED_FILE_SEPARATOR_CHAR);
pattern = pattern.replace(NORMALIZED_FILE_SEPARATOR + NORMALIZED_FILE_SEPARATOR, NORMALIZED_FILE_SEPARATOR);
// see http://ant.apache.org/manual/dirtasks.html
if (pattern.endsWith(NORMALIZED_FILE_SEPARATOR)) {
pattern += SelectorUtils.DEEP_TREE_MATCH;
}
// remove duplicated **/** -> **
pattern = pattern.replace(SelectorUtils.DEEP_TREE_MATCH + NORMALIZED_FILE_SEPARATOR
+ SelectorUtils.DEEP_TREE_MATCH, SelectorUtils.DEEP_TREE_MATCH);
return pattern;
}
示例12: tokenize
import org.apache.tools.ant.types.selectors.SelectorUtils; //导入依赖的package包/类
/**
* Tokenizes the given path according to wildcards.
*
* @param text the text to be tokenized
* @param considerSeparator tokenize also separators
* @return the tokens
*/
private static List<String> tokenize(String text, boolean considerSeparator) {
List<String> result = new ArrayList<String>();
int i = 0;
int len = text.length();
int lastMatch = -1;
while (i < len) {
char c = text.charAt(i);
if (MULTIPLE_CHAR_MATCH_CHAR == c) {
if (i > 0) {
result.add(text.substring(lastMatch + 1, i));
}
if (i + 1 < len && MULTIPLE_CHAR_MATCH_CHAR == text.charAt(i + 1)) {
result.add(SelectorUtils.DEEP_TREE_MATCH);
i++;
} else {
result.add("*");
}
lastMatch = i;
} else if (SINGLE_CHAR_MATCH_CHAR == c) {
if (i > 0) {
result.add(text.substring(lastMatch + 1, i));
}
result.add(SINGLE_CHAR_MATCH);
lastMatch = i;
} else if (considerSeparator && NORMALIZED_FILE_SEPARATOR_CHAR == c) {
result.add(text.substring(lastMatch + 1, i));
result.add(NORMALIZED_FILE_SEPARATOR);
lastMatch = i;
}
i++;
}
if (lastMatch + 1 < len) {
result.add(text.substring(lastMatch + 1, len));
}
return result;
}
示例13: shouldSkipPattern
import org.apache.tools.ant.types.selectors.SelectorUtils; //导入依赖的package包/类
/**
* true if the pattern specifies a relative path without basedir
* or an absolute path not inside basedir.
*
* @since Ant 1.8.0
*/
private boolean shouldSkipPattern(final String pattern) {
if (FileUtils.isAbsolutePath(pattern)) {
//skip abs. paths not under basedir, if set:
if (!(basedir == null || SelectorUtils.matchPatternStart(pattern,
basedir.getAbsolutePath(),
isCaseSensitive()))) {
return true;
}
} else if (basedir == null) {
//skip non-abs. paths if basedir == null:
return true;
}
return false;
}
示例14: isCaseSensitive
import org.apache.tools.ant.types.selectors.SelectorUtils; //导入依赖的package包/类
/**
* Test whether all contents of the specified directory must be excluded.
* @param path the path to check.
* @return whether all the specified directory's contents are excluded.
*/
/* package */ boolean contentsExcluded(final TokenizedPath path) {
return Stream.of(excludePatterns)
.filter(p -> p.endsWith(SelectorUtils.DEEP_TREE_MATCH))
.map(TokenizedPattern::withoutLastToken)
.anyMatch(wlt -> wlt.matchPath(path, isCaseSensitive()));
}
示例15: fillNonPatternSet
import org.apache.tools.ant.types.selectors.SelectorUtils; //导入依赖的package包/类
/**
* Add all patterns that are not real patterns (do not contain
* wildcards) to the set and returns the real patterns.
*
* @param map Map to populate.
* @param patterns String[] of patterns.
* @since Ant 1.8.0
*/
private TokenizedPattern[] fillNonPatternSet(final Map<String, TokenizedPath> map,
final String[] patterns) {
final List<TokenizedPattern> al = new ArrayList<>(patterns.length);
for (String pattern : patterns) {
if (SelectorUtils.hasWildcards(pattern)) {
al.add(new TokenizedPattern(pattern));
} else {
final String s = isCaseSensitive() ? pattern : pattern.toUpperCase();
map.put(s, new TokenizedPath(s));
}
}
return al.toArray(new TokenizedPattern[al.size()]);
}