Browse Source

Only whitespace changes

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274823 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 22 years ago
parent
commit
9e66320fa0
2 changed files with 79 additions and 66 deletions
  1. +53
    -42
      src/main/org/apache/tools/ant/DirectoryScanner.java
  2. +26
    -24
      src/main/org/apache/tools/ant/types/selectors/SelectorUtils.java

+ 53
- 42
src/main/org/apache/tools/ant/DirectoryScanner.java View File

@@ -644,57 +644,66 @@ public class DirectoryScanner
}
checkIncludePatterns();
}

/**
* this routine is actually checking all the include patterns
* in order to avoid scanning everything under base dir
* @since ant1.6
* this routine is actually checking all the include patterns in
* order to avoid scanning everything under base dir
* @since ant1.6
*/
private void checkIncludePatterns() {
Hashtable newroots = new Hashtable();
// put in the newroots vector the include patterns without wildcard tokens
for (int icounter=0; icounter<includes.length; icounter++) {
String newpattern=SelectorUtils.rtrimWildcardTokens(includes[icounter]);
// check whether the candidate new pattern has a parent
boolean hasParent=false;
Enumeration myenum = newroots.keys();
while (myenum.hasMoreElements()) {
String existingpattern=(String)myenum.nextElement();
if (existingpattern.length() <= newpattern.length()) {
if (newpattern.indexOf(existingpattern)==0) {
hasParent=true;
Hashtable newroots = new Hashtable();
// put in the newroots vector the include patterns without
// wildcard tokens
for (int icounter = 0; icounter < includes.length; icounter++) {
String newpattern =
SelectorUtils.rtrimWildcardTokens(includes[icounter]);
// check whether the candidate new pattern has a parent
boolean hasParent=false;
Enumeration myenum = newroots.keys();
while (myenum.hasMoreElements()) {
String existingpattern= (String) myenum.nextElement();
if (existingpattern.length() <= newpattern.length()) {
if (newpattern.indexOf(existingpattern)==0) {
hasParent=true;
}
}
}
if (!hasParent) {
newroots.put(newpattern,includes[icounter]);
}
}
}
if ( !hasParent) {
newroots.put(newpattern,includes[icounter]);
}
}
Enumeration enum2 = newroots.keys();
while (enum2.hasMoreElements()) {
String currentelement = (String) enum2.nextElement();
File myfile=new File(basedir,currentelement);
if (myfile.exists()) {
if (myfile.isDirectory()) {
if (isIncluded(currentelement) && currentelement.length()>0) {
accountForIncludedDir(currentelement,myfile,true);
} else {
if (currentelement.length() > 0) {
if (currentelement.charAt(currentelement.length()-1) != File.separatorChar) {
currentelement = currentelement + File.separatorChar;

Enumeration enum2 = newroots.keys();
while (enum2.hasMoreElements()) {
String currentelement = (String) enum2.nextElement();
File myfile=new File(basedir, currentelement);
if (myfile.exists()) {
if (myfile.isDirectory()) {
if (isIncluded(currentelement)
&& currentelement.length()>0) {
accountForIncludedDir(currentelement,myfile,true);
} else {
if (currentelement.length() > 0) {
if (currentelement.charAt(currentelement.length()
-1 )
!= File.separatorChar) {
currentelement =
currentelement + File.separatorChar;
}
}
scandir(myfile, currentelement, true);
}
} else {
String originalpattern=
(String) newroots.get(currentelement);
if (originalpattern.equals(currentelement)) {
accountForIncludedFile(currentelement,myfile);
}
}
scandir(myfile, currentelement, true);
}
}
else {
String originalpattern=(String)newroots.get(currentelement);
if (originalpattern.equals(currentelement)) {
accountForIncludedFile(currentelement,myfile);
}
}
}
}
}

/**
* Top level invocation for a slow scan. A slow scan builds up a full
* list of excluded/included files/directories, whereas a fast scan
@@ -838,9 +847,11 @@ public class DirectoryScanner
}

}

/**
*
* @param name path of the directory relative to the directory of the fileset
* @param name path of the directory relative to the directory of
* the fileset
* @param file directory as file
* @param fast
*/


+ 26
- 24
src/main/org/apache/tools/ant/types/selectors/SelectorUtils.java View File

@@ -526,29 +526,29 @@ public final class SelectorUtils {
*
* @param path Path to tokenize. Must not be <code>null</code>.
*
* @return a Vector of path elements from the tokenized path
*/
public static Vector tokenizePath (String path) {
return tokenizePath(path, File.separator);
}
/**
* Breaks a path up into a Vector of path elements, tokenizing on
*
* @param path Path to tokenize. Must not be <code>null</code>.
* @param separator the separator against which to tokenize.
*
* @return a Vector of path elements from the tokenized path
* @since ant 1.6
*/
public static Vector tokenizePath (String path, String separator) {
Vector ret = new Vector();
StringTokenizer st = new StringTokenizer(path,separator);
while (st.hasMoreTokens()) {
ret.addElement(st.nextToken());
}
return ret;
}
* @return a Vector of path elements from the tokenized path
*/
public static Vector tokenizePath (String path) {
return tokenizePath(path, File.separator);
}
/**
* Breaks a path up into a Vector of path elements, tokenizing on
*
* @param path Path to tokenize. Must not be <code>null</code>.
* @param separator the separator against which to tokenize.
*
* @return a Vector of path elements from the tokenized path
* @since Ant 1.6
*/
public static Vector tokenizePath (String path, String separator) {
Vector ret = new Vector();
StringTokenizer st = new StringTokenizer(path,separator);
while (st.hasMoreTokens()) {
ret.addElement(st.nextToken());
}
return ret;
}

/**
* Same as {@link #tokenizePath tokenizePath} but hopefully faster.
@@ -662,14 +662,16 @@ public final class SelectorUtils {
}
return result.toString();
}

/**
* Tests if a string contains stars or question marks
* @param input a String which one wants to test for containing wildcard
* @param input a String which one wants to test for containing wildcard
* @return true if the string contains at least a star or a question mark
*/
public static boolean hasWildcards(String input) {
return (input.indexOf('*')!=-1 || input.indexOf('?')!=-1);
}

/**
* removes from a pattern all tokens to the right containing wildcards
* @param input


Loading…
Cancel
Save