@@ -310,7 +310,7 @@ public class DirectoryScanner
*
* @since Ant 1.6
*/
private Set<String> scannedDirs = new HashSet<String>();
private final Set<String> scannedDirs = new HashSet<String>();
/**
* Map of all include patterns that are full file names and don't
@@ -327,7 +327,7 @@ public class DirectoryScanner
*
* @since Ant 1.8.0
*/
private Map<String, TokenizedPath> includeNonPatterns = new HashMap<String, TokenizedPath>();
private final Map<String, TokenizedPath> includeNonPatterns = new HashMap<String, TokenizedPath>();
/**
* Map of all exclude patterns that are full file names and don't
@@ -344,7 +344,7 @@ public class DirectoryScanner
*
* @since Ant 1.8.0
*/
private Map<String, TokenizedPath> excludeNonPatterns = new HashMap<String, TokenizedPath>();
private final Map<String, TokenizedPath> excludeNonPatterns = new HashMap<String, TokenizedPath>();
/**
* Array of all include patterns that contain wildcards.
@@ -384,7 +384,7 @@ public class DirectoryScanner
*
* @since Ant 1.6.3
*/
private Object scanLock = new Object();
private final Object scanLock = new Object();
/**
* Slow scanning flag.
@@ -398,7 +398,7 @@ public class DirectoryScanner
*
* @since Ant 1.6.3
*/
private Object slowScanLock = new Object();
private final Object slowScanLock = new Object();
/**
* Exception thrown during scan.
@@ -423,7 +423,7 @@ public class DirectoryScanner
*
* @since Ant 1.8.0
*/
private Set<String> notFollowedSymlinks = new HashSet<String>();
private final Set<String> notFollowedSymlinks = new HashSet<String>();
/**
* Sole constructor.
@@ -447,7 +447,7 @@ public class DirectoryScanner
* @return whether or not a given path matches the start of a given
* pattern up to the first "**".
*/
protected static boolean matchPatternStart(String pattern, String str) {
protected static boolean matchPatternStart(final String pattern, final String str) {
return SelectorUtils.matchPatternStart(pattern, str);
}
@@ -469,8 +469,8 @@ public class DirectoryScanner
* @return whether or not a given path matches the start of a given
* pattern up to the first "**".
*/
protected static boolean matchPatternStart(String pattern, String str,
boolean isCaseSensitive) {
protected static boolean matchPatternStart(final String pattern, final String str,
final boolean isCaseSensitive) {
return SelectorUtils.matchPatternStart(pattern, str, isCaseSensitive);
}
@@ -485,7 +485,7 @@ public class DirectoryScanner
* @return <code>true</code> if the pattern matches against the string,
* or <code>false</code> otherwise.
*/
protected static boolean matchPath(String pattern, String str) {
protected static boolean matchPath(final String pattern, final String str) {
return SelectorUtils.matchPath(pattern, str);
}
@@ -502,8 +502,8 @@ public class DirectoryScanner
* @return <code>true</code> if the pattern matches against the string,
* or <code>false</code> otherwise.
*/
protected static boolean matchPath(String pattern, String str,
boolean isCaseSensitive) {
protected static boolean matchPath(final String pattern, final String str,
final boolean isCaseSensitive) {
return SelectorUtils.matchPath(pattern, str, isCaseSensitive);
}
@@ -521,7 +521,7 @@ public class DirectoryScanner
* @return <code>true</code> if the string matches against the pattern,
* or <code>false</code> otherwise.
*/
public static boolean match(String pattern, String str) {
public static boolean match(final String pattern, final String str) {
return SelectorUtils.match(pattern, str);
}
@@ -542,8 +542,8 @@ public class DirectoryScanner
* @return <code>true</code> if the string matches against the pattern,
* or <code>false</code> otherwise.
*/
protected static boolean match(String pattern, String str,
boolean isCaseSensitive) {
protected static boolean match(final String pattern, final String str,
final boolean isCaseSensitive) {
return SelectorUtils.match(pattern, str, isCaseSensitive);
}
@@ -574,7 +574,7 @@ public class DirectoryScanner
*
* @since Ant 1.6
*/
public static boolean addDefaultExclude(String s) {
public static boolean addDefaultExclude(final String s) {
synchronized (defaultExcludes) {
return defaultExcludes.add(s);
}
@@ -591,7 +591,7 @@ public class DirectoryScanner
*
* @since Ant 1.6
*/
public static boolean removeDefaultExclude(String s) {
public static boolean removeDefaultExclude(final String s) {
synchronized (defaultExcludes) {
return defaultExcludes.remove(s);
}
@@ -619,8 +619,7 @@ public class DirectoryScanner
*
* @param basedir The base directory to scan.
*/
@Override
public void setBasedir(String basedir) {
public void setBasedir(final String basedir) {
setBasedir(basedir == null ? (File) null
: new File(basedir.replace('/', File.separatorChar).replace(
'\\', File.separatorChar)));
@@ -632,8 +631,7 @@ public class DirectoryScanner
*
* @param basedir The base directory for scanning.
*/
@Override
public synchronized void setBasedir(File basedir) {
public synchronized void setBasedir(final File basedir) {
this.basedir = basedir;
}
@@ -643,7 +641,6 @@ public class DirectoryScanner
*
* @return the base directory to be scanned.
*/
@Override
public synchronized File getBasedir() {
return basedir;
}
@@ -665,8 +662,7 @@ public class DirectoryScanner
* @param isCaseSensitive whether or not the file system should be
* regarded as a case sensitive one.
*/
@Override
public synchronized void setCaseSensitive(boolean isCaseSensitive) {
public synchronized void setCaseSensitive(final boolean isCaseSensitive) {
this.isCaseSensitive = isCaseSensitive;
}
@@ -677,7 +673,7 @@ public class DirectoryScanner
* is an error
* @since Ant 1.7.1
*/
public void setErrorOnMissingDir(boolean errorOnMissingDir) {
public void setErrorOnMissingDir(final boolean errorOnMissingDir) {
this.errorOnMissingDir = errorOnMissingDir;
}
@@ -697,7 +693,7 @@ public class DirectoryScanner
*
* @param followSymlinks whether or not symbolic links should be followed.
*/
public synchronized void setFollowSymlinks(boolean followSymlinks) {
public synchronized void setFollowSymlinks(final boolean followSymlinks) {
this.followSymlinks = followSymlinks;
}
@@ -707,7 +703,7 @@ public class DirectoryScanner
*
* @since Ant 1.8.0
*/
public void setMaxLevelsOfSymlinks(int max) {
public void setMaxLevelsOfSymlinks(final int max) {
maxLevelsOfSymlinks = max;
}
@@ -724,8 +720,7 @@ public class DirectoryScanner
* list is given, all elements must be
* non-<code>null</code>.
*/
@Override
public synchronized void setIncludes(String[] includes) {
public synchronized void setIncludes(final String[] includes) {
if (includes == null) {
this.includes = null;
} else {
@@ -748,8 +743,7 @@ public class DirectoryScanner
* should be excluded. If a non-<code>null</code> list is
* given, all elements must be non-<code>null</code>.
*/
@Override
public synchronized void setExcludes(String[] excludes) {
public synchronized void setExcludes(final String[] excludes) {
if (excludes == null) {
this.excludes = null;
} else {
@@ -773,10 +767,10 @@ public class DirectoryScanner
*
* @since Ant 1.6.3
*/
public synchronized void addExcludes(String[] excludes) {
public synchronized void addExcludes(final String[] excludes) {
if (excludes != null && excludes.length > 0) {
if (this.excludes != null && this.excludes.length > 0) {
String[] tmp = new String[excludes.length
final String[] tmp = new String[excludes.length
+ this.excludes.length];
System.arraycopy(this.excludes, 0, tmp, 0,
this.excludes.length);
@@ -800,7 +794,7 @@ public class DirectoryScanner
*
* @since Ant 1.6.3
*/
private static String normalizePattern(String p) {
private static String normalizePattern(final String p) {
String pattern = p.replace('/', File.separatorChar)
.replace('\\', File.separatorChar);
if (pattern.endsWith(File.separator)) {
@@ -814,8 +808,7 @@ public class DirectoryScanner
*
* @param selectors specifies the selectors to be invoked on a scan.
*/
@Override
public synchronized void setSelectors(FileSelector[] selectors) {
public synchronized void setSelectors(final FileSelector[] selectors) {
this.selectors = selectors;
}
@@ -840,14 +833,13 @@ public class DirectoryScanner
* @exception IllegalStateException if the base directory was set
* incorrectly (i.e. if it doesn't exist or isn't a directory).
*/
@Override
public void scan() throws IllegalStateException {
synchronized (scanLock) {
if (scanning) {
while (scanning) {
try {
scanLock.wait();
} catch (InterruptedException e) {
} catch (final InterruptedException e) {
continue;
}
}
@@ -858,17 +850,17 @@ public class DirectoryScanner
}
scanning = true;
}
File savedBase = basedir;
final File savedBase = basedir;
try {
synchronized (this) {
illegal = null;
clearResults();
// set in/excludes to reasonable defaults if needed:
boolean nullIncludes = (includes == null);
final boolean nullIncludes = (includes == null);
includes = nullIncludes
? new String[] {SelectorUtils.DEEP_TREE_MATCH} : includes;
boolean nullExcludes = (excludes == null);
final boolean nullExcludes = (excludes == null);
excludes = nullExcludes ? new String[0] : excludes;
if (basedir != null && !followSymlinks
@@ -920,7 +912,7 @@ public class DirectoryScanner
includes = nullIncludes ? null : includes;
excludes = nullExcludes ? null : excludes;
}
} catch (IOException ex) {
} catch (final IOException ex) {
throw new BuildException(ex);
} finally {
basedir = savedBase;
@@ -938,19 +930,19 @@ public class DirectoryScanner
*/
private void checkIncludePatterns() {
ensureNonPatternSetsReady();
Map<TokenizedPath, String> newroots = new HashMap<TokenizedPath, String>();
final Map<TokenizedPath, String> newroots = new HashMap<TokenizedPath, String>();
// put in the newroots map the include patterns without
// wildcard tokens
for (int i = 0; i < includePatterns.length; i++) {
String pattern = includePatterns[i].toString();
final String pattern = includePatterns[i].toString();
if (!shouldSkipPattern(pattern)) {
newroots.put(includePatterns[i].rtrimWildcardTokens(),
pattern);
}
}
for (Map.Entry<String, TokenizedPath> entry : includeNonPatterns.entrySet()) {
String pattern = entry.getKey();
for (final Map.Entry<String, TokenizedPath> entry : includeNonPatterns.entrySet()) {
final String pattern = entry.getKey();
if (!shouldSkipPattern(pattern)) {
newroots.put(entry.getValue(), pattern);
}
@@ -965,13 +957,13 @@ public class DirectoryScanner
if (basedir != null) {
try {
canonBase = basedir.getCanonicalFile();
} catch (IOException ex) {
} catch (final IOException ex) {
throw new BuildException(ex);
}
}
// only scan directories that can include matched files or
// directories
for (Map.Entry<TokenizedPath, String> entry : newroots.entrySet()) {
for (final Map.Entry<TokenizedPath, String> entry : newroots.entrySet()) {
TokenizedPath currentPath = entry.getKey();
String currentelement = currentPath.toString();
if (basedir == null
@@ -985,7 +977,7 @@ public class DirectoryScanner
// the results to show what's really on the disk, so
// we need to double check.
try {
String path = (basedir == null)
final String path = (basedir == null)
? myfile.getCanonicalPath()
: FILE_UTILS.removeLeadingPath(canonBase,
myfile.getCanonicalFile());
@@ -1001,13 +993,13 @@ public class DirectoryScanner
}
}
}
} catch (IOException ex) {
} catch (final IOException ex) {
throw new BuildException(ex);
}
}
if ((myfile == null || !myfile.exists()) && !isCaseSensitive()) {
File f = currentPath.findFile(basedir, false);
final File f = currentPath.findFile(basedir, false);
if (f != null && f.exists()) {
// adapt currentelement to the case we've
// actually found
@@ -1032,8 +1024,8 @@ public class DirectoryScanner
scandir(myfile, currentPath, true);
}
} else if (myfile.isFile()) {
String originalpattern = entry.getValue();
boolean included = isCaseSensitive()
final String originalpattern = entry.getValue();
final boolean included = isCaseSensitive()
? originalpattern.equals(currentelement)
: originalpattern.equalsIgnoreCase(currentelement);
if (included) {
@@ -1051,7 +1043,7 @@ public class DirectoryScanner
*
* @since Ant 1.8.0
*/
private boolean shouldSkipPattern(String pattern) {
private boolean shouldSkipPattern(final String pattern) {
if (FileUtils.isAbsolutePath(pattern)) {
//skip abs. paths not under basedir, if set:
if (basedir != null
@@ -1101,7 +1093,7 @@ public class DirectoryScanner
while (slowScanning) {
try {
slowScanLock.wait();
} catch (InterruptedException e) {
} catch (final InterruptedException e) {
// Empty
}
}
@@ -1113,16 +1105,16 @@ public class DirectoryScanner
synchronized (this) {
// set in/excludes to reasonable defaults if needed:
boolean nullIncludes = (includes == null);
final boolean nullIncludes = (includes == null);
includes = nullIncludes
? new String[] {SelectorUtils.DEEP_TREE_MATCH} : includes;
boolean nullExcludes = (excludes == null);
final boolean nullExcludes = (excludes == null);
excludes = nullExcludes ? new String[0] : excludes;
String[] excl = new String[dirsExcluded.size()];
final String[] excl = new String[dirsExcluded.size()];
dirsExcluded.copyInto(excl);
String[] notIncl = new String[dirsNotIncluded.size()];
final String[] notIncl = new String[dirsNotIncluded.size()];
dirsNotIncluded.copyInto(notIncl);
ensureNonPatternSetsReady();
@@ -1142,9 +1134,9 @@ public class DirectoryScanner
}
}
private void processSlowScan(String[] arr) {
private void processSlowScan(final String[] arr) {
for (int i = 0; i < arr.length; i++) {
TokenizedPath path = new TokenizedPath(arr[i]);
final TokenizedPath path = new TokenizedPath(arr[i]);
if (!couldHoldIncluded(path) || contentsExcluded(path)) {
scandir(new File(basedir, arr[i]), path, false);
}
@@ -1171,7 +1163,7 @@ public class DirectoryScanner
* @see #dirsExcluded
* @see #slowScan
*/
protected void scandir(File dir, String vpath, boolean fast) {
protected void scandir(final File dir, final String vpath, final boolean fast) {
scandir(dir, new TokenizedPath(vpath), fast);
}
@@ -1195,11 +1187,11 @@ public class DirectoryScanner
* @see #dirsExcluded
* @see #slowScan
*/
private void scandir(File dir, TokenizedPath path, boolean fast) {
private void scandir(final File dir, final TokenizedPath path, final boolean fast) {
if (dir == null) {
throw new BuildException("dir must not be null.");
}
String[] newfiles = dir.list();
final String[] newfiles = dir.list();
if (newfiles == null) {
if (!dir.exists()) {
throw new BuildException(dir + DOES_NOT_EXIST_POSTFIX);
@@ -1213,8 +1205,8 @@ public class DirectoryScanner
scandir(dir, path, fast, newfiles, new LinkedList<String>());
}
private void scandir(File dir, TokenizedPath path, boolean fast,
String[] newfiles, LinkedList<String> directoryNamesFollowed) {
private void scandir(final File dir, final TokenizedPath path, final boolean fast,
String[] newfiles, final LinkedList<String> directoryNamesFollowed) {
String vpath = path.toString();
if (vpath.length() > 0 && !vpath.endsWith(File.separator)) {
vpath += File.separator;
@@ -1225,12 +1217,12 @@ public class DirectoryScanner
return;
}
if (!followSymlinks) {
ArrayList<String> noLinks = new ArrayList<String>();
final ArrayList<String> noLinks = new ArrayList<String>();
for (int i = 0; i < newfiles.length; i++) {
try {
if (SYMLINK_UTILS.isSymbolicLink(dir, newfiles[i])) {
String name = vpath + newfiles[i];
File file = new File(dir, newfiles[i]);
final String name = vpath + newfiles[i];
final File file = new File(dir, newfiles[i]);
if (file.isDirectory()) {
dirsExcluded.addElement(name);
} else if (file.isFile()) {
@@ -1240,8 +1232,8 @@ public class DirectoryScanner
} else {
noLinks.add(newfiles[i]);
}
} catch (IOException ioe) {
String msg = "IOException caught while checking "
} catch (final IOException ioe) {
final String msg = "IOException caught while checking "
+ "for links, couldn't get canonical path!";
// will be caught and redirected to Ant's logging system
System.err.println(msg);
@@ -1254,10 +1246,10 @@ public class DirectoryScanner
}
for (int i = 0; i < newfiles.length; i++) {
String name = vpath + newfiles[i];
TokenizedPath newPath = new TokenizedPath(path, newfiles[i]);
File file = new File(dir, newfiles[i]);
String[] children = file.list();
final String name = vpath + newfiles[i];
final TokenizedPath newPath = new TokenizedPath(path, newfiles[i]);
final File file = new File(dir, newfiles[i]);
final String[] children = file.list();
if (children == null || (children.length == 0 && file.isFile())) {
if (isIncluded(newPath)) {
accountForIncludedFile(newPath, file);
@@ -1307,7 +1299,7 @@ public class DirectoryScanner
* @param name path of the file relative to the directory of the FileSet.
* @param file included File.
*/
private void accountForIncludedFile(TokenizedPath name, File file) {
private void accountForIncludedFile(final TokenizedPath name, final File file) {
processIncluded(name, file, filesIncluded, filesExcluded,
filesDeselected);
}
@@ -1319,29 +1311,29 @@ public class DirectoryScanner
* @param file directory as File.
* @param fast whether to perform fast scans.
*/
private void accountForIncludedDir(TokenizedPath name, File file,
boolean fast) {
private void accountForIncludedDir(final TokenizedPath name, final File file,
final boolean fast) {
processIncluded(name, file, dirsIncluded, dirsExcluded, dirsDeselected);
if (fast && couldHoldIncluded(name) && !contentsExcluded(name)) {
scandir(file, name, fast);
}
}
private void accountForIncludedDir(TokenizedPath name,
File file, boolean fast,
String[] children,
LinkedList<String> directoryNamesFollowed) {
private void accountForIncludedDir(final TokenizedPath name,
final File file, final boolean fast,
final String[] children,
final LinkedList<String> directoryNamesFollowed) {
processIncluded(name, file, dirsIncluded, dirsExcluded, dirsDeselected);
if (fast && couldHoldIncluded(name) && !contentsExcluded(name)) {
scandir(file, name, fast, children, directoryNamesFollowed);
}
}
private void accountForNotFollowedSymlink(String name, File file) {
private void accountForNotFollowedSymlink(final String name, final File file) {
accountForNotFollowedSymlink(new TokenizedPath(name), file);
}
private void accountForNotFollowedSymlink(TokenizedPath name, File file) {
private void accountForNotFollowedSymlink(final TokenizedPath name, final File file) {
if (!isExcluded(name) &&
(isIncluded(name)
|| (file.isDirectory() && couldHoldIncluded(name)
@@ -1350,10 +1342,10 @@ public class DirectoryScanner
}
}
private void processIncluded(TokenizedPath path,
File file, Vector<String> inc, Vector<String> exc,
Vector<String> des) {
String name = path.toString();
private void processIncluded(final TokenizedPath path,
final File file, final Vector<String> inc, final Vector<String> exc,
final Vector<String> des) {
final String name = path.toString();
if (inc.contains(name) || exc.contains(name) || des.contains(name)) {
return;
}
@@ -1378,7 +1370,7 @@ public class DirectoryScanner
* @return <code>true</code> when the name matches against at least one
* include pattern, or <code>false</code> otherwise.
*/
protected boolean isIncluded(String name) {
protected boolean isIncluded(final String name) {
return isIncluded(new TokenizedPath(name));
}
@@ -1390,7 +1382,7 @@ public class DirectoryScanner
* @return <code>true</code> when the name matches against at least one
* include pattern, or <code>false</code> otherwise.
*/
private boolean isIncluded(TokenizedPath path) {
private boolean isIncluded(final TokenizedPath path) {
ensureNonPatternSetsReady();
if (isCaseSensitive()
@@ -1414,7 +1406,7 @@ public class DirectoryScanner
* @return <code>true</code> when the name matches against the start of at
* least one include pattern, or <code>false</code> otherwise.
*/
protected boolean couldHoldIncluded(String name) {
protected boolean couldHoldIncluded(final String name) {
return couldHoldIncluded(new TokenizedPath(name));
}
@@ -1426,13 +1418,13 @@ public class DirectoryScanner
* @return <code>true</code> when the name matches against the start of at
* least one include pattern, or <code>false</code> otherwise.
*/
private boolean couldHoldIncluded(TokenizedPath tokenizedName) {
private boolean couldHoldIncluded(final TokenizedPath tokenizedName) {
for (int i = 0; i < includePatterns.length; i++) {
if (couldHoldIncluded(tokenizedName, includePatterns[i])) {
return true;
}
}
for (Iterator<TokenizedPath> iter = includeNonPatterns.values().iterator();
for (final Iterator<TokenizedPath> iter = includeNonPatterns.values().iterator();
iter.hasNext();) {
if (couldHoldIncluded(tokenizedName,
iter.next().toPattern())) {
@@ -1450,8 +1442,8 @@ public class DirectoryScanner
* @return <code>true</code> when the name matches against the start of the
* include pattern, or <code>false</code> otherwise.
*/
private boolean couldHoldIncluded(TokenizedPath tokenizedName,
TokenizedPattern tokenizedInclude) {
private boolean couldHoldIncluded(final TokenizedPath tokenizedName,
final TokenizedPattern tokenizedInclude) {
return tokenizedInclude.matchStartOf(tokenizedName, isCaseSensitive())
&& isMorePowerfulThanExcludes(tokenizedName.toString())
&& isDeeper(tokenizedInclude, tokenizedName);
@@ -1465,7 +1457,7 @@ public class DirectoryScanner
* @return whether the pattern is deeper than the name.
* @since Ant 1.6.3
*/
private boolean isDeeper(TokenizedPattern pattern, TokenizedPath name) {
private boolean isDeeper(final TokenizedPattern pattern, final TokenizedPath name) {
return pattern.containsPattern(SelectorUtils.DEEP_TREE_MATCH)
|| pattern.depth() > name.depth();
}
@@ -1486,7 +1478,7 @@ public class DirectoryScanner
* this include pattern.
* @since Ant 1.6
*/
private boolean isMorePowerfulThanExcludes(String name) {
private boolean isMorePowerfulThanExcludes(final String name) {
final String soughtexclude =
name + File.separatorChar + SelectorUtils.DEEP_TREE_MATCH;
for (int counter = 0; counter < excludePatterns.length; counter++) {
@@ -1502,7 +1494,7 @@ public class DirectoryScanner
* @param path the path to check.
* @return whether all the specified directory's contents are excluded.
*/
/* package */ boolean contentsExcluded(TokenizedPath path) {
/* package */ boolean contentsExcluded(final TokenizedPath path) {
for (int i = 0; i < excludePatterns.length; i++) {
if (excludePatterns[i].endsWith(SelectorUtils.DEEP_TREE_MATCH)
&& excludePatterns[i].withoutLastToken()
@@ -1521,7 +1513,7 @@ public class DirectoryScanner
* @return <code>true</code> when the name matches against at least one
* exclude pattern, or <code>false</code> otherwise.
*/
protected boolean isExcluded(String name) {
protected boolean isExcluded(final String name) {
return isExcluded(new TokenizedPath(name));
}
@@ -1533,7 +1525,7 @@ public class DirectoryScanner
* @return <code>true</code> when the name matches against at least one
* exclude pattern, or <code>false</code> otherwise.
*/
private boolean isExcluded(TokenizedPath name) {
private boolean isExcluded(final TokenizedPath name) {
ensureNonPatternSetsReady();
if (isCaseSensitive()
@@ -1557,7 +1549,7 @@ public class DirectoryScanner
* @return <code>false</code> when the selectors says that the file
* should not be selected, <code>true</code> otherwise.
*/
protected boolean isSelected(String name, File file) {
protected boolean isSelected(final String name, final File file) {
if (selectors != null) {
for (int i = 0; i < selectors.length; i++) {
if (!selectors[i].isSelected(basedir, name, file)) {
@@ -1576,7 +1568,6 @@ public class DirectoryScanner
* @return the names of the files which matched at least one of the
* include patterns and none of the exclude patterns.
*/
@Override
public String[] getIncludedFiles() {
String[] files;
synchronized (this) {
@@ -1612,10 +1603,9 @@ public class DirectoryScanner
*
* @see #slowScan
*/
@Override
public synchronized String[] getNotIncludedFiles() {
slowScan();
String[] files = new String[filesNotIncluded.size()];
final String[] files = new String[filesNotIncluded.size()];
filesNotIncluded.copyInto(files);
return files;
}
@@ -1631,10 +1621,9 @@ public class DirectoryScanner
*
* @see #slowScan
*/
@Override
public synchronized String[] getExcludedFiles() {
slowScan();
String[] files = new String[filesExcluded.size()];
final String[] files = new String[filesExcluded.size()];
filesExcluded.copyInto(files);
return files;
}
@@ -1650,10 +1639,9 @@ public class DirectoryScanner
*
* @see #slowScan
*/
@Override
public synchronized String[] getDeselectedFiles() {
slowScan();
String[] files = new String[filesDeselected.size()];
final String[] files = new String[filesDeselected.size()];
filesDeselected.copyInto(files);
return files;
}
@@ -1666,7 +1654,6 @@ public class DirectoryScanner
* @return the names of the directories which matched at least one of the
* include patterns and none of the exclude patterns.
*/
@Override
public String[] getIncludedDirectories() {
String[] directories;
synchronized (this) {
@@ -1702,10 +1689,9 @@ public class DirectoryScanner
*
* @see #slowScan
*/
@Override
public synchronized String[] getNotIncludedDirectories() {
slowScan();
String[] directories = new String[dirsNotIncluded.size()];
final String[] directories = new String[dirsNotIncluded.size()];
dirsNotIncluded.copyInto(directories);
return directories;
}
@@ -1721,10 +1707,9 @@ public class DirectoryScanner
*
* @see #slowScan
*/
@Override
public synchronized String[] getExcludedDirectories() {
slowScan();
String[] directories = new String[dirsExcluded.size()];
final String[] directories = new String[dirsExcluded.size()];
dirsExcluded.copyInto(directories);
return directories;
}
@@ -1740,10 +1725,9 @@ public class DirectoryScanner
*
* @see #slowScan
*/
@Override
public synchronized String[] getDeselectedDirectories() {
slowScan();
String[] directories = new String[dirsDeselected.size()];
final String[] directories = new String[dirsDeselected.size()];
dirsDeselected.copyInto(directories);
return directories;
}
@@ -1770,11 +1754,10 @@ public class DirectoryScanner
/**
* Add default exclusions to the current exclusions set.
*/
@Override
public synchronized void addDefaultExcludes() {
int excludesLength = excludes == null ? 0 : excludes.length;
final int excludesLength = excludes == null ? 0 : excludes.length;
String[] newExcludes;
String[] defaultExcludesTemp = getDefaultExcludes();
final String[] defaultExcludesTemp = getDefaultExcludes();
newExcludes = new String[excludesLength + defaultExcludesTemp.length];
if (excludesLength > 0) {
System.arraycopy(excludes, 0, newExcludes, 0, excludesLength);
@@ -1794,8 +1777,7 @@ public class DirectoryScanner
* @return the resource with the given name.
* @since Ant 1.5.2
*/
@Override
public synchronized Resource getResource(String name) {
public synchronized Resource getResource(final String name) {
return new FileResource(basedir, name);
}
@@ -1807,7 +1789,7 @@ public class DirectoryScanner
*
* @since Ant 1.6
*/
private boolean hasBeenScanned(String vpath) {
private boolean hasBeenScanned(final String vpath) {
return !scannedDirs.add(vpath);
}
@@ -1855,11 +1837,11 @@ public class DirectoryScanner
* @param patterns String[] of patterns.
* @since Ant 1.8.0
*/
private TokenizedPattern[] fillNonPatternSet(Map<String, TokenizedPath> map, String[] patterns) {
ArrayList<TokenizedPattern> al = new ArrayList<TokenizedPattern>(patterns.length);
private TokenizedPattern[] fillNonPatternSet(final Map<String, TokenizedPath> map, final String[] patterns) {
final ArrayList<TokenizedPattern> al = new ArrayList<TokenizedPattern>(patterns.length);
for (int i = 0; i < patterns.length; i++) {
if (!SelectorUtils.hasWildcards(patterns[i])) {
String s = isCaseSensitive()
final String s = isCaseSensitive()
? patterns[i] : patterns[i].toUpperCase();
map.put(s, new TokenizedPath(s));
} else {
@@ -1880,21 +1862,21 @@ public class DirectoryScanner
*
* @since Ant 1.8.0
*/
private boolean causesIllegalSymlinkLoop(String dirName, File parent,
LinkedList<String> directoryNamesFollowed) {
private boolean causesIllegalSymlinkLoop(final String dirName, final File parent,
final LinkedList<String> directoryNamesFollowed) {
try {
if (directoryNamesFollowed.size() >= maxLevelsOfSymlinks
&& CollectionUtils.frequency(directoryNamesFollowed, dirName)
>= maxLevelsOfSymlinks
&& SYMLINK_UTILS.isSymbolicLink(parent, dirName)) {
ArrayList<String> files = new ArrayList<String>();
final ArrayList<String> files = new ArrayList<String>();
File f = FILE_UTILS.resolveFile(parent, dirName);
String target = f.getCanonicalPath();
final String target = f.getCanonicalPath();
files.add(target);
String relPath = "";
for (String dir : directoryNamesFollowed) {
for (final String dir : directoryNamesFollowed) {
relPath += "../";
if (dirName.equals(dir)) {
f = FILE_UTILS.resolveFile(parent, relPath + dir);
@@ -1909,7 +1891,7 @@ public class DirectoryScanner
}
return false;
} catch (IOException ex) {
} catch (final IOException ex) {
throw new BuildException("Caught error while checking for"
+ " symbolic links", ex);
}