From 13f6d98c9de38c6c53d4d855157c3fad620c3303 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Mat=C3=A8rne?= Date: Fri, 4 Jul 2014 13:56:55 +0200 Subject: [PATCH] make it compile under Java5 (1.5.0_22-b03) --- .../org/apache/tools/ant/AntClassLoader.java | 11 - .../apache/tools/ant/DirectoryScanner.java | 242 ++++----- src/main/org/apache/tools/ant/Main.java | 2 - src/main/org/apache/tools/ant/Project.java | 1 - .../tools/ant/filters/ConcatFilter.java | 5 +- .../tools/ant/taskdefs/AntStructure.java | 4 - .../org/apache/tools/ant/taskdefs/Copy.java | 18 +- .../org/apache/tools/ant/taskdefs/Get.java | 132 +++-- .../apache/tools/ant/taskdefs/Javadoc.java | 497 +++++++++--------- .../org/apache/tools/ant/taskdefs/Tar.java | 204 +++---- .../tools/ant/taskdefs/XSLTProcess.java | 212 ++++---- .../org/apache/tools/ant/taskdefs/Zip.java | 351 ++++++------- .../compilers/AptCompilerAdapter.java | 31 +- .../compilers/DefaultCompilerAdapter.java | 2 - .../ant/taskdefs/condition/IsReachable.java | 25 +- .../ant/taskdefs/optional/TraXLiaison.java | 120 ++--- .../junit/JUnit4TestMethodAdapter.java | 2 - .../taskdefs/optional/junit/JUnitTask.java | 370 +++++++------ .../optional/junit/JUnitTestRunner.java | 22 - .../optional/junit/TearDownOnVmCrash.java | 9 - .../junit/XMLJUnitResultFormatter.java | 11 - .../ant/types/mappers/CutDirsMapper.java | 3 - .../tools/ant/types/resources/Archives.java | 27 +- .../ContentTransformingResource.java | 9 +- .../LazyResourceCollectionWrapper.java | 18 +- .../ant/types/resources/MultiRootFileSet.java | 40 +- .../ant/types/resources/selectors/Type.java | 1 - .../apache/tools/ant/util/ResourceUtils.java | 2 - .../tools/ant/util/SymbolicLinkUtils.java | 31 +- src/main/org/apache/tools/tar/TarUtils.java | 59 +-- .../tools/zip/AbstractUnicodeExtraField.java | 23 +- .../apache/tools/zip/FallbackZipEncoding.java | 11 +- .../org/apache/tools/zip/NioZipEncoding.java | 19 +- .../tools/zip/Simple8BitZipEncoding.java | 46 +- .../tools/zip/UnicodeCommentExtraField.java | 7 +- .../tools/zip/UnicodePathExtraField.java | 5 +- src/main/org/apache/tools/zip/ZipFile.java | 135 +++-- 37 files changed, 1284 insertions(+), 1423 deletions(-) diff --git a/src/main/org/apache/tools/ant/AntClassLoader.java b/src/main/org/apache/tools/ant/AntClassLoader.java index 88a81c498..f2ce34d1e 100644 --- a/src/main/org/apache/tools/ant/AntClassLoader.java +++ b/src/main/org/apache/tools/ant/AntClassLoader.java @@ -119,7 +119,6 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { * @return true if there are more elements in the * enumeration; false otherwise. */ - @Override public boolean hasMoreElements() { return (this.nextResource != null); } @@ -129,7 +128,6 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { * * @return the next resource in the enumeration */ - @Override public URL nextElement() { final URL ret = this.nextResource; if (ret == null) { @@ -1445,7 +1443,6 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { * * @param event the buildStarted event */ - @Override public void buildStarted(final BuildEvent event) { // Not significant for the class loader. } @@ -1456,7 +1453,6 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { * * @param event the buildFinished event */ - @Override public void buildFinished(final BuildEvent event) { cleanup(); } @@ -1470,7 +1466,6 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { * * @since Ant 1.6.2 */ - @Override public void subBuildFinished(final BuildEvent event) { if (event.getProject() == project) { cleanup(); @@ -1484,7 +1479,6 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { * * @since Ant 1.6.2 */ - @Override public void subBuildStarted(final BuildEvent event) { // Not significant for the class loader. } @@ -1494,7 +1488,6 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { * * @param event the targetStarted event */ - @Override public void targetStarted(final BuildEvent event) { // Not significant for the class loader. } @@ -1504,7 +1497,6 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { * * @param event the targetFinished event */ - @Override public void targetFinished(final BuildEvent event) { // Not significant for the class loader. } @@ -1514,7 +1506,6 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { * * @param event the taskStarted event */ - @Override public void taskStarted(final BuildEvent event) { // Not significant for the class loader. } @@ -1524,7 +1515,6 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { * * @param event the taskFinished event */ - @Override public void taskFinished(final BuildEvent event) { // Not significant for the class loader. } @@ -1534,7 +1524,6 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { * * @param event the messageLogged event */ - @Override public void messageLogged(final BuildEvent event) { // Not significant for the class loader. } diff --git a/src/main/org/apache/tools/ant/DirectoryScanner.java b/src/main/org/apache/tools/ant/DirectoryScanner.java index cf93eb7c3..3565c834e 100644 --- a/src/main/org/apache/tools/ant/DirectoryScanner.java +++ b/src/main/org/apache/tools/ant/DirectoryScanner.java @@ -310,7 +310,7 @@ public class DirectoryScanner * * @since Ant 1.6 */ - private Set scannedDirs = new HashSet(); + private final Set scannedDirs = new HashSet(); /** * 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 includeNonPatterns = new HashMap(); + private final Map includeNonPatterns = new HashMap(); /** * 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 excludeNonPatterns = new HashMap(); + private final Map excludeNonPatterns = new HashMap(); /** * 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 notFollowedSymlinks = new HashSet(); + private final Set notFollowedSymlinks = new HashSet(); /** * 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 true if the pattern matches against the string, * or false 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 true if the pattern matches against the string, * or false 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 true if the string matches against the pattern, * or false 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 true if the string matches against the pattern, * or false 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-null. */ - @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-null list is * given, all elements must be non-null. */ - @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 newroots = new HashMap(); + final Map newroots = new HashMap(); // 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 entry : includeNonPatterns.entrySet()) { - String pattern = entry.getKey(); + for (final Map.Entry 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 entry : newroots.entrySet()) { + for (final Map.Entry 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()); } - private void scandir(File dir, TokenizedPath path, boolean fast, - String[] newfiles, LinkedList directoryNamesFollowed) { + private void scandir(final File dir, final TokenizedPath path, final boolean fast, + String[] newfiles, final LinkedList 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 noLinks = new ArrayList(); + final ArrayList noLinks = new ArrayList(); 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 directoryNamesFollowed) { + private void accountForIncludedDir(final TokenizedPath name, + final File file, final boolean fast, + final String[] children, + final LinkedList 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 inc, Vector exc, - Vector des) { - String name = path.toString(); + private void processIncluded(final TokenizedPath path, + final File file, final Vector inc, final Vector exc, + final Vector 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 true when the name matches against at least one * include pattern, or false 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 true when the name matches against at least one * include pattern, or false otherwise. */ - private boolean isIncluded(TokenizedPath path) { + private boolean isIncluded(final TokenizedPath path) { ensureNonPatternSetsReady(); if (isCaseSensitive() @@ -1414,7 +1406,7 @@ public class DirectoryScanner * @return true when the name matches against the start of at * least one include pattern, or false 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 true when the name matches against the start of at * least one include pattern, or false 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 iter = includeNonPatterns.values().iterator(); + for (final Iterator iter = includeNonPatterns.values().iterator(); iter.hasNext();) { if (couldHoldIncluded(tokenizedName, iter.next().toPattern())) { @@ -1450,8 +1442,8 @@ public class DirectoryScanner * @return true when the name matches against the start of the * include pattern, or false 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 true when the name matches against at least one * exclude pattern, or false 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 true when the name matches against at least one * exclude pattern, or false otherwise. */ - private boolean isExcluded(TokenizedPath name) { + private boolean isExcluded(final TokenizedPath name) { ensureNonPatternSetsReady(); if (isCaseSensitive() @@ -1557,7 +1549,7 @@ public class DirectoryScanner * @return false when the selectors says that the file * should not be selected, true 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 map, String[] patterns) { - ArrayList al = new ArrayList(patterns.length); + private TokenizedPattern[] fillNonPatternSet(final Map map, final String[] patterns) { + final ArrayList al = new ArrayList(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 directoryNamesFollowed) { + private boolean causesIllegalSymlinkLoop(final String dirName, final File parent, + final LinkedList directoryNamesFollowed) { try { if (directoryNamesFollowed.size() >= maxLevelsOfSymlinks && CollectionUtils.frequency(directoryNamesFollowed, dirName) >= maxLevelsOfSymlinks && SYMLINK_UTILS.isSymbolicLink(parent, dirName)) { - ArrayList files = new ArrayList(); + final ArrayList files = new ArrayList(); 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); } diff --git a/src/main/org/apache/tools/ant/Main.java b/src/main/org/apache/tools/ant/Main.java index 6cf4718a9..845317681 100644 --- a/src/main/org/apache/tools/ant/Main.java +++ b/src/main/org/apache/tools/ant/Main.java @@ -157,7 +157,6 @@ public class Main implements AntMain { private final Map, List> extraArguments = new HashMap, List>(); private static final GetProperty NOPROPERTIES = new GetProperty() { - @Override public Object getProperty(final String aName) { // No existing property takes precedence return null; @@ -208,7 +207,6 @@ public class Main implements AntMain { * * @since Ant 1.6 */ - @Override public void startAnt(final String[] args, final Properties additionalUserProperties, final ClassLoader coreLoader) { diff --git a/src/main/org/apache/tools/ant/Project.java b/src/main/org/apache/tools/ant/Project.java index 02b23c95d..0412efa70 100644 --- a/src/main/org/apache/tools/ant/Project.java +++ b/src/main/org/apache/tools/ant/Project.java @@ -2487,7 +2487,6 @@ public class Project implements ResourceFactory { * @return the file resource. * @since Ant 1.7 */ - @Override public Resource getResource(final String name) { return new FileResource(getBaseDir(), name); } diff --git a/src/main/org/apache/tools/ant/filters/ConcatFilter.java b/src/main/org/apache/tools/ant/filters/ConcatFilter.java index a28edbfef..593e74a80 100644 --- a/src/main/org/apache/tools/ant/filters/ConcatFilter.java +++ b/src/main/org/apache/tools/ant/filters/ConcatFilter.java @@ -171,9 +171,8 @@ public final class ConcatFilter extends BaseParamFilterReader * @return a new filter based on this configuration, but filtering * the specified reader */ - @Override public Reader chain(final Reader rdr) { - ConcatFilter newFilter = new ConcatFilter(rdr); + final ConcatFilter newFilter = new ConcatFilter(rdr); newFilter.setPrepend(getPrepend()); newFilter.setAppend(getAppend()); // Usually the initialized is set to true. But here it must not. @@ -190,7 +189,7 @@ public final class ConcatFilter extends BaseParamFilterReader */ private void initialize() throws IOException { // get parameters - Parameter[] params = getParameters(); + final Parameter[] params = getParameters(); if (params != null) { for (int i = 0; i < params.length; i++) { if ("prepend".equals(params[i].getName())) { diff --git a/src/main/org/apache/tools/ant/taskdefs/AntStructure.java b/src/main/org/apache/tools/ant/taskdefs/AntStructure.java index f5677d898..db7d916c0 100644 --- a/src/main/org/apache/tools/ant/taskdefs/AntStructure.java +++ b/src/main/org/apache/tools/ant/taskdefs/AntStructure.java @@ -182,12 +182,10 @@ public class AntStructure extends Task { private final Hashtable visited = new Hashtable(); - @Override public void printTail(final PrintWriter out) { visited.clear(); } - @Override public void printHead(final PrintWriter out, final Project p, final Hashtable> tasks, final Hashtable> types) { printHead(out, tasks.keys(), types.keys()); @@ -246,7 +244,6 @@ public class AntStructure extends Task { /** * Prints the definition for the target element. */ - @Override public void printTargetDecl(final PrintWriter out) { out.print(" element) { diff --git a/src/main/org/apache/tools/ant/taskdefs/Copy.java b/src/main/org/apache/tools/ant/taskdefs/Copy.java index 7fdfaf2f4..191b9e31c 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Copy.java +++ b/src/main/org/apache/tools/ant/taskdefs/Copy.java @@ -823,16 +823,16 @@ public class Copy extends Task { toCopy = new Resource[v.size()]; v.copyInto(toCopy); } else { - toCopy = - ResourceUtils.selectOutOfDateSources(this, fromResources, - mapper, - new ResourceFactory() { - @Override + toCopy = ResourceUtils.selectOutOfDateSources( + this, + fromResources, + mapper, + new ResourceFactory() { public Resource getResource(final String name) { - return new FileResource(toDir, name); - } - }, - granularity); + return new FileResource(toDir, name); + } + }, + granularity); } for (int i = 0; i < toCopy.length; i++) { final String[] mappedFiles = mapper.mapFileName(toCopy[i].getName()); diff --git a/src/main/org/apache/tools/ant/taskdefs/Get.java b/src/main/org/apache/tools/ant/taskdefs/Get.java index de0792170..0577d515f 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Get.java +++ b/src/main/org/apache/tools/ant/taskdefs/Get.java @@ -71,7 +71,7 @@ public class Get extends Task { private static final String DEFAULT_AGENT_PREFIX = "Apache Ant"; private static final String GZIP_CONTENT_ENCODING = "gzip"; - private Resources sources = new Resources(); + private final Resources sources = new Resources(); private File destination; // required private boolean verbose = false; private boolean quiet = false; @@ -98,9 +98,9 @@ public class Get extends Task { public void execute() throws BuildException { checkAttributes(); - for (Resource r : sources) { - URLProvider up = r.as(URLProvider.class); - URL source = up.getURL(); + for (final Resource r : sources) { + final URLProvider up = r.as(URLProvider.class); + final URL source = up.getURL(); File dest = destination; if (destination.isDirectory()) { @@ -109,14 +109,14 @@ public class Get extends Task { if (path.endsWith("/")) { path = path.substring(0, path.length() - 1); } - int slash = path.lastIndexOf("/"); + final int slash = path.lastIndexOf("/"); if (slash > -1) { path = path.substring(slash + 1); } dest = new File(destination, path); } else { - FileNameMapper mapper = mapperElement.getImplementation(); - String[] d = mapper.mapFileName(source.toString()); + final FileNameMapper mapper = mapperElement.getImplementation(); + final String[] d = mapper.mapFileName(source.toString()); if (d == null) { log("skipping " + r + " - mapper can't handle it", Project.MSG_WARN); @@ -135,7 +135,7 @@ public class Get extends Task { } //set up logging - int logLevel = Project.MSG_INFO; + final int logLevel = Project.MSG_INFO; DownloadProgress progress = null; if (verbose) { progress = new VerboseProgress(System.out); @@ -144,7 +144,7 @@ public class Get extends Task { //execute the get try { doGet(source, dest, logLevel, progress); - } catch (IOException ioe) { + } catch (final IOException ioe) { log("Error getting " + source + " to " + dest); if (!ignoreErrors) { throw new BuildException(ioe, getLocation()); @@ -168,12 +168,12 @@ public class Get extends Task { * @deprecated only gets the first configured resource */ @Deprecated - public boolean doGet(int logLevel, DownloadProgress progress) + public boolean doGet(final int logLevel, final DownloadProgress progress) throws IOException { checkAttributes(); - for (Resource r : sources) { - URLProvider up = r.as(URLProvider.class); - URL source = up.getURL(); + for (final Resource r : sources) { + final URLProvider up = r.as(URLProvider.class); + final URL source = up.getURL(); return doGet(source, destination, logLevel, progress); } /*NOTREACHED*/ @@ -197,7 +197,7 @@ public class Get extends Task { * is false. * @since Ant 1.8.0 */ - public boolean doGet(URL source, File dest, int logLevel, + public boolean doGet(final URL source, final File dest, final int logLevel, DownloadProgress progress) throws IOException { @@ -221,13 +221,13 @@ public class Get extends Task { if (useTimestamp && dest.exists()) { timestamp = dest.lastModified(); if (verbose) { - Date t = new Date(timestamp); + final Date t = new Date(timestamp); log("local file date : " + t.toString(), logLevel); } hasTimestamp = true; } - GetThread getThread = new GetThread(source, dest, + final GetThread getThread = new GetThread(source, dest, hasTimestamp, timestamp, progress, logLevel, userAgent); getThread.setDaemon(true); @@ -235,13 +235,13 @@ public class Get extends Task { getThread.start(); try { getThread.join(maxTime * 1000); - } catch (InterruptedException ie) { + } catch (final InterruptedException ie) { log("interrupted waiting for GET to finish", Project.MSG_VERBOSE); } if (getThread.isAlive()) { - String msg = "The GET operation took longer than " + maxTime + final String msg = "The GET operation took longer than " + maxTime + " seconds, stopping it."; if (ignoreErrors) { log(msg); @@ -257,7 +257,7 @@ public class Get extends Task { } @Override - public void log(String msg, int msgLevel) { + public void log(final String msg, final int msgLevel) { if (!quiet || msgLevel >= Project.MSG_ERR) { super.log(msg, msgLevel); } @@ -276,8 +276,8 @@ public class Get extends Task { throw new BuildException("at least one source is required", getLocation()); } - for (Resource r : sources) { - URLProvider up = r.as(URLProvider.class); + for (final Resource r : sources) { + final URLProvider up = r.as(URLProvider.class); if (up == null) { throw new BuildException("Only URLProvider resources are" + " supported", getLocation()); @@ -311,7 +311,7 @@ public class Get extends Task { * * @param u URL for the file. */ - public void setSrc(URL u) { + public void setSrc(final URL u) { add(new URLResource(u)); } @@ -319,7 +319,7 @@ public class Get extends Task { * Adds URLs to get. * @since Ant 1.8.0 */ - public void add(ResourceCollection rc) { + public void add(final ResourceCollection rc) { sources.add(rc); } @@ -328,7 +328,7 @@ public class Get extends Task { * * @param dest Path to file. */ - public void setDest(File dest) { + public void setDest(final File dest) { this.destination = dest; } @@ -337,7 +337,7 @@ public class Get extends Task { * * @param v if "true" then be verbose */ - public void setVerbose(boolean v) { + public void setVerbose(final boolean v) { verbose = v; } @@ -347,7 +347,7 @@ public class Get extends Task { * @param v if "true" then be quiet * @since Ant 1.9.4 */ - public void setQuiet(boolean v){ + public void setQuiet(final boolean v){ this.quiet = v; } @@ -356,7 +356,7 @@ public class Get extends Task { * * @param v if "true" then don't report download errors up to ant */ - public void setIgnoreErrors(boolean v) { + public void setIgnoreErrors(final boolean v) { ignoreErrors = v; } @@ -378,7 +378,7 @@ public class Get extends Task { * cause no end of grief.

* @param v "true" to enable file time fetching */ - public void setUseTimestamp(boolean v) { + public void setUseTimestamp(final boolean v) { useTimestamp = v; } @@ -388,7 +388,7 @@ public class Get extends Task { * * @param u username for authentication */ - public void setUsername(String u) { + public void setUsername(final String u) { this.uname = u; } @@ -397,7 +397,7 @@ public class Get extends Task { * * @param p password for authentication */ - public void setPassword(String p) { + public void setPassword(final String p) { this.pword = p; } @@ -407,7 +407,7 @@ public class Get extends Task { * * @since Ant 1.8.0 */ - public void setMaxTime(long maxTime) { + public void setMaxTime(final long maxTime) { this.maxTime = maxTime; } @@ -418,7 +418,7 @@ public class Get extends Task { * * @since Ant 1.8.0 */ - public void setRetries(int r) { + public void setRetries(final int r) { this.numberRetries = r; } @@ -429,7 +429,7 @@ public class Get extends Task { * * @since Ant 1.8.0 */ - public void setSkipExisting(boolean s) { + public void setSkipExisting(final boolean s) { this.skipExisting = s; } @@ -441,7 +441,7 @@ public class Get extends Task { * * @since Ant 1.9.3 */ - public void setUserAgent(String userAgent) { + public void setUserAgent(final String userAgent) { this.userAgent = userAgent; } @@ -455,7 +455,7 @@ public class Get extends Task { * * @since Ant 1.8.0 */ - public void setHttpUseCaches(boolean httpUseCache) { + public void setHttpUseCaches(final boolean httpUseCache) { this.httpUseCaches = httpUseCache; } @@ -479,7 +479,7 @@ public class Get extends Task { * @param fileNameMapper the mapper to add. * @since Ant 1.8.0 */ - public void add(FileNameMapper fileNameMapper) { + public void add(final FileNameMapper fileNameMapper) { createMapper().add(fileNameMapper); } @@ -520,25 +520,20 @@ public class Get extends Task { /** * begin a download */ - @Override public void beginDownload() { - } /** * tick handler * */ - @Override public void onTick() { } /** * end a download */ - @Override public void endDownload() { - } } @@ -555,14 +550,13 @@ public class Get extends Task { * Construct a verbose progress reporter. * @param out the output stream. */ - public VerboseProgress(PrintStream out) { + public VerboseProgress(final PrintStream out) { this.out = out; } /** * begin a download */ - @Override public void beginDownload() { dots = 0; } @@ -571,7 +565,6 @@ public class Get extends Task { * tick handler * */ - @Override public void onTick() { out.print("."); if (dots++ > DOTS_PER_LINE) { @@ -583,7 +576,6 @@ public class Get extends Task { /** * end a download */ - @Override public void endDownload() { out.println(); out.flush(); @@ -608,8 +600,8 @@ public class Get extends Task { private int redirections = 0; private String userAgent = null; - GetThread(URL source, File dest, - boolean h, long t, DownloadProgress p, int l, String userAgent) { + GetThread(final URL source, final File dest, + final boolean h, final long t, final DownloadProgress p, final int l, final String userAgent) { this.source = source; this.dest = dest; hasTimestamp = h; @@ -623,9 +615,9 @@ public class Get extends Task { public void run() { try { success = get(); - } catch (IOException ioex) { + } catch (final IOException ioex) { ioexception = ioex; - } catch (BuildException bex) { + } catch (final BuildException bex) { exception = bex; } } @@ -638,7 +630,7 @@ public class Get extends Task { return false; } - boolean downloadSucceeded = downloadFile(); + final boolean downloadSucceeded = downloadFile(); //if (and only if) the use file time option is set, then //the saved file now has its timestamp set to that of the @@ -651,11 +643,11 @@ public class Get extends Task { } - private boolean redirectionAllowed(URL aSource, URL aDest) { + private boolean redirectionAllowed(final URL aSource, final URL aDest) { if (!(aSource.getProtocol().equals(aDest.getProtocol()) || (HTTP .equals(aSource.getProtocol()) && HTTPS.equals(aDest .getProtocol())))) { - String message = "Redirection detected from " + final String message = "Redirection detected from " + aSource.getProtocol() + " to " + aDest.getProtocol() + ". Protocol switch unsafe, not allowed."; if (ignoreErrors) { @@ -668,7 +660,7 @@ public class Get extends Task { redirections++; if (redirections > REDIRECT_LIMIT) { - String message = "More than " + REDIRECT_LIMIT + final String message = "More than " + REDIRECT_LIMIT + " times redirected, giving up"; if (ignoreErrors) { log(message, logLevel); @@ -682,10 +674,10 @@ public class Get extends Task { return true; } - private URLConnection openConnection(URL aSource) throws IOException { + private URLConnection openConnection(final URL aSource) throws IOException { // set up the URL connection - URLConnection connection = aSource.openConnection(); + final URLConnection connection = aSource.openConnection(); // modify the headers // NB: things like user authentication could go in here too. if (hasTimestamp) { @@ -696,12 +688,12 @@ public class Get extends Task { // prepare Java 1.1 style credentials if (uname != null || pword != null) { - String up = uname + ":" + pword; + final String up = uname + ":" + pword; String encoding; // we do not use the sun impl for portability, // and always use our own implementation for consistent // testing - Base64Converter encoder = new Base64Converter(); + final Base64Converter encoder = new Base64Converter(); encoding = encoder.encode(up.getBytes()); connection.setRequestProperty("Authorization", "Basic " + encoding); @@ -718,29 +710,29 @@ public class Get extends Task { // connect to the remote site (may take some time) try { connection.connect(); - } catch (NullPointerException e) { + } catch (final NullPointerException e) { //bad URLs can trigger NPEs in some JVMs throw new BuildException("Failed to parse " + source.toString(), e); } // First check on a 301 / 302 (moved) response (HTTP only) if (connection instanceof HttpURLConnection) { - HttpURLConnection httpConnection = (HttpURLConnection) connection; - int responseCode = httpConnection.getResponseCode(); + final HttpURLConnection httpConnection = (HttpURLConnection) connection; + final int responseCode = httpConnection.getResponseCode(); if (isMoved(responseCode)) { - String newLocation = httpConnection.getHeaderField("Location"); - String message = aSource + final String newLocation = httpConnection.getHeaderField("Location"); + final String message = aSource + (responseCode == HttpURLConnection.HTTP_MOVED_PERM ? " permanently" : "") + " moved to " + newLocation; log(message, logLevel); - URL newURL = new URL(aSource, newLocation); + final URL newURL = new URL(aSource, newLocation); if (!redirectionAllowed(aSource, newURL)) { return null; } return openConnection(newURL); } // next test for a 304 result (HTTP only) - long lastModified = httpConnection.getLastModified(); + final long lastModified = httpConnection.getLastModified(); if (responseCode == HttpURLConnection.HTTP_NOT_MODIFIED || (lastModified != 0 && hasTimestamp && timestamp >= lastModified)) { // not modified so no file download. just return @@ -752,7 +744,7 @@ public class Get extends Task { } // test for 401 result (HTTP only) if (responseCode == HttpURLConnection.HTTP_UNAUTHORIZED) { - String message = "HTTP Authorization failure"; + final String message = "HTTP Authorization failure"; if (ignoreErrors) { log(message, logLevel); return null; @@ -770,7 +762,7 @@ public class Get extends Task { return connection; } - private boolean isMoved(int responseCode) { + private boolean isMoved(final int responseCode) { return responseCode == HttpURLConnection.HTTP_MOVED_PERM || responseCode == HttpURLConnection.HTTP_MOVED_TEMP || responseCode == HttpURLConnection.HTTP_SEE_OTHER || @@ -786,7 +778,7 @@ public class Get extends Task { try { is = connection.getInputStream(); break; - } catch (IOException ex) { + } catch (final IOException ex) { log("Error opening connection " + ex, logLevel); } } @@ -807,7 +799,7 @@ public class Get extends Task { progress.beginDownload(); boolean finished = false; try { - byte[] buffer = new byte[BIG_BUFFER_SIZE]; + final byte[] buffer = new byte[BIG_BUFFER_SIZE]; int length; while (!isInterrupted() && (length = is.read(buffer)) >= 0) { os.write(buffer, 0, length); @@ -830,9 +822,9 @@ public class Get extends Task { } private void updateTimeStamp() { - long remoteTimestamp = connection.getLastModified(); + final long remoteTimestamp = connection.getLastModified(); if (verbose) { - Date t = new Date(remoteTimestamp); + final Date t = new Date(remoteTimestamp); log("last modified = " + t.toString() + ((remoteTimestamp == 0) ? " - using current time instead" diff --git a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java index 5ce62ef86..a82b52a0b 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java +++ b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java @@ -107,7 +107,7 @@ public class Javadoc extends Task { * * @param name the name of the doclet parameter */ - public void setName(String name) { + public void setName(final String name) { this.name = name; } @@ -128,7 +128,7 @@ public class Javadoc extends Task { * * @param value the parameter value. */ - public void setValue(String value) { + public void setValue(final String value) { this.value = value; } @@ -159,7 +159,7 @@ public class Javadoc extends Task { * * @param name the extension's name. */ - public void setName(String name) { + public void setName(final String name) { this.name = name; } @@ -177,7 +177,7 @@ public class Javadoc extends Task { * * @param path a Path instance containing the classpath to use. */ - public void setPath(Path path) { + public void setPath(final Path path) { if (this.path == null) { this.path = path; } else { @@ -213,7 +213,7 @@ public class Javadoc extends Task { * * @param r the reference containing the path. */ - public void setPathRef(Reference r) { + public void setPathRef(final Reference r) { createPath().setRefid(r); } } @@ -225,7 +225,7 @@ public class Javadoc extends Task { public class DocletInfo extends ExtensionInfo { /** Collection of doclet parameters. */ - private Vector params = new Vector(); + private final Vector params = new Vector(); /** * Create a doclet parameter to be configured by Ant. @@ -233,7 +233,7 @@ public class Javadoc extends Task { * @return a new DocletParam instance to be configured. */ public DocletParam createParam() { - DocletParam param = new DocletParam(); + final DocletParam param = new DocletParam(); params.addElement(param); return param; @@ -261,7 +261,7 @@ public class Javadoc extends Task { * * @param name the package name. */ - public void setName(String name) { + public void setName(final String name) { this.name = name.trim(); } @@ -303,7 +303,7 @@ public class Javadoc extends Task { * * @param file the source file */ - public SourceFile(File file) { + public SourceFile(final File file) { this.file = file; } @@ -312,7 +312,7 @@ public class Javadoc extends Task { * * @param file the source file. */ - public void setFile(File file) { + public void setFile(final File file) { this.file = file; } @@ -334,14 +334,14 @@ public class Javadoc extends Task { */ public static class Html { /** The text for the element */ - private StringBuffer text = new StringBuffer(); + private final StringBuffer text = new StringBuffer(); /** * Add text to the element. * * @param t the text to be added. */ - public void addText(String t) { + public void addText(final String t) { text.append(t); } @@ -379,12 +379,12 @@ public class Javadoc extends Task { * task runtime.

*/ public class ResourceCollectionContainer { - private ArrayList rcs = new ArrayList(); + private final ArrayList rcs = new ArrayList(); /** * Add a resource collection to the container. * @param rc the collection to add. */ - public void add(ResourceCollection rc) { + public void add(final ResourceCollection rc) { rcs.add(rc); } @@ -400,7 +400,7 @@ public class Javadoc extends Task { private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); /** The command line built to execute Javadoc. */ - private Commandline cmd = new Commandline(); + private final Commandline cmd = new Commandline(); /** * Utility method to add an argument to the command line conditionally @@ -409,7 +409,7 @@ public class Javadoc extends Task { * @param b the flag which controls if the argument is added. * @param arg the argument value. */ - private void addArgIf(boolean b, String arg) { + private void addArgIf(final boolean b, final String arg) { if (b) { cmd.createArgument().setValue(arg); } @@ -421,7 +421,7 @@ public class Javadoc extends Task { * @param key the argument name. * @param value the argument value. */ - private void addArgIfNotEmpty(String key, String value) { + private void addArgIfNotEmpty(final String key, final String value) { if (value != null && value.length() != 0) { cmd.createArgument().setValue(key); cmd.createArgument().setValue(value); @@ -443,9 +443,9 @@ public class Javadoc extends Task { private boolean failOnWarning = false; private Path sourcePath = null; private File destDir = null; - private Vector sourceFiles = new Vector(); - private Vector packageNames = new Vector(); - private Vector excludePackageNames = new Vector(1); + private final Vector sourceFiles = new Vector(); + private final Vector packageNames = new Vector(); + private final Vector excludePackageNames = new Vector(1); private boolean author = true; private boolean version = true; private DocletInfo doclet = null; @@ -453,9 +453,9 @@ public class Javadoc extends Task { private Path bootclasspath = null; private String group = null; private String packageList = null; - private Vector links = new Vector(); - private Vector groups = new Vector(); - private Vector tags = new Vector(); + private final Vector links = new Vector(); + private final Vector groups = new Vector(); + private final Vector tags = new Vector(); private boolean useDefaultExcludes = true; private Html doctitle = null; private Html header = null; @@ -473,9 +473,9 @@ public class Javadoc extends Task { private String docEncoding = null; private boolean postProcessGeneratedJavadocs = true; - private ResourceCollectionContainer nestedSourceFiles + private final ResourceCollectionContainer nestedSourceFiles = new ResourceCollectionContainer(); - private Vector packageSets = new Vector(); + private final Vector packageSets = new Vector(); /** * Work around command line length limit by using an external file @@ -483,7 +483,7 @@ public class Javadoc extends Task { * * @param b true if an external file is to be used. */ - public void setUseExternalFile(boolean b) { + public void setUseExternalFile(final boolean b) { useExternalFile = b; } @@ -494,7 +494,7 @@ public class Javadoc extends Task { * should be used, "false"|"off"|"no" when they * shouldn't be used. */ - public void setDefaultexcludes(boolean useDefaultExcludes) { + public void setDefaultexcludes(final boolean useDefaultExcludes) { this.useDefaultExcludes = useDefaultExcludes; } @@ -504,7 +504,7 @@ public class Javadoc extends Task { * @param max a string indicating the maximum memory according to the * JVM conventions (e.g. 128m is 128 Megabytes) */ - public void setMaxmemory(String max) { + public void setMaxmemory(final String max) { cmd.createArgument().setValue("-J-Xmx" + max); } @@ -513,7 +513,7 @@ public class Javadoc extends Task { * * @param add the additional command line parameter for the javadoc task. */ - public void setAdditionalparam(String add) { + public void setAdditionalparam(final String add) { cmd.createArgument().setLine(add); } @@ -531,7 +531,7 @@ public class Javadoc extends Task { * * @param src a Path instance containing the various source directories. */ - public void setSourcepath(Path src) { + public void setSourcepath(final Path src) { if (sourcePath == null) { sourcePath = src; } else { @@ -557,7 +557,7 @@ public class Javadoc extends Task { * * @param r the reference containing the source path definition. */ - public void setSourcepathRef(Reference r) { + public void setSourcepathRef(final Reference r) { createSourcepath().setRefid(r); } @@ -566,7 +566,7 @@ public class Javadoc extends Task { * * @param dir the destination directory. */ - public void setDestdir(File dir) { + public void setDestdir(final File dir) { destDir = dir; cmd.createArgument().setValue("-d"); cmd.createArgument().setFile(destDir); @@ -577,11 +577,11 @@ public class Javadoc extends Task { * * @param src a comma separated list of source files. */ - public void setSourcefiles(String src) { - StringTokenizer tok = new StringTokenizer(src, ","); + public void setSourcefiles(final String src) { + final StringTokenizer tok = new StringTokenizer(src, ","); while (tok.hasMoreTokens()) { - String f = tok.nextToken(); - SourceFile sf = new SourceFile(); + final String f = tok.nextToken(); + final SourceFile sf = new SourceFile(); sf.setFile(getProject().resolveFile(f.trim())); addSource(sf); } @@ -592,7 +592,7 @@ public class Javadoc extends Task { * * @param sf the source file to be processed. */ - public void addSource(SourceFile sf) { + public void addSource(final SourceFile sf) { sourceFiles.addElement(sf); } @@ -604,11 +604,11 @@ public class Javadoc extends Task { * * @see #addPackage for wildcard information. */ - public void setPackagenames(String packages) { - StringTokenizer tok = new StringTokenizer(packages, ","); + public void setPackagenames(final String packages) { + final StringTokenizer tok = new StringTokenizer(packages, ","); while (tok.hasMoreTokens()) { - String p = tok.nextToken(); - PackageName pn = new PackageName(); + final String p = tok.nextToken(); + final PackageName pn = new PackageName(); pn.setName(p); addPackage(pn); } @@ -622,7 +622,7 @@ public class Javadoc extends Task { * * @param pn the package name, possibly wildcarded. */ - public void addPackage(PackageName pn) { + public void addPackage(final PackageName pn) { packageNames.addElement(pn); } @@ -632,11 +632,11 @@ public class Javadoc extends Task { * @param packages a comma separated list of packages to be excluded. * This may not include wildcards. */ - public void setExcludePackageNames(String packages) { - StringTokenizer tok = new StringTokenizer(packages, ","); + public void setExcludePackageNames(final String packages) { + final StringTokenizer tok = new StringTokenizer(packages, ","); while (tok.hasMoreTokens()) { - String p = tok.nextToken(); - PackageName pn = new PackageName(); + final String p = tok.nextToken(); + final PackageName pn = new PackageName(); pn.setName(p); addExcludePackage(pn); } @@ -647,7 +647,7 @@ public class Javadoc extends Task { * * @param pn the name of the package (wildcards are not permitted). */ - public void addExcludePackage(PackageName pn) { + public void addExcludePackage(final PackageName pn) { excludePackageNames.addElement(pn); } @@ -657,7 +657,7 @@ public class Javadoc extends Task { * * @param f the file containing the overview. */ - public void setOverview(File f) { + public void setOverview(final File f) { cmd.createArgument().setValue("-overview"); cmd.createArgument().setFile(f); } @@ -668,7 +668,7 @@ public class Javadoc extends Task { * * @param b true if scope is to be public. */ - public void setPublic(boolean b) { + public void setPublic(final boolean b) { addArgIf(b, "-public"); } @@ -678,7 +678,7 @@ public class Javadoc extends Task { * * @param b true if scope is to be protected. */ - public void setProtected(boolean b) { + public void setProtected(final boolean b) { addArgIf(b, "-protected"); } @@ -688,7 +688,7 @@ public class Javadoc extends Task { * * @param b true if scope is to be package level. */ - public void setPackage(boolean b) { + public void setPackage(final boolean b) { addArgIf(b, "-package"); } @@ -698,7 +698,7 @@ public class Javadoc extends Task { * * @param b true if scope is to be private level. */ - public void setPrivate(boolean b) { + public void setPrivate(final boolean b) { addArgIf(b, "-private"); } @@ -709,7 +709,7 @@ public class Javadoc extends Task { * * @param at the scope to be processed. */ - public void setAccess(AccessType at) { + public void setAccess(final AccessType at) { cmd.createArgument().setValue("-" + at.getValue()); } @@ -719,7 +719,7 @@ public class Javadoc extends Task { * * @param docletName the name of the doclet class. */ - public void setDoclet(String docletName) { + public void setDoclet(final String docletName) { if (doclet == null) { doclet = new DocletInfo(); doclet.setProject(getProject()); @@ -732,7 +732,7 @@ public class Javadoc extends Task { * * @param docletPath the doclet classpath. */ - public void setDocletPath(Path docletPath) { + public void setDocletPath(final Path docletPath) { if (doclet == null) { doclet = new DocletInfo(); doclet.setProject(getProject()); @@ -746,7 +746,7 @@ public class Javadoc extends Task { * @param r the reference to the Path instance to use as the doclet * classpath. */ - public void setDocletPathRef(Reference r) { + public void setDocletPathRef(final Reference r) { if (doclet == null) { doclet = new DocletInfo(); doclet.setProject(getProject()); @@ -771,7 +771,7 @@ public class Javadoc extends Task { * * @param tagletInfo information about the taglet. */ - public void addTaglet(ExtensionInfo tagletInfo) { + public void addTaglet(final ExtensionInfo tagletInfo) { tags.addElement(tagletInfo); } @@ -783,7 +783,7 @@ public class Javadoc extends Task { * * @param b if true attempt to generate old style documentation. */ - public void setOld(boolean b) { + public void setOld(final boolean b) { log("Javadoc 1.4 doesn't support the -1.1 switch anymore", Project.MSG_WARN); } @@ -794,7 +794,7 @@ public class Javadoc extends Task { * @param path an Ant Path object containing the compilation * classpath. */ - public void setClasspath(Path path) { + public void setClasspath(final Path path) { if (classpath == null) { classpath = path; } else { @@ -819,7 +819,7 @@ public class Javadoc extends Task { * * @param r the reference to an instance defining the classpath. */ - public void setClasspathRef(Reference r) { + public void setClasspathRef(final Reference r) { createClasspath().setRefid(r); } @@ -828,7 +828,7 @@ public class Javadoc extends Task { * * @param path the boot classpath. */ - public void setBootclasspath(Path path) { + public void setBootclasspath(final Path path) { if (bootclasspath == null) { bootclasspath = path; } else { @@ -853,7 +853,7 @@ public class Javadoc extends Task { * * @param r the reference to an instance defining the bootclasspath. */ - public void setBootClasspathRef(Reference r) { + public void setBootClasspathRef(final Reference r) { createBootclasspath().setRefid(r); } @@ -865,7 +865,7 @@ public class Javadoc extends Task { * Use the {@link #setExtdirs(Path)} version. */ @Deprecated - public void setExtdirs(String path) { + public void setExtdirs(final String path) { cmd.createArgument().setValue("-extdirs"); cmd.createArgument().setValue(path); } @@ -875,7 +875,7 @@ public class Javadoc extends Task { * * @param path a path containing the extension directories. */ - public void setExtdirs(Path path) { + public void setExtdirs(final Path path) { cmd.createArgument().setValue("-extdirs"); cmd.createArgument().setPath(path); } @@ -885,7 +885,7 @@ public class Javadoc extends Task { * * @param b true if operation is to be verbose. */ - public void setVerbose(boolean b) { + public void setVerbose(final boolean b) { addArgIf(b, "-verbose"); } @@ -894,7 +894,7 @@ public class Javadoc extends Task { * * @param locale the locale to use. */ - public void setLocale(String locale) { + public void setLocale(final String locale) { // createArgument(true) is necessary to make sure -locale // is the first argument (required in 1.3+). cmd.createArgument(true).setValue(locale); @@ -906,7 +906,7 @@ public class Javadoc extends Task { * * @param enc the name of the encoding for the source files. */ - public void setEncoding(String enc) { + public void setEncoding(final String enc) { cmd.createArgument().setValue("-encoding"); cmd.createArgument().setValue(enc); } @@ -916,7 +916,7 @@ public class Javadoc extends Task { * * @param b true if the version tag should be included. */ - public void setVersion(boolean b) { + public void setVersion(final boolean b) { this.version = b; } @@ -925,7 +925,7 @@ public class Javadoc extends Task { * * @param b true if the use page should be generated. */ - public void setUse(boolean b) { + public void setUse(final boolean b) { addArgIf(b, "-use"); } @@ -935,7 +935,7 @@ public class Javadoc extends Task { * * @param b true if the author tag should be included. */ - public void setAuthor(boolean b) { + public void setAuthor(final boolean b) { author = b; } @@ -944,7 +944,7 @@ public class Javadoc extends Task { * * @param b true if the index should be split into a file per letter. */ - public void setSplitindex(boolean b) { + public void setSplitindex(final boolean b) { addArgIf(b, "-splitindex"); } @@ -954,7 +954,7 @@ public class Javadoc extends Task { * * @param title the window title to use. */ - public void setWindowtitle(String title) { + public void setWindowtitle(final String title) { addArgIfNotEmpty("-windowtitle", title); } @@ -963,8 +963,8 @@ public class Javadoc extends Task { * * @param doctitle the Document title. */ - public void setDoctitle(String doctitle) { - Html h = new Html(); + public void setDoctitle(final String doctitle) { + final Html h = new Html(); h.addText(doctitle); addDoctitle(h); } @@ -974,7 +974,7 @@ public class Javadoc extends Task { * * @param text the HTML element containing the document title. */ - public void addDoctitle(Html text) { + public void addDoctitle(final Html text) { doctitle = text; } @@ -983,8 +983,8 @@ public class Javadoc extends Task { * * @param header the header text */ - public void setHeader(String header) { - Html h = new Html(); + public void setHeader(final String header) { + final Html h = new Html(); h.addText(header); addHeader(h); } @@ -994,7 +994,7 @@ public class Javadoc extends Task { * * @param text the header text */ - public void addHeader(Html text) { + public void addHeader(final Html text) { header = text; } @@ -1003,8 +1003,8 @@ public class Javadoc extends Task { * * @param footer the footer text. */ - public void setFooter(String footer) { - Html h = new Html(); + public void setFooter(final String footer) { + final Html h = new Html(); h.addText(footer); addFooter(h); } @@ -1014,7 +1014,7 @@ public class Javadoc extends Task { * * @param text the footer text. */ - public void addFooter(Html text) { + public void addFooter(final Html text) { footer = text; } @@ -1023,8 +1023,8 @@ public class Javadoc extends Task { * * @param bottom the bottom text. */ - public void setBottom(String bottom) { - Html h = new Html(); + public void setBottom(final String bottom) { + final Html h = new Html(); h.addText(bottom); addBottom(h); } @@ -1034,7 +1034,7 @@ public class Javadoc extends Task { * * @param text the bottom text. */ - public void addBottom(Html text) { + public void addBottom(final Html text) { bottom = text; } @@ -1044,16 +1044,16 @@ public class Javadoc extends Task { * * @param src the offline link specification (url and package list) */ - public void setLinkoffline(String src) { - LinkArgument le = createLink(); + public void setLinkoffline(final String src) { + final LinkArgument le = createLink(); le.setOffline(true); - String linkOfflineError = "The linkoffline attribute must include" + final String linkOfflineError = "The linkoffline attribute must include" + " a URL and a package-list file location separated by a" + " space"; if (src.trim().length() == 0) { throw new BuildException(linkOfflineError); } - StringTokenizer tok = new StringTokenizer(src, " ", false); + final StringTokenizer tok = new StringTokenizer(src, " ", false); le.setHref(tok.nextToken()); if (!tok.hasMoreTokens()) { @@ -1069,7 +1069,7 @@ public class Javadoc extends Task { * each one being a group name and package specification separated * by a space. */ - public void setGroup(String src) { + public void setGroup(final String src) { group = src; } @@ -1077,7 +1077,7 @@ public class Javadoc extends Task { * Create links to Javadoc output at the given URL. * @param src the URL to link to */ - public void setLink(String src) { + public void setLink(final String src) { createLink().setHref(src); } @@ -1086,7 +1086,7 @@ public class Javadoc extends Task { * * @param b If true, do not include deprecated information. */ - public void setNodeprecated(boolean b) { + public void setNodeprecated(final boolean b) { addArgIf(b, "-nodeprecated"); } @@ -1095,7 +1095,7 @@ public class Javadoc extends Task { * * @param b if true, do not generate deprecated list. */ - public void setNodeprecatedlist(boolean b) { + public void setNodeprecatedlist(final boolean b) { addArgIf(b, "-nodeprecatedlist"); } @@ -1104,7 +1104,7 @@ public class Javadoc extends Task { * * @param b if true, do not generate class hierarchy. */ - public void setNotree(boolean b) { + public void setNotree(final boolean b) { addArgIf(b, "-notree"); } @@ -1113,7 +1113,7 @@ public class Javadoc extends Task { * * @param b if true, do not generate index. */ - public void setNoindex(boolean b) { + public void setNoindex(final boolean b) { addArgIf(b, "-noindex"); } @@ -1122,7 +1122,7 @@ public class Javadoc extends Task { * * @param b if true, do not generate help link */ - public void setNohelp(boolean b) { + public void setNohelp(final boolean b) { addArgIf(b, "-nohelp"); } @@ -1131,7 +1131,7 @@ public class Javadoc extends Task { * * @param b if true, do not generate navigation bar. */ - public void setNonavbar(boolean b) { + public void setNonavbar(final boolean b) { addArgIf(b, "-nonavbar"); } @@ -1140,7 +1140,7 @@ public class Javadoc extends Task { * * @param b if true, generate warning about the serial tag. */ - public void setSerialwarn(boolean b) { + public void setSerialwarn(final boolean b) { addArgIf(b, "-serialwarn"); } @@ -1149,7 +1149,7 @@ public class Javadoc extends Task { * * @param f the file with the CSS to use. */ - public void setStylesheetfile(File f) { + public void setStylesheetfile(final File f) { cmd.createArgument().setValue("-stylesheetfile"); cmd.createArgument().setFile(f); } @@ -1159,7 +1159,7 @@ public class Javadoc extends Task { * * @param f the file containing help content. */ - public void setHelpfile(File f) { + public void setHelpfile(final File f) { cmd.createArgument().setValue("-helpfile"); cmd.createArgument().setFile(f); } @@ -1169,7 +1169,7 @@ public class Javadoc extends Task { * * @param enc name of the encoding to use. */ - public void setDocencoding(String enc) { + public void setDocencoding(final String enc) { cmd.createArgument().setValue("-docencoding"); cmd.createArgument().setValue(enc); docEncoding = enc; @@ -1180,7 +1180,7 @@ public class Javadoc extends Task { * * @param src the file containing the package list. */ - public void setPackageList(String src) { + public void setPackageList(final String src) { packageList = src; } @@ -1190,7 +1190,7 @@ public class Javadoc extends Task { * @return link argument to configure */ public LinkArgument createLink() { - LinkArgument la = new LinkArgument(); + final LinkArgument la = new LinkArgument(); links.addElement(la); return la; } @@ -1215,7 +1215,7 @@ public class Javadoc extends Task { * Set the href attribute. * @param hr a String value */ - public void setHref(String hr) { + public void setHref(final String hr) { href = hr; } @@ -1231,7 +1231,7 @@ public class Javadoc extends Task { * Set the packetlist location attribute. * @param src a File value */ - public void setPackagelistLoc(File src) { + public void setPackagelistLoc(final File src) { packagelistLoc = src; } @@ -1247,7 +1247,7 @@ public class Javadoc extends Task { * Set the packetlist location attribute. * @param src an URL value */ - public void setPackagelistURL(URL src) { + public void setPackagelistURL(final URL src) { packagelistURL = src; } @@ -1263,7 +1263,7 @@ public class Javadoc extends Task { * Set the offline attribute. * @param offline a boolean value */ - public void setOffline(boolean offline) { + public void setOffline(final boolean offline) { this.offline = offline; } @@ -1280,7 +1280,7 @@ public class Javadoc extends Task { * to the current basedir. * @param resolve a boolean value */ - public void setResolveLink(boolean resolve) { + public void setResolveLink(final boolean resolve) { this.resolveLink = resolve; } @@ -1303,7 +1303,7 @@ public class Javadoc extends Task { * @return tag argument to be configured */ public TagArgument createTag() { - TagArgument ta = new TagArgument(); + final TagArgument ta = new TagArgument(); tags.addElement (ta); return ta; } @@ -1344,7 +1344,7 @@ public class Javadoc extends Task { * @param name The name of the tag. * Must not be null or empty. */ - public void setName (String name) { + public void setName (final String name) { this.name = name; } @@ -1367,16 +1367,16 @@ public class Javadoc extends Task { public void setScope (String verboseScope) throws BuildException { verboseScope = verboseScope.toLowerCase(Locale.ENGLISH); - boolean[] elements = new boolean[SCOPE_ELEMENTS.length]; + final boolean[] elements = new boolean[SCOPE_ELEMENTS.length]; boolean gotAll = false; boolean gotNotAll = false; // Go through the tokens one at a time, updating the // elements array and issuing warnings where appropriate. - StringTokenizer tok = new StringTokenizer (verboseScope, ","); + final StringTokenizer tok = new StringTokenizer (verboseScope, ","); while (tok.hasMoreTokens()) { - String next = tok.nextToken().trim(); + final String next = tok.nextToken().trim(); if (next.equals("all")) { if (gotAll) { getProject().log ("Repeated tag scope element: all", @@ -1415,7 +1415,7 @@ public class Javadoc extends Task { if (gotAll) { this.scope = "a"; } else { - StringBuffer buff = new StringBuffer (elements.length); + final StringBuffer buff = new StringBuffer (elements.length); for (int i = 0; i < elements.length; i++) { if (elements[i]) { buff.append (SCOPE_ELEMENTS[i].charAt(0)); @@ -1430,7 +1430,7 @@ public class Javadoc extends Task { * * @param enabled Whether or not this tag is enabled. */ - public void setEnabled (boolean enabled) { + public void setEnabled (final boolean enabled) { this.enabled = enabled; } @@ -1461,7 +1461,7 @@ public class Javadoc extends Task { * @return a group argument to be configured */ public GroupArgument createGroup() { - GroupArgument ga = new GroupArgument(); + final GroupArgument ga = new GroupArgument(); groups.addElement(ga); return ga; } @@ -1472,7 +1472,7 @@ public class Javadoc extends Task { */ public class GroupArgument { private Html title; - private Vector packages = new Vector(); + private final Vector packages = new Vector(); /** Constructor for GroupArgument */ public GroupArgument() { @@ -1483,8 +1483,8 @@ public class Javadoc extends Task { * Set the title attribute using a string. * @param src a String value */ - public void setTitle(String src) { - Html h = new Html(); + public void setTitle(final String src) { + final Html h = new Html(); h.addText(src); addTitle(h); } @@ -1492,7 +1492,7 @@ public class Javadoc extends Task { * Set the title attribute using a nested Html value. * @param text a Html value */ - public void addTitle(Html text) { + public void addTitle(final Html text) { title = text; } @@ -1508,11 +1508,11 @@ public class Javadoc extends Task { * Set the packages to Javadoc on. * @param src a comma separated list of packages */ - public void setPackages(String src) { - StringTokenizer tok = new StringTokenizer(src, ","); + public void setPackages(final String src) { + final StringTokenizer tok = new StringTokenizer(src, ","); while (tok.hasMoreTokens()) { - String p = tok.nextToken(); - PackageName pn = new PackageName(); + final String p = tok.nextToken(); + final PackageName pn = new PackageName(); pn.setName(p); addPackage(pn); } @@ -1521,7 +1521,7 @@ public class Javadoc extends Task { * Add a package nested element. * @param pn a nested element specifying the package. */ - public void addPackage(PackageName pn) { + public void addPackage(final PackageName pn) { packages.addElement(pn); } @@ -1530,7 +1530,7 @@ public class Javadoc extends Task { * @return the packages as a string */ public String getPackages() { - StringBuffer p = new StringBuffer(); + final StringBuffer p = new StringBuffer(); final int size = packages.size(); for (int i = 0; i < size; i++) { if (i > 0) { @@ -1546,7 +1546,7 @@ public class Javadoc extends Task { * Charset for cross-platform viewing of generated documentation. * @param src the name of the charset */ - public void setCharset(String src) { + public void setCharset(final String src) { this.addArgIfNotEmpty("-charset", src); } @@ -1557,7 +1557,7 @@ public class Javadoc extends Task { *

Default is false.

* @param b a boolean value */ - public void setFailonerror(boolean b) { + public void setFailonerror(final boolean b) { failOnError = b; } @@ -1569,7 +1569,7 @@ public class Javadoc extends Task { * @param b a boolean value * @since Ant 1.9.4 */ - public void setFailonwarning(boolean b) { + public void setFailonwarning(final boolean b) { failOnWarning = b; } @@ -1579,7 +1579,7 @@ public class Javadoc extends Task { * @param source a String value * @since Ant 1.5 */ - public void setSource(String source) { + public void setSource(final String source) { this.source = source; } @@ -1589,7 +1589,7 @@ public class Javadoc extends Task { * @param executable the command to invoke. * @since Ant 1.6.3 */ - public void setExecutable(String executable) { + public void setExecutable(final String executable) { this.executable = executable; } @@ -1601,7 +1601,7 @@ public class Javadoc extends Task { * @param packageSet a directory set * @since 1.5 */ - public void addPackageset(DirSet packageSet) { + public void addPackageset(final DirSet packageSet) { packageSets.addElement(packageSet); } @@ -1615,7 +1615,7 @@ public class Javadoc extends Task { * @param fs a file set * @since 1.5 */ - public void addFileset(FileSet fs) { + public void addFileset(final FileSet fs) { createSourceFiles().add(fs); } @@ -1636,7 +1636,7 @@ public class Javadoc extends Task { * @param b a String value * @since Ant 1.6 */ - public void setLinksource(boolean b) { + public void setLinksource(final boolean b) { this.linksource = b; } @@ -1646,7 +1646,7 @@ public class Javadoc extends Task { * @param b a String value * @since Ant 1.6 */ - public void setBreakiterator(boolean b) { + public void setBreakiterator(final boolean b) { this.breakiterator = b; } @@ -1656,7 +1656,7 @@ public class Javadoc extends Task { * @param noqualifier the parameter to the -noqualifier switch * @since Ant 1.6 */ - public void setNoqualifier(String noqualifier) { + public void setNoqualifier(final String noqualifier) { this.noqualifier = noqualifier; } @@ -1666,7 +1666,7 @@ public class Javadoc extends Task { * @param b a boolean value. * @since Ant 1.6.3 */ - public void setIncludeNoSourcePackages(boolean b) { + public void setIncludeNoSourcePackages(final boolean b) { this.includeNoSourcePackages = b; } @@ -1675,7 +1675,7 @@ public class Javadoc extends Task { * * @since Ant 1.8.0 */ - public void setDocFilesSubDirs(boolean b) { + public void setDocFilesSubDirs(final boolean b) { docFilesSubDirs = b; } @@ -1685,7 +1685,7 @@ public class Javadoc extends Task { * * @since Ant 1.8.0 */ - public void setExcludeDocFilesSubDir(String s) { + public void setExcludeDocFilesSubDir(final String s) { excludeDocFilesSubDir = s; } @@ -1693,7 +1693,7 @@ public class Javadoc extends Task { * Whether to post-process the generated javadocs in order to mitigate CVE-2013-1571. * @since Ant 1.9.2 */ - public void setPostProcessGeneratedJavadocs(boolean b) { + public void setPostProcessGeneratedJavadocs(final boolean b) { postProcessGeneratedJavadocs = b; } @@ -1705,8 +1705,8 @@ public class Javadoc extends Task { public void execute() throws BuildException { checkTaskName(); - Vector packagesToDoc = new Vector(); - Path sourceDirs = new Path(getProject()); + final Vector packagesToDoc = new Vector(); + final Path sourceDirs = new Path(getProject()); checkPackageAndSourcePath(); @@ -1718,6 +1718,7 @@ public class Javadoc extends Task { checkPackages(packagesToDoc, sourceDirs); @SuppressWarnings("unchecked") + final Vector sourceFilesToDoc = (Vector) sourceFiles.clone(); addSourceFiles(sourceFilesToDoc); @@ -1725,7 +1726,7 @@ public class Javadoc extends Task { log("Generating Javadoc", Project.MSG_INFO); - Commandline toExecute = (Commandline) cmd.clone(); + final Commandline toExecute = (Commandline) cmd.clone(); if (executable != null) { toExecute.setExecutable(executable); } else { @@ -1774,7 +1775,7 @@ public class Javadoc extends Task { if (useExternalFile) { srcListWriter.flush(); } - } catch (IOException e) { + } catch (final IOException e) { tmpList.delete(); throw new BuildException("Error creating temporary file", e, getLocation()); @@ -1789,9 +1790,9 @@ public class Javadoc extends Task { log("Javadoc execution", Project.MSG_INFO); - JavadocOutputStream out = new JavadocOutputStream(Project.MSG_INFO); - JavadocOutputStream err = new JavadocOutputStream(Project.MSG_WARN); - Execute exe = new Execute(new PumpStreamHandler(out, err)); + final JavadocOutputStream out = new JavadocOutputStream(Project.MSG_INFO); + final JavadocOutputStream err = new JavadocOutputStream(Project.MSG_WARN); + final Execute exe = new Execute(new PumpStreamHandler(out, err)); exe.setAntRun(getProject()); /* @@ -1803,7 +1804,7 @@ public class Javadoc extends Task { exe.setWorkingDirectory(null); try { exe.setCommandline(toExecute.getCommandline()); - int ret = exe.execute(); + final int ret = exe.execute(); if (ret != 0 && failOnError) { throw new BuildException("Javadoc returned " + ret, getLocation()); @@ -1813,7 +1814,7 @@ public class Javadoc extends Task { getLocation()); } postProcessGeneratedJavadocs(); - } catch (IOException e) { + } catch (final IOException e) { throw new BuildException("Javadoc failed: " + e, e, getLocation()); } finally { if (tmpList != null) { @@ -1826,7 +1827,7 @@ public class Javadoc extends Task { try { out.close(); err.close(); - } catch (IOException e) { + } catch (final IOException e) { // ignore } } @@ -1842,22 +1843,22 @@ public class Javadoc extends Task { private void checkPackageAndSourcePath() { if (packageList != null && sourcePath == null) { - String msg = "sourcePath attribute must be set when " + final String msg = "sourcePath attribute must be set when " + "specifying packagelist."; throw new BuildException(msg); } } - private void checkPackages(Vector packagesToDoc, Path sourceDirs) { + private void checkPackages(final Vector packagesToDoc, final Path sourceDirs) { if (packagesToDoc.size() != 0 && sourceDirs.size() == 0) { - String msg = "sourcePath attribute must be set when " + final String msg = "sourcePath attribute must be set when " + "specifying package names."; throw new BuildException(msg); } } private void checkPackagesToDoc( - Vector packagesToDoc, Vector sourceFilesToDoc) { + final Vector packagesToDoc, final Vector sourceFilesToDoc) { if (packageList == null && packagesToDoc.size() == 0 && sourceFilesToDoc.size() == 0) { throw new BuildException("No source files and no packages have " @@ -1865,14 +1866,14 @@ public class Javadoc extends Task { } } - private void doSourcePath(Commandline toExecute, Path sourceDirs) { + private void doSourcePath(final Commandline toExecute, final Path sourceDirs) { if (sourceDirs.size() > 0) { toExecute.createArgument().setValue("-sourcepath"); toExecute.createArgument().setPath(sourceDirs); } } - private void generalJavadocArguments(Commandline toExecute) { + private void generalJavadocArguments(final Commandline toExecute) { if (doctitle != null) { toExecute.createArgument().setValue("-doctitle"); toExecute.createArgument().setValue(expand(doctitle.getText())); @@ -1913,7 +1914,7 @@ public class Javadoc extends Task { } } - private void doDoclet(Commandline toExecute) { + private void doDoclet(final Commandline toExecute) { if (doclet != null) { if (doclet.getName() == null) { throw new BuildException("The doclet name must be " @@ -1922,16 +1923,16 @@ public class Javadoc extends Task { toExecute.createArgument().setValue("-doclet"); toExecute.createArgument().setValue(doclet.getName()); if (doclet.getPath() != null) { - Path docletPath + final Path docletPath = doclet.getPath().concatSystemClasspath("ignore"); if (docletPath.size() != 0) { toExecute.createArgument().setValue("-docletpath"); toExecute.createArgument().setPath(docletPath); } } - for (Enumeration e = doclet.getParams(); + for (final Enumeration e = doclet.getParams(); e.hasMoreElements();) { - DocletParam param = e.nextElement(); + final DocletParam param = e.nextElement(); if (param.getName() == null) { throw new BuildException("Doclet parameters must " + "have a name"); @@ -1947,21 +1948,21 @@ public class Javadoc extends Task { } } - private void writeExternalArgs(Commandline toExecute) { + private void writeExternalArgs(final Commandline toExecute) { // If using an external file, write the command line options to it File optionsTmpFile = null; BufferedWriter optionsListWriter = null; try { optionsTmpFile = FILE_UTILS.createTempFile( "javadocOptions", "", null, true, true); - String[] listOpt = toExecute.getArguments(); + final String[] listOpt = toExecute.getArguments(); toExecute.clearArgs(); toExecute.createArgument().setValue( "@" + optionsTmpFile.getAbsolutePath()); optionsListWriter = new BufferedWriter( new FileWriter(optionsTmpFile.getAbsolutePath(), true)); for (int i = 0; i < listOpt.length; i++) { - String string = listOpt[i]; + final String string = listOpt[i]; if (string.startsWith("-J-")) { toExecute.createArgument().setValue(string); } else { @@ -1975,7 +1976,7 @@ public class Javadoc extends Task { } } optionsListWriter.close(); - } catch (IOException ex) { + } catch (final IOException ex) { if (optionsTmpFile != null) { optionsTmpFile.delete(); } @@ -1987,7 +1988,7 @@ public class Javadoc extends Task { } } - private void doBootPath(Commandline toExecute) { + private void doBootPath(final Commandline toExecute) { Path bcp = new Path(getProject()); if (bootclasspath != null) { bcp.append(bootclasspath); @@ -1999,10 +2000,10 @@ public class Javadoc extends Task { } } - private void doLinks(Commandline toExecute) { + private void doLinks(final Commandline toExecute) { if (links.size() != 0) { - for (Enumeration e = links.elements(); e.hasMoreElements();) { - LinkArgument la = e.nextElement(); + for (final Enumeration e = links.elements(); e.hasMoreElements();) { + final LinkArgument la = e.nextElement(); if (la.getHref() == null || la.getHref().length() == 0) { log("No href was given for the link - skipping", @@ -2011,13 +2012,13 @@ public class Javadoc extends Task { } String link = null; if (la.shouldResolveLink()) { - File hrefAsFile = + final File hrefAsFile = getProject().resolveFile(la.getHref()); if (hrefAsFile.exists()) { try { link = FILE_UTILS.getFileURL(hrefAsFile) .toExternalForm(); - } catch (MalformedURLException ex) { + } catch (final MalformedURLException ex) { // should be impossible log("Warning: link location was invalid " + hrefAsFile, Project.MSG_WARN); @@ -2027,10 +2028,10 @@ public class Javadoc extends Task { if (link == null) { // is the href a valid URL try { - URL base = new URL("file://."); + final URL base = new URL("file://."); new URL(base, la.getHref()); link = la.getHref(); - } catch (MalformedURLException mue) { + } catch (final MalformedURLException mue) { // ok - just skip log("Link href \"" + la.getHref() + "\" is not a valid url - skipping link", @@ -2040,7 +2041,7 @@ public class Javadoc extends Task { } if (la.isLinkOffline()) { - File packageListLocation = la.getPackagelistLoc(); + final File packageListLocation = la.getPackagelistLoc(); URL packageListURL = la.getPackagelistURL(); if (packageListLocation == null && packageListURL == null) { @@ -2052,13 +2053,13 @@ public class Javadoc extends Task { + "offline"); } if (packageListLocation != null) { - File packageListFile = + final File packageListFile = new File(packageListLocation, "package-list"); if (packageListFile.exists()) { try { packageListURL = FILE_UTILS.getFileURL(packageListLocation); - } catch (MalformedURLException ex) { + } catch (final MalformedURLException ex) { log("Warning: Package list location was " + "invalid " + packageListLocation, Project.MSG_WARN); @@ -2082,7 +2083,7 @@ public class Javadoc extends Task { } } - private void doGroup(Commandline toExecute) { + private void doGroup(final Commandline toExecute) { // add the single group arguments // Javadoc 1.2 rules: // Multiple -group args allowed. @@ -2096,13 +2097,13 @@ public class Javadoc extends Task { // E.g., group="XSLT_Packages org.apache.xalan.xslt*, // XPath_Packages org.apache.xalan.xpath*" if (group != null) { - StringTokenizer tok = new StringTokenizer(group, ",", false); + final StringTokenizer tok = new StringTokenizer(group, ",", false); while (tok.hasMoreTokens()) { - String grp = tok.nextToken().trim(); - int space = grp.indexOf(" "); + final String grp = tok.nextToken().trim(); + final int space = grp.indexOf(" "); if (space > 0) { - String name = grp.substring(0, space); - String pkgList = grp.substring(space + 1); + final String name = grp.substring(0, space); + final String pkgList = grp.substring(space + 1); toExecute.createArgument().setValue("-group"); toExecute.createArgument().setValue(name); toExecute.createArgument().setValue(pkgList); @@ -2112,12 +2113,12 @@ public class Javadoc extends Task { } // add the group arguments - private void doGroups(Commandline toExecute) { + private void doGroups(final Commandline toExecute) { if (groups.size() != 0) { - for (Enumeration e = groups.elements(); e.hasMoreElements();) { - GroupArgument ga = e.nextElement(); - String title = ga.getTitle(); - String packages = ga.getPackages(); + for (final Enumeration e = groups.elements(); e.hasMoreElements();) { + final GroupArgument ga = e.nextElement(); + final String title = ga.getTitle(); + final String packages = ga.getPackages(); if (title == null || packages == null) { throw new BuildException("The title and packages must " + "be specified for group " @@ -2131,12 +2132,12 @@ public class Javadoc extends Task { } // Do java1.4 arguments - private void doJava14(Commandline toExecute) { - for (Enumeration e = tags.elements(); e.hasMoreElements();) { - Object element = e.nextElement(); + private void doJava14(final Commandline toExecute) { + for (final Enumeration e = tags.elements(); e.hasMoreElements();) { + final Object element = e.nextElement(); if (element instanceof TagArgument) { - TagArgument ta = (TagArgument) element; - File tagDir = ta.getDir(getProject()); + final TagArgument ta = (TagArgument) element; + final File tagDir = ta.getDir(getProject()); if (tagDir == null) { // The tag element is not used as a fileset, // but specifies the tag directly. @@ -2147,13 +2148,13 @@ public class Javadoc extends Task { // The tag element is used as a // fileset. Parse all the files and create // -tag arguments. - DirectoryScanner tagDefScanner = + final DirectoryScanner tagDefScanner = ta.getDirectoryScanner(getProject()); - String[] files = tagDefScanner.getIncludedFiles(); + final String[] files = tagDefScanner.getIncludedFiles(); for (int i = 0; i < files.length; i++) { - File tagDefFile = new File(tagDir, files[i]); + final File tagDefFile = new File(tagDir, files[i]); try { - BufferedReader in + final BufferedReader in = new BufferedReader( new FileReader(tagDefFile) ); @@ -2165,7 +2166,7 @@ public class Javadoc extends Task { .setValue(line); } in.close(); - } catch (IOException ioe) { + } catch (final IOException ioe) { throw new BuildException( "Couldn't read " + " tag file from " @@ -2174,12 +2175,12 @@ public class Javadoc extends Task { } } } else { - ExtensionInfo tagletInfo = (ExtensionInfo) element; + final ExtensionInfo tagletInfo = (ExtensionInfo) element; toExecute.createArgument().setValue("-taglet"); toExecute.createArgument().setValue(tagletInfo .getName()); if (tagletInfo.getPath() != null) { - Path tagletPath = tagletInfo.getPath() + final Path tagletPath = tagletInfo.getPath() .concatSystemClasspath("ignore"); if (tagletPath.size() != 0) { toExecute.createArgument() @@ -2190,7 +2191,7 @@ public class Javadoc extends Task { } } - String sourceArg = source != null ? source + final String sourceArg = source != null ? source : getProject().getProperty(MagicNames.BUILD_JAVAC_SOURCE); if (sourceArg != null) { toExecute.createArgument().setValue("-source"); @@ -2206,7 +2207,7 @@ public class Javadoc extends Task { } } - private void doDocFilesSubDirs(Commandline toExecute) { + private void doDocFilesSubDirs(final Commandline toExecute) { if (docFilesSubDirs) { toExecute.createArgument().setValue("-docfilessubdirs"); if (excludeDocFilesSubDir != null @@ -2218,14 +2219,14 @@ public class Javadoc extends Task { } private void doSourceAndPackageNames( - Commandline toExecute, - Vector packagesToDoc, - Vector sourceFilesToDoc, - boolean useExternalFile, - File tmpList, - BufferedWriter srcListWriter) + final Commandline toExecute, + final Vector packagesToDoc, + final Vector sourceFilesToDoc, + final boolean useExternalFile, + final File tmpList, + final BufferedWriter srcListWriter) throws IOException { - for (String packageName : packagesToDoc) { + for (final String packageName : packagesToDoc) { if (useExternalFile) { srcListWriter.write(packageName); srcListWriter.newLine(); @@ -2234,8 +2235,8 @@ public class Javadoc extends Task { } } - for (SourceFile sf : sourceFilesToDoc) { - String sourceFileName = sf.getFile().getAbsolutePath(); + for (final SourceFile sf : sourceFilesToDoc) { + final String sourceFileName = sf.getFile().getAbsolutePath(); if (useExternalFile) { // TODO what is the following doing? // should it run if !javadoc4 && executable != null? @@ -2285,12 +2286,12 @@ public class Javadoc extends Task { } private String quoteString(final String str, final char delim) { - StringBuffer buf = new StringBuffer(str.length() * 2); + final StringBuffer buf = new StringBuffer(str.length() * 2); buf.append(delim); final int len = str.length(); boolean lastCharWasCR = false; for (int i = 0; i < len; i++) { - char c = str.charAt(i); + final char c = str.charAt(i); if (c == delim) { // can't put the non-constant delim into a case buf.append('\\').append(c); lastCharWasCR = false; @@ -2333,8 +2334,8 @@ public class Javadoc extends Task { * * @since 1.7 */ - private void addSourceFiles(Vector sf) { - Iterator e = nestedSourceFiles.iterator(); + private void addSourceFiles(final Vector sf) { + final Iterator e = nestedSourceFiles.iterator(); while (e.hasNext()) { ResourceCollection rc = e.next(); if (!rc.isFilesystemOnly()) { @@ -2342,9 +2343,9 @@ public class Javadoc extends Task { + " supported by javadoc"); } if (rc instanceof FileSet) { - FileSet fs = (FileSet) rc; + final FileSet fs = (FileSet) rc; if (!fs.hasPatterns() && !fs.hasSelectors()) { - FileSet fs2 = (FileSet) fs.clone(); + final FileSet fs2 = (FileSet) fs.clone(); fs2.createInclude().setName("**/*.java"); if (includeNoSourcePackages) { fs2.createInclude().setName("**/package.html"); @@ -2352,7 +2353,7 @@ public class Javadoc extends Task { rc = fs2; } } - for (Resource r : rc) { + for (final Resource r : rc) { sf.addElement(new SourceFile(r.as(FileProvider.class).getFile())); } } @@ -2366,9 +2367,10 @@ public class Javadoc extends Task { * * @since 1.5 */ - private void parsePackages(Vector pn, Path sp) { - HashSet addedPackages = new HashSet(); + private void parsePackages(final Vector pn, final Path sp) { + final HashSet addedPackages = new HashSet(); @SuppressWarnings("unchecked") + final Vector dirSets = (Vector) packageSets.clone(); // for each sourcePath entry, add a directoryset with includes @@ -2376,12 +2378,12 @@ public class Javadoc extends Task { // elements and excludes taken from excludepackages attribute // and nested excludepackage elements if (sourcePath != null) { - PatternSet ps = new PatternSet(); + final PatternSet ps = new PatternSet(); ps.setProject(getProject()); if (packageNames.size() > 0) { - Enumeration e = packageNames.elements(); + final Enumeration e = packageNames.elements(); while (e.hasMoreElements()) { - PackageName p = e.nextElement(); + final PackageName p = e.nextElement(); String pkg = p.getName().replace('.', '/'); if (pkg.endsWith("*")) { pkg += "*"; @@ -2392,9 +2394,9 @@ public class Javadoc extends Task { ps.createInclude().setName("**"); } - Enumeration e = excludePackageNames.elements(); + final Enumeration e = excludePackageNames.elements(); while (e.hasMoreElements()) { - PackageName p = e.nextElement(); + final PackageName p = e.nextElement(); String pkg = p.getName().replace('.', '/'); if (pkg.endsWith("*")) { pkg += "*"; @@ -2403,11 +2405,11 @@ public class Javadoc extends Task { } - String[] pathElements = sourcePath.list(); + final String[] pathElements = sourcePath.list(); for (int i = 0; i < pathElements.length; i++) { - File dir = new File(pathElements[i]); + final File dir = new File(pathElements[i]); if (dir.isDirectory()) { - DirSet ds = new DirSet(); + final DirSet ds = new DirSet(); ds.setProject(getProject()); ds.setDefaultexcludes(useDefaultExcludes); ds.setDir(dir); @@ -2420,20 +2422,19 @@ public class Javadoc extends Task { } } - Enumeration e = dirSets.elements(); + final Enumeration e = dirSets.elements(); while (e.hasMoreElements()) { - DirSet ds = e.nextElement(); - File baseDir = ds.getDir(getProject()); + final DirSet ds = e.nextElement(); + final File baseDir = ds.getDir(getProject()); log("scanning " + baseDir + " for packages.", Project.MSG_DEBUG); - DirectoryScanner dsc = ds.getDirectoryScanner(getProject()); - String[] dirs = dsc.getIncludedDirectories(); + final DirectoryScanner dsc = ds.getDirectoryScanner(getProject()); + final String[] dirs = dsc.getIncludedDirectories(); boolean containsPackages = false; for (int i = 0; i < dirs.length; i++) { // are there any java files in this directory? - File pd = new File(baseDir, dirs[i]); - String[] files = pd.list(new FilenameFilter () { - @Override - public boolean accept(File dir1, String name) { + final File pd = new File(baseDir, dirs[i]); + final String[] files = pd.list(new FilenameFilter () { + public boolean accept(final File dir1, final String name) { return name.endsWith(".java") || (includeNoSourcePackages && name.equals("package.html")); @@ -2449,7 +2450,7 @@ public class Javadoc extends Task { Project.MSG_WARN); } else { containsPackages = true; - String packageName = + final String packageName = dirs[i].replace(File.separatorChar, '.'); if (!addedPackages.contains(packageName)) { addedPackages.add(packageName); @@ -2504,7 +2505,7 @@ public class Javadoc extends Task { ds.addDefaultExcludes(); ds.scan(); int patched = 0; - for (String f : ds.getIncludedFiles()) { + for (final String f : ds.getIncludedFiles()) { patched += postProcess(new File(destDir, f), fixData); } if (patched > 0) { @@ -2513,12 +2514,12 @@ public class Javadoc extends Task { } } - private int postProcess(File file, String fixData) throws IOException { - String enc = docEncoding != null ? docEncoding + private int postProcess(final File file, final String fixData) throws IOException { + final String enc = docEncoding != null ? docEncoding : FILE_UTILS.getDefaultEncoding(); // we load the whole file as one String (toc/index files are // generally small, because they only contain frameset declaration): - InputStream fin = new FileInputStream(file); + final InputStream fin = new FileInputStream(file); String fileContents; try { fileContents = @@ -2532,11 +2533,11 @@ public class Javadoc extends Task { // patched with "validURL(url)": if (fileContents.indexOf("function validURL(url) {") < 0) { // we need to patch the file! - String patchedFileContents = patchContent(fileContents, fixData); + final String patchedFileContents = patchContent(fileContents, fixData); if (!patchedFileContents.equals(fileContents)) { - FileOutputStream fos = new FileOutputStream(file); + final FileOutputStream fos = new FileOutputStream(file); try { - OutputStreamWriter w = new OutputStreamWriter(fos, enc); + final OutputStreamWriter w = new OutputStreamWriter(fos, enc); w.write(patchedFileContents); w.close(); return 1; @@ -2548,14 +2549,14 @@ public class Javadoc extends Task { return 0; } - private String fixLineFeeds(String orig) { + private String fixLineFeeds(final String orig) { return orig.replace("\r\n", "\n") .replace("\n", StringUtils.LINE_SEP); } - private String patchContent(String fileContents, String fixData) { + private String patchContent(final String fileContents, final String fixData) { // using regexes here looks like overkill - int start = fileContents.indexOf(LOAD_FRAME); + final int start = fileContents.indexOf(LOAD_FRAME); if (start >= 0) { return fileContents.substring(0, start) + fixData + fileContents.substring(start + LOAD_FRAME_LEN); @@ -2564,7 +2565,7 @@ public class Javadoc extends Task { } private class JavadocOutputStream extends LogOutputStream { - JavadocOutputStream(int level) { + JavadocOutputStream(final int level) { super(Javadoc.this, level); } @@ -2576,7 +2577,7 @@ public class Javadoc extends Task { private String queuedLine = null; private boolean sawWarnings = false; @Override - protected void processLine(String line, int messageLevel) { + protected void processLine(final String line, final int messageLevel) { if (line.contains("warning")) { sawWarnings = true; } @@ -2617,7 +2618,7 @@ public class Javadoc extends Task { * @param content the string to expand * @return the converted string */ - protected String expand(String content) { + protected String expand(final String content) { return getProject().replaceProperties(content); } diff --git a/src/main/org/apache/tools/ant/taskdefs/Tar.java b/src/main/org/apache/tools/ant/taskdefs/Tar.java index c5259ba99..268e660ab 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Tar.java +++ b/src/main/org/apache/tools/ant/taskdefs/Tar.java @@ -24,10 +24,13 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.util.Enumeration; +import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.Vector; import java.util.zip.GZIPOutputStream; @@ -68,31 +71,36 @@ public class Tar extends MatchingTask { * Tar.WARN is deprecated and is replaced with * Tar.TarLongFileMode.WARN */ - public static final String WARN = "warn"; + @Deprecated + public static final String WARN = "warn"; /** * @deprecated since 1.5.x. * Tar.FAIL is deprecated and is replaced with * Tar.TarLongFileMode.FAIL */ - public static final String FAIL = "fail"; + @Deprecated + public static final String FAIL = "fail"; /** * @deprecated since 1.5.x. * Tar.TRUNCATE is deprecated and is replaced with * Tar.TarLongFileMode.TRUNCATE */ - public static final String TRUNCATE = "truncate"; + @Deprecated + public static final String TRUNCATE = "truncate"; /** * @deprecated since 1.5.x. * Tar.GNU is deprecated and is replaced with * Tar.TarLongFileMode.GNU */ - public static final String GNU = "gnu"; + @Deprecated + public static final String GNU = "gnu"; /** * @deprecated since 1.5.x. * Tar.OMIT is deprecated and is replaced with * Tar.TarLongFileMode.OMIT */ - public static final String OMIT = "omit"; + @Deprecated + public static final String OMIT = "omit"; // CheckStyle:VisibilityModifier OFF - bc File tarFile; @@ -101,12 +109,10 @@ public class Tar extends MatchingTask { private TarLongFileMode longFileMode = new TarLongFileMode(); // need to keep the package private version for backwards compatibility - Vector filesets = new Vector(); + Vector filesets = new Vector(); // we must keep two lists since other classes may modify the // filesets Vector (it is package private) without us noticing - private Vector resourceCollections = new Vector(); - - Vector fileSetFiles = new Vector(); + private final Vector resourceCollections = new Vector(); // CheckStyle:VisibilityModifier ON @@ -122,7 +128,7 @@ public class Tar extends MatchingTask { * @return the tar fileset to be used as the nested element. */ public TarFileSet createTarFileSet() { - TarFileSet fs = new TarFileSet(); + final TarFileSet fs = new TarFileSet(); fs.setProject(getProject()); filesets.addElement(fs); return fs; @@ -133,7 +139,7 @@ public class Tar extends MatchingTask { * @param res a resource collection to archive. * @since Ant 1.7 */ - public void add(ResourceCollection res) { + public void add(final ResourceCollection res) { resourceCollections.add(res); } @@ -143,7 +149,8 @@ public class Tar extends MatchingTask { * @deprecated since 1.5.x. * For consistency with other tasks, please use setDestFile(). */ - public void setTarfile(File tarFile) { + @Deprecated + public void setTarfile(final File tarFile) { this.tarFile = tarFile; } @@ -152,7 +159,7 @@ public class Tar extends MatchingTask { * @since Ant 1.5 * @param destFile The output of the tar */ - public void setDestFile(File destFile) { + public void setDestFile(final File destFile) { this.tarFile = destFile; } @@ -160,7 +167,7 @@ public class Tar extends MatchingTask { * This is the base directory to look in for things to tar. * @param baseDir the base directory. */ - public void setBasedir(File baseDir) { + public void setBasedir(final File baseDir) { this.baseDir = baseDir; } @@ -183,7 +190,8 @@ public class Tar extends MatchingTask { * mechanism do the work and also to encapsulate operations on * the mode in its own class. */ - public void setLongfile(String mode) { + @Deprecated + public void setLongfile(final String mode) { log("DEPRECATED - The setLongfile(String) method has been deprecated." + " Use setLongfile(Tar.TarLongFileMode) instead."); this.longFileMode = new TarLongFileMode(); @@ -205,7 +213,7 @@ public class Tar extends MatchingTask { * * @param mode the mode to handle long file names. */ - public void setLongfile(TarLongFileMode mode) { + public void setLongfile(final TarLongFileMode mode) { this.longFileMode = mode; } @@ -219,7 +227,7 @@ public class Tar extends MatchingTask { * * @param mode the compression method. */ - public void setCompression(TarCompressionMethod mode) { + public void setCompression(final TarCompressionMethod mode) { this.compression = mode; } @@ -227,7 +235,8 @@ public class Tar extends MatchingTask { * do the business * @throws BuildException on error */ - public void execute() throws BuildException { + @Override + public void execute() throws BuildException { if (tarFile == null) { throw new BuildException("tarfile attribute must be set!", getLocation()); @@ -243,7 +252,8 @@ public class Tar extends MatchingTask { getLocation()); } - Vector savedFileSets = (Vector) filesets.clone(); + @SuppressWarnings("unchecked") + final Vector savedFileSets = (Vector) filesets.clone(); try { if (baseDir != null) { if (!baseDir.exists()) { @@ -252,7 +262,7 @@ public class Tar extends MatchingTask { } // add the main fileset to the list of filesets to process. - TarFileSet mainFileSet = new TarFileSet(fileset); + final TarFileSet mainFileSet = new TarFileSet(fileset); mainFileSet.setDir(baseDir); filesets.addElement(mainFileSet); } @@ -267,12 +277,11 @@ public class Tar extends MatchingTask { // check if tar is out of date with respect to each // fileset boolean upToDate = true; - for (Enumeration e = filesets.elements(); e.hasMoreElements();) { - upToDate &= check((TarFileSet) e.nextElement()); + for(final TarFileSet tfs : filesets) { + upToDate &= check(tfs); } - for (Enumeration e = resourceCollections.elements(); - e.hasMoreElements();) { - upToDate &= check((ResourceCollection) e.nextElement()); + for(final ResourceCollection rcol : resourceCollections) { + upToDate &= check(rcol); } if (upToDate) { @@ -281,7 +290,7 @@ public class Tar extends MatchingTask { return; } - File parent = tarFile.getParentFile(); + final File parent = tarFile.getParentFile(); if (parent != null && !parent.isDirectory() && !(parent.mkdirs() || parent.isDirectory())) { throw new BuildException("Failed to create missing parent" @@ -310,16 +319,14 @@ public class Tar extends MatchingTask { } longWarningGiven = false; - for (Enumeration e = filesets.elements(); - e.hasMoreElements();) { - tar((TarFileSet) e.nextElement(), tOut); + for(final TarFileSet tfs : filesets) { + tar(tfs, tOut); } - for (Enumeration e = resourceCollections.elements(); - e.hasMoreElements();) { - tar((ResourceCollection) e.nextElement(), tOut); + for(final ResourceCollection rcol : resourceCollections) { + tar(rcol, tOut); } - } catch (IOException ioe) { - String msg = "Problem creating TAR: " + ioe.getMessage(); + } catch (final IOException ioe) { + final String msg = "Problem creating TAR: " + ioe.getMessage(); throw new BuildException(msg, ioe, getLocation()); } finally { FileUtils.close(tOut); @@ -337,8 +344,8 @@ public class Tar extends MatchingTask { * @param tarFileSet the fileset that the file came from. * @throws IOException on error */ - protected void tarFile(File file, TarOutputStream tOut, String vPath, - TarFileSet tarFileSet) + protected void tarFile(final File file, final TarOutputStream tOut, final String vPath, + final TarFileSet tarFileSet) throws IOException { if (file.equals(tarFile)) { // If the archive is built for the first time and it is @@ -364,8 +371,8 @@ public class Tar extends MatchingTask { * @throws IOException on error * @since Ant 1.7 */ - protected void tarResource(Resource r, TarOutputStream tOut, String vPath, - TarFileSet tarFileSet) + protected void tarResource(final Resource r, final TarOutputStream tOut, String vPath, + final TarFileSet tarFileSet) throws IOException { if (!r.isExists()) { @@ -375,7 +382,7 @@ public class Tar extends MatchingTask { boolean preserveLeadingSlashes = false; if (tarFileSet != null) { - String fullpath = tarFileSet.getFullpath(this.getProject()); + final String fullpath = tarFileSet.getFullpath(this.getProject()); if (fullpath.length() > 0) { vPath = fullpath; } else { @@ -395,7 +402,7 @@ public class Tar extends MatchingTask { preserveLeadingSlashes = tarFileSet.getPreserveLeadingSlashes(); if (vPath.startsWith("/") && !preserveLeadingSlashes) { - int l = vPath.length(); + final int l = vPath.length(); if (l <= 1) { // we would end up adding "" to the archive return; @@ -429,14 +436,14 @@ public class Tar extends MatchingTask { } } - TarEntry te = new TarEntry(vPath, preserveLeadingSlashes); + final TarEntry te = new TarEntry(vPath, preserveLeadingSlashes); te.setModTime(r.getLastModified()); // preserve permissions if (r instanceof ArchiveResource) { - ArchiveResource ar = (ArchiveResource) r; + final ArchiveResource ar = (ArchiveResource) r; te.setMode(ar.getMode()); if (r instanceof TarResource) { - TarResource tr = (TarResource) r; + final TarResource tr = (TarResource) r; te.setUserName(tr.getUserName()); te.setUserId(tr.getUid()); te.setGroupName(tr.getGroup()); @@ -483,7 +490,7 @@ public class Tar extends MatchingTask { if (!r.isDirectory()) { in = r.getInputStream(); - byte[] buffer = new byte[BUFFER_SIZE]; + final byte[] buffer = new byte[BUFFER_SIZE]; int count = 0; do { tOut.write(buffer, 0, count); @@ -504,7 +511,8 @@ public class Tar extends MatchingTask { * @deprecated since 1.5.x. * use the two-arg version instead. */ - protected boolean archiveIsUpToDate(String[] files) { + @Deprecated + protected boolean archiveIsUpToDate(final String[] files) { return archiveIsUpToDate(files, baseDir); } @@ -515,9 +523,9 @@ public class Tar extends MatchingTask { * @return true if the archive is up to date. * @since Ant 1.5.2 */ - protected boolean archiveIsUpToDate(String[] files, File dir) { - SourceFileScanner sfs = new SourceFileScanner(this); - MergingMapper mm = new MergingMapper(); + protected boolean archiveIsUpToDate(final String[] files, final File dir) { + final SourceFileScanner sfs = new SourceFileScanner(this); + final MergingMapper mm = new MergingMapper(); mm.setTo(tarFile.getAbsolutePath()); return sfs.restrict(files, dir, null, mm).length == 0; } @@ -528,7 +536,7 @@ public class Tar extends MatchingTask { * @return true if the archive is up to date. * @since Ant 1.7 */ - protected boolean archiveIsUpToDate(Resource r) { + protected boolean archiveIsUpToDate(final Resource r) { return SelectorUtils.isOutOfDate(new FileResource(tarFile), r, FileUtils.getFileUtils() .getFileTimestampGranularity()); @@ -563,27 +571,27 @@ public class Tar extends MatchingTask { * @return whether the archive is up-to-date * @since Ant 1.7 */ - protected boolean check(ResourceCollection rc) { + protected boolean check(final ResourceCollection rc) { boolean upToDate = true; if (isFileFileSet(rc)) { - FileSet fs = (FileSet) rc; + final FileSet fs = (FileSet) rc; upToDate = check(fs.getDir(getProject()), getFileNames(fs)); } else if (!rc.isFilesystemOnly() && !supportsNonFileResources()) { throw new BuildException("only filesystem resources are supported"); } else if (rc.isFilesystemOnly()) { - HashSet basedirs = new HashSet(); - HashMap basedirToFilesMap = new HashMap(); - for (Resource res : rc) { - FileResource r = ResourceUtils + final Set basedirs = new HashSet(); + final Map> basedirToFilesMap = new HashMap>(); + for (final Resource res : rc) { + final FileResource r = ResourceUtils .asFileResource(res.as(FileProvider.class)); File base = r.getBaseDir(); if (base == null) { base = Copy.NULL_FILE_PLACEHOLDER; } basedirs.add(base); - Vector files = (Vector) basedirToFilesMap.get(base); + List files = basedirToFilesMap.get(base); if (files == null) { - files = new Vector(); + files = new Vector(); basedirToFilesMap.put(base, files); } if (base == Copy.NULL_FILE_PLACEHOLDER) { @@ -592,19 +600,15 @@ public class Tar extends MatchingTask { files.add(r.getName()); } } - Iterator iter = basedirs.iterator(); - while (iter.hasNext()) { - File base = (File) iter.next(); - Vector f = (Vector) basedirToFilesMap.get(base); - String[] files = (String[]) f.toArray(new String[f.size()]); - upToDate &= - check(base == Copy.NULL_FILE_PLACEHOLDER ? null : base, - files); + for(final File base : basedirs) { + final File tmpBase = base == Copy.NULL_FILE_PLACEHOLDER ? null : base; + final List files = basedirToFilesMap.get(base); + check(tmpBase, files); } } else { // non-file resources - Iterator iter = rc.iterator(); + final Iterator iter = rc.iterator(); while (upToDate && iter.hasNext()) { - Resource r = iter.next(); + final Resource r = iter.next(); upToDate = archiveIsUpToDate(r); } } @@ -620,7 +624,7 @@ public class Tar extends MatchingTask { * @return whether the archive is up-to-date * @since Ant 1.7 */ - protected boolean check(File basedir, String[] files) { + protected boolean check(final File basedir, final String[] files) { boolean upToDate = true; if (!archiveIsUpToDate(files, basedir)) { upToDate = false; @@ -635,6 +639,20 @@ public class Tar extends MatchingTask { return upToDate; } + /** + *

Checks whether the archive is out-of-date with respect to the + * given files, ensures that the archive won't contain itself.

+ * + * @param basedir base directory for file names + * @param files array of relative file names + * @return whether the archive is up-to-date + * @see #check(File, String[]) + * @since Ant 1.9.5 + */ + protected boolean check(final File basedir, final Collection files) { + return check(basedir, files.toArray(new String[files.size()])); + } + /** * Adds the resources contained in this collection to the archive. * @@ -646,7 +664,7 @@ public class Tar extends MatchingTask { * @throws IOException on error. * @since Ant 1.7 */ - protected void tar(ResourceCollection rc, TarOutputStream tOut) + protected void tar(final ResourceCollection rc, final TarOutputStream tOut) throws IOException { ArchiveFileSet afs = null; if (rc instanceof ArchiveFileSet) { @@ -659,23 +677,23 @@ public class Tar extends MatchingTask { + "filesets that specify a " + "single file."); } - TarFileSet tfs = asTarFileSet(afs); + final TarFileSet tfs = asTarFileSet(afs); if (isFileFileSet(rc)) { - FileSet fs = (FileSet) rc; - String[] files = getFileNames(fs); + final FileSet fs = (FileSet) rc; + final String[] files = getFileNames(fs); for (int i = 0; i < files.length; i++) { - File f = new File(fs.getDir(getProject()), files[i]); - String name = files[i].replace(File.separatorChar, '/'); + final File f = new File(fs.getDir(getProject()), files[i]); + final String name = files[i].replace(File.separatorChar, '/'); tarFile(f, tOut, name, tfs); } } else if (rc.isFilesystemOnly()) { - for (Resource r : rc) { - File f = r.as(FileProvider.class).getFile(); + for (final Resource r : rc) { + final File f = r.as(FileProvider.class).getFile(); tarFile(f, tOut, f.getName(), tfs); } } else { // non-file resources - for (Resource r : rc) { + for (final Resource r : rc) { tarResource(r, tOut, r.getName(), tfs); } } @@ -688,7 +706,7 @@ public class Tar extends MatchingTask { * @return true if the collection is a fileset. * @since Ant 1.7 */ - protected static boolean isFileFileSet(ResourceCollection rc) { + protected static boolean isFileFileSet(final ResourceCollection rc) { return rc instanceof FileSet && rc.isFilesystemOnly(); } @@ -699,11 +717,11 @@ public class Tar extends MatchingTask { * @return a list of the filenames. * @since Ant 1.7 */ - protected static String[] getFileNames(FileSet fs) { - DirectoryScanner ds = fs.getDirectoryScanner(fs.getProject()); - String[] directories = ds.getIncludedDirectories(); - String[] filesPerSe = ds.getIncludedFiles(); - String[] files = new String [directories.length + filesPerSe.length]; + protected static String[] getFileNames(final FileSet fs) { + final DirectoryScanner ds = fs.getDirectoryScanner(fs.getProject()); + final String[] directories = ds.getIncludedDirectories(); + final String[] filesPerSe = ds.getIncludedFiles(); + final String[] files = new String [directories.length + filesPerSe.length]; System.arraycopy(directories, 0, files, 0, directories.length); System.arraycopy(filesPerSe, 0, files, directories.length, filesPerSe.length); @@ -719,7 +737,7 @@ public class Tar extends MatchingTask { * @return a new TarFileSet. * @since Ant 1.7 */ - protected TarFileSet asTarFileSet(ArchiveFileSet archiveFileSet) { + protected TarFileSet asTarFileSet(final ArchiveFileSet archiveFileSet) { TarFileSet tfs = null; if (archiveFileSet != null && archiveFileSet instanceof TarFileSet) { tfs = (TarFileSet) archiveFileSet; @@ -740,7 +758,7 @@ public class Tar extends MatchingTask { if (archiveFileSet instanceof org.apache.tools.ant.types.TarFileSet) { - org.apache.tools.ant.types.TarFileSet t = + final org.apache.tools.ant.types.TarFileSet t = (org.apache.tools.ant.types.TarFileSet) archiveFileSet; if (t.hasUserNameBeenSet()) { tfs.setUserName(t.getUserName()); @@ -776,7 +794,7 @@ public class Tar extends MatchingTask { * * @param fileset a FileSet value */ - public TarFileSet(FileSet fileset) { + public TarFileSet(final FileSet fileset) { super(fileset); } @@ -794,7 +812,7 @@ public class Tar extends MatchingTask { * @return a list of file and directory names, relative to * the baseDir for the project. */ - public String[] getFiles(Project p) { + public String[] getFiles(final Project p) { if (files == null) { files = getFileNames(this); } @@ -808,7 +826,7 @@ public class Tar extends MatchingTask { * optional, default=0644 * @param octalString a 3 digit octal string. */ - public void setMode(String octalString) { + public void setMode(final String octalString) { setFileMode(octalString); } @@ -825,7 +843,7 @@ public class Tar extends MatchingTask { * Optional, default is false. * @param b the leading slashes flag. */ - public void setPreserveLeadingSlashes(boolean b) { + public void setPreserveLeadingSlashes(final boolean b) { this.preserveLeadingSlashes = b; } @@ -865,7 +883,8 @@ public class Tar extends MatchingTask { /** * @return the possible values for this enumerated type. */ - public String[] getValues() { + @Override + public String[] getValues() { return validModes; } @@ -945,7 +964,8 @@ public class Tar extends MatchingTask { * Get valid enumeration values. * @return valid enumeration values */ - public String[] getValues() { + @Override + public String[] getValues() { return new String[] {NONE, GZIP, BZIP2 }; } diff --git a/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java b/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java index 91ea06264..32ef10aee 100644 --- a/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java +++ b/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java @@ -90,7 +90,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { private String fileDirParameter = null; /** additional parameters to be passed to the stylesheets */ - private List params = new ArrayList(); + private final List params = new ArrayList(); /** Input XML document to be used */ private File inFile = null; @@ -116,10 +116,10 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { private boolean force = false; /** XSL output properties to be used */ - private Vector outputProperties = new Vector(); + private final Vector outputProperties = new Vector(); /** for resolving entities such as dtds */ - private XMLCatalog xmlCatalog = new XMLCatalog(); + private final XMLCatalog xmlCatalog = new XMLCatalog(); /** Utilities used for file operations */ private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); @@ -167,7 +167,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { * * @since Ant 1.7 */ - private Union resources = new Union(); + private final Union resources = new Union(); /** * Whether to use the implicit fileset. @@ -229,7 +229,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { * * @since Ant 1.8.0 */ - private CommandlineJava.SysProperties sysProperties = + private final CommandlineJava.SysProperties sysProperties = new CommandlineJava.SysProperties(); /** @@ -252,7 +252,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { * @param b true if files in included directories are processed. * @since Ant 1.5 */ - public void setScanIncludedDirectories(boolean b) { + public void setScanIncludedDirectories(final boolean b) { performDirectoryScan = b; } @@ -264,7 +264,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { * @param b a boolean value * @since Ant 1.5.2 */ - public void setReloadStylesheet(boolean b) { + public void setReloadStylesheet(final boolean b) { reuseLoadedStylesheet = !b; } @@ -274,7 +274,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { * @exception BuildException if more than one mapper is defined * @since Ant 1.6.2 */ - public void addMapper(Mapper mapper) { + public void addMapper(final Mapper mapper) { if (mapperElement != null) { handleError("Cannot define more than one mapper"); } else { @@ -289,7 +289,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { * @param rc the collection of resources to style * @since Ant 1.7 */ - public void add(ResourceCollection rc) { + public void add(final ResourceCollection rc) { resources.add(rc); } @@ -298,7 +298,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { * @param rc the configured Resources object represented as <style>. * @since Ant 1.7 */ - public void addConfiguredStyle(Resources rc) { + public void addConfiguredStyle(final Resources rc) { if (rc.size() != 1) { handleError("The style element must be specified with exactly one" + " nested resource."); @@ -312,7 +312,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { * @param xslResource Resource to set as the stylesheet. * @since Ant 1.7 */ - public void setXslResource(Resource xslResource) { + public void setXslResource(final Resource xslResource) { this.xslResource = xslResource; } @@ -322,8 +322,8 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { * @exception BuildException if more than one mapper is defined * @since Ant 1.7.0 */ - public void add(FileNameMapper fileNameMapper) throws BuildException { - Mapper mapper = new Mapper(getProject()); + public void add(final FileNameMapper fileNameMapper) throws BuildException { + final Mapper mapper = new Mapper(getProject()); mapper.add(fileNameMapper); addMapper(mapper); } @@ -340,13 +340,13 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { log("Warning: the task name