From 25ae6c22121ab8c68c15f6783da60d93e8663058 Mon Sep 17 00:00:00 2001 From: Matthew Jason Benson Date: Fri, 7 Jan 2005 17:14:42 +0000 Subject: [PATCH] Various inconsequentials git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@277317 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/tools/ant/DirectoryScanner.java | 61 +++++++++++-------- 1 file changed, 35 insertions(+), 26 deletions(-) diff --git a/src/main/org/apache/tools/ant/DirectoryScanner.java b/src/main/org/apache/tools/ant/DirectoryScanner.java index cf0789d5b..7ae98a7f4 100644 --- a/src/main/org/apache/tools/ant/DirectoryScanner.java +++ b/src/main/org/apache/tools/ant/DirectoryScanner.java @@ -944,9 +944,9 @@ public class DirectoryScanner } } /** - * process included file - * @param name path of the file relative to the directory of the fileset - * @param file included file + * Process included file. + * @param name path of the file relative to the directory of the FileSet. + * @param file included File. */ private void accountForIncludedFile(String name, File file) { if (!filesIncluded.contains(name) @@ -968,11 +968,11 @@ public class DirectoryScanner } /** - * + * Process included directory. * @param name path of the directory relative to the directory of - * the fileset - * @param file directory as file - * @param fast + * the FileSet. + * @param file directory as File. + * @param fast whether to perform fast scans. */ private void accountForIncludedDir(String name, File file, boolean fast) { if (!dirsIncluded.contains(name) @@ -1011,11 +1011,7 @@ public class DirectoryScanner * include pattern, or false otherwise. */ protected boolean isIncluded(String name) { - if (!areNonPatternSetsReady) { - includePatterns = fillNonPatternSet(includeNonPatterns, includes); - excludePatterns = fillNonPatternSet(excludeNonPatterns, excludes); - areNonPatternSetsReady = true; - } + ensureNonPatternSetsReady(); if ((isCaseSensitive() && includeNonPatterns.contains(name)) || @@ -1085,12 +1081,8 @@ public class DirectoryScanner * exclude pattern, or false otherwise. */ protected boolean isExcluded(String name) { - if (!areNonPatternSetsReady) { - includePatterns = fillNonPatternSet(includeNonPatterns, includes); - excludePatterns = fillNonPatternSet(excludeNonPatterns, excludes); - areNonPatternSetsReady = true; - } - + ensureNonPatternSetsReady(); + if ((isCaseSensitive() && excludeNonPatterns.contains(name)) || (!isCaseSensitive() @@ -1134,6 +1126,9 @@ public class DirectoryScanner * include patterns and none of the exclude patterns. */ public String[] getIncludedFiles() { + if (filesIncluded == null) { + throw new IllegalStateException(); + } String[] files = new String[filesIncluded.size()]; filesIncluded.copyInto(files); Arrays.sort(files); @@ -1214,6 +1209,9 @@ public class DirectoryScanner * include patterns and none of the exclude patterns. */ public String[] getIncludedDirectories() { + if (dirsIncluded == null) { + throw new IllegalStateException(); + } String[] directories = new String[dirsIncluded.size()]; dirsIncluded.copyInto(directories); Arrays.sort(directories); @@ -1498,7 +1496,7 @@ public class DirectoryScanner * * @since Ant 1.6 */ - private void clearCaches() { + private synchronized void clearCaches() { fileListMap.clear(); scannedDirs.clear(); includeNonPatterns.clear(); @@ -1508,7 +1506,21 @@ public class DirectoryScanner } /** - * Adds all patterns that are no real patterns (doesn't contain + * Ensure that the in|exclude "patterns" + * have been properly divided up. + * + * @since Ant 1.7 + */ + private synchronized void ensureNonPatternSetsReady() { + if (!areNonPatternSetsReady) { + includePatterns = fillNonPatternSet(includeNonPatterns, includes); + excludePatterns = fillNonPatternSet(excludeNonPatterns, excludes); + areNonPatternSetsReady = true; + } + } + + /** + * Adds all patterns that are not real patterns (do not contain * wildcards) to the set and returns the real patterns. * * @since Ant 1.7 @@ -1517,16 +1529,13 @@ public class DirectoryScanner ArrayList al = new ArrayList(patterns.length); for (int i = 0; i < patterns.length; i++) { if (!SelectorUtils.hasWildcards(patterns[i])) { - if (isCaseSensitive()) { - set.add(patterns[i]); - } else { - set.add(patterns[i].toUpperCase()); - } + set.add(isCaseSensitive() ? patterns[i] + : patterns[i].toUpperCase()); } else { al.add(patterns[i]); } } - return set.size() == 0 ? patterns + return set.size() == 0 ? patterns : (String[]) al.toArray(new String[al.size()]); }