@@ -119,7 +119,6 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* @return <code>true</code> if there are more elements in the | * @return <code>true</code> if there are more elements in the | ||||
* enumeration; <code>false</code> otherwise. | * enumeration; <code>false</code> otherwise. | ||||
*/ | */ | ||||
@Override | |||||
public boolean hasMoreElements() { | public boolean hasMoreElements() { | ||||
return (this.nextResource != null); | return (this.nextResource != null); | ||||
} | } | ||||
@@ -129,7 +128,6 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* | * | ||||
* @return the next resource in the enumeration | * @return the next resource in the enumeration | ||||
*/ | */ | ||||
@Override | |||||
public URL nextElement() { | public URL nextElement() { | ||||
final URL ret = this.nextResource; | final URL ret = this.nextResource; | ||||
if (ret == null) { | if (ret == null) { | ||||
@@ -1445,7 +1443,6 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* | * | ||||
* @param event the buildStarted event | * @param event the buildStarted event | ||||
*/ | */ | ||||
@Override | |||||
public void buildStarted(final BuildEvent event) { | public void buildStarted(final BuildEvent event) { | ||||
// Not significant for the class loader. | // Not significant for the class loader. | ||||
} | } | ||||
@@ -1456,7 +1453,6 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* | * | ||||
* @param event the buildFinished event | * @param event the buildFinished event | ||||
*/ | */ | ||||
@Override | |||||
public void buildFinished(final BuildEvent event) { | public void buildFinished(final BuildEvent event) { | ||||
cleanup(); | cleanup(); | ||||
} | } | ||||
@@ -1470,7 +1466,6 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* | * | ||||
* @since Ant 1.6.2 | * @since Ant 1.6.2 | ||||
*/ | */ | ||||
@Override | |||||
public void subBuildFinished(final BuildEvent event) { | public void subBuildFinished(final BuildEvent event) { | ||||
if (event.getProject() == project) { | if (event.getProject() == project) { | ||||
cleanup(); | cleanup(); | ||||
@@ -1484,7 +1479,6 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* | * | ||||
* @since Ant 1.6.2 | * @since Ant 1.6.2 | ||||
*/ | */ | ||||
@Override | |||||
public void subBuildStarted(final BuildEvent event) { | public void subBuildStarted(final BuildEvent event) { | ||||
// Not significant for the class loader. | // Not significant for the class loader. | ||||
} | } | ||||
@@ -1494,7 +1488,6 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* | * | ||||
* @param event the targetStarted event | * @param event the targetStarted event | ||||
*/ | */ | ||||
@Override | |||||
public void targetStarted(final BuildEvent event) { | public void targetStarted(final BuildEvent event) { | ||||
// Not significant for the class loader. | // Not significant for the class loader. | ||||
} | } | ||||
@@ -1504,7 +1497,6 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* | * | ||||
* @param event the targetFinished event | * @param event the targetFinished event | ||||
*/ | */ | ||||
@Override | |||||
public void targetFinished(final BuildEvent event) { | public void targetFinished(final BuildEvent event) { | ||||
// Not significant for the class loader. | // Not significant for the class loader. | ||||
} | } | ||||
@@ -1514,7 +1506,6 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* | * | ||||
* @param event the taskStarted event | * @param event the taskStarted event | ||||
*/ | */ | ||||
@Override | |||||
public void taskStarted(final BuildEvent event) { | public void taskStarted(final BuildEvent event) { | ||||
// Not significant for the class loader. | // Not significant for the class loader. | ||||
} | } | ||||
@@ -1524,7 +1515,6 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* | * | ||||
* @param event the taskFinished event | * @param event the taskFinished event | ||||
*/ | */ | ||||
@Override | |||||
public void taskFinished(final BuildEvent event) { | public void taskFinished(final BuildEvent event) { | ||||
// Not significant for the class loader. | // Not significant for the class loader. | ||||
} | } | ||||
@@ -1534,7 +1524,6 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
* | * | ||||
* @param event the messageLogged event | * @param event the messageLogged event | ||||
*/ | */ | ||||
@Override | |||||
public void messageLogged(final BuildEvent event) { | public void messageLogged(final BuildEvent event) { | ||||
// Not significant for the class loader. | // Not significant for the class loader. | ||||
} | } | ||||
@@ -310,7 +310,7 @@ public class DirectoryScanner | |||||
* | * | ||||
* @since Ant 1.6 | * @since Ant 1.6 | ||||
*/ | */ | ||||
private Set<String> scannedDirs = new HashSet<String>(); | |||||
private final Set<String> scannedDirs = new HashSet<String>(); | |||||
/** | /** | ||||
* Map of all include patterns that are full file names and don't | * 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 | * @since Ant 1.8.0 | ||||
*/ | */ | ||||
private Map<String, TokenizedPath> includeNonPatterns = new HashMap<String, TokenizedPath>(); | |||||
private final Map<String, TokenizedPath> includeNonPatterns = new HashMap<String, TokenizedPath>(); | |||||
/** | /** | ||||
* Map of all exclude patterns that are full file names and don't | * 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 | * @since Ant 1.8.0 | ||||
*/ | */ | ||||
private Map<String, TokenizedPath> excludeNonPatterns = new HashMap<String, TokenizedPath>(); | |||||
private final Map<String, TokenizedPath> excludeNonPatterns = new HashMap<String, TokenizedPath>(); | |||||
/** | /** | ||||
* Array of all include patterns that contain wildcards. | * Array of all include patterns that contain wildcards. | ||||
@@ -384,7 +384,7 @@ public class DirectoryScanner | |||||
* | * | ||||
* @since Ant 1.6.3 | * @since Ant 1.6.3 | ||||
*/ | */ | ||||
private Object scanLock = new Object(); | |||||
private final Object scanLock = new Object(); | |||||
/** | /** | ||||
* Slow scanning flag. | * Slow scanning flag. | ||||
@@ -398,7 +398,7 @@ public class DirectoryScanner | |||||
* | * | ||||
* @since Ant 1.6.3 | * @since Ant 1.6.3 | ||||
*/ | */ | ||||
private Object slowScanLock = new Object(); | |||||
private final Object slowScanLock = new Object(); | |||||
/** | /** | ||||
* Exception thrown during scan. | * Exception thrown during scan. | ||||
@@ -423,7 +423,7 @@ public class DirectoryScanner | |||||
* | * | ||||
* @since Ant 1.8.0 | * @since Ant 1.8.0 | ||||
*/ | */ | ||||
private Set<String> notFollowedSymlinks = new HashSet<String>(); | |||||
private final Set<String> notFollowedSymlinks = new HashSet<String>(); | |||||
/** | /** | ||||
* Sole constructor. | * Sole constructor. | ||||
@@ -447,7 +447,7 @@ public class DirectoryScanner | |||||
* @return whether or not a given path matches the start of a given | * @return whether or not a given path matches the start of a given | ||||
* pattern up to the first "**". | * 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); | 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 | * @return whether or not a given path matches the start of a given | ||||
* pattern up to the first "**". | * 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); | return SelectorUtils.matchPatternStart(pattern, str, isCaseSensitive); | ||||
} | } | ||||
@@ -485,7 +485,7 @@ public class DirectoryScanner | |||||
* @return <code>true</code> if the pattern matches against the string, | * @return <code>true</code> if the pattern matches against the string, | ||||
* or <code>false</code> otherwise. | * or <code>false</code> otherwise. | ||||
*/ | */ | ||||
protected static boolean matchPath(String pattern, String str) { | |||||
protected static boolean matchPath(final String pattern, final String str) { | |||||
return SelectorUtils.matchPath(pattern, str); | return SelectorUtils.matchPath(pattern, str); | ||||
} | } | ||||
@@ -502,8 +502,8 @@ public class DirectoryScanner | |||||
* @return <code>true</code> if the pattern matches against the string, | * @return <code>true</code> if the pattern matches against the string, | ||||
* or <code>false</code> otherwise. | * or <code>false</code> otherwise. | ||||
*/ | */ | ||||
protected static boolean matchPath(String pattern, String str, | |||||
boolean isCaseSensitive) { | |||||
protected static boolean matchPath(final String pattern, final String str, | |||||
final boolean isCaseSensitive) { | |||||
return SelectorUtils.matchPath(pattern, str, isCaseSensitive); | return SelectorUtils.matchPath(pattern, str, isCaseSensitive); | ||||
} | } | ||||
@@ -521,7 +521,7 @@ public class DirectoryScanner | |||||
* @return <code>true</code> if the string matches against the pattern, | * @return <code>true</code> if the string matches against the pattern, | ||||
* or <code>false</code> otherwise. | * or <code>false</code> otherwise. | ||||
*/ | */ | ||||
public static boolean match(String pattern, String str) { | |||||
public static boolean match(final String pattern, final String str) { | |||||
return SelectorUtils.match(pattern, str); | return SelectorUtils.match(pattern, str); | ||||
} | } | ||||
@@ -542,8 +542,8 @@ public class DirectoryScanner | |||||
* @return <code>true</code> if the string matches against the pattern, | * @return <code>true</code> if the string matches against the pattern, | ||||
* or <code>false</code> otherwise. | * or <code>false</code> otherwise. | ||||
*/ | */ | ||||
protected static boolean match(String pattern, String str, | |||||
boolean isCaseSensitive) { | |||||
protected static boolean match(final String pattern, final String str, | |||||
final boolean isCaseSensitive) { | |||||
return SelectorUtils.match(pattern, str, isCaseSensitive); | return SelectorUtils.match(pattern, str, isCaseSensitive); | ||||
} | } | ||||
@@ -574,7 +574,7 @@ public class DirectoryScanner | |||||
* | * | ||||
* @since Ant 1.6 | * @since Ant 1.6 | ||||
*/ | */ | ||||
public static boolean addDefaultExclude(String s) { | |||||
public static boolean addDefaultExclude(final String s) { | |||||
synchronized (defaultExcludes) { | synchronized (defaultExcludes) { | ||||
return defaultExcludes.add(s); | return defaultExcludes.add(s); | ||||
} | } | ||||
@@ -591,7 +591,7 @@ public class DirectoryScanner | |||||
* | * | ||||
* @since Ant 1.6 | * @since Ant 1.6 | ||||
*/ | */ | ||||
public static boolean removeDefaultExclude(String s) { | |||||
public static boolean removeDefaultExclude(final String s) { | |||||
synchronized (defaultExcludes) { | synchronized (defaultExcludes) { | ||||
return defaultExcludes.remove(s); | return defaultExcludes.remove(s); | ||||
} | } | ||||
@@ -619,8 +619,7 @@ public class DirectoryScanner | |||||
* | * | ||||
* @param basedir The base directory to scan. | * @param basedir The base directory to scan. | ||||
*/ | */ | ||||
@Override | |||||
public void setBasedir(String basedir) { | |||||
public void setBasedir(final String basedir) { | |||||
setBasedir(basedir == null ? (File) null | setBasedir(basedir == null ? (File) null | ||||
: new File(basedir.replace('/', File.separatorChar).replace( | : new File(basedir.replace('/', File.separatorChar).replace( | ||||
'\\', File.separatorChar))); | '\\', File.separatorChar))); | ||||
@@ -632,8 +631,7 @@ public class DirectoryScanner | |||||
* | * | ||||
* @param basedir The base directory for scanning. | * @param basedir The base directory for scanning. | ||||
*/ | */ | ||||
@Override | |||||
public synchronized void setBasedir(File basedir) { | |||||
public synchronized void setBasedir(final File basedir) { | |||||
this.basedir = basedir; | this.basedir = basedir; | ||||
} | } | ||||
@@ -643,7 +641,6 @@ public class DirectoryScanner | |||||
* | * | ||||
* @return the base directory to be scanned. | * @return the base directory to be scanned. | ||||
*/ | */ | ||||
@Override | |||||
public synchronized File getBasedir() { | public synchronized File getBasedir() { | ||||
return basedir; | return basedir; | ||||
} | } | ||||
@@ -665,8 +662,7 @@ public class DirectoryScanner | |||||
* @param isCaseSensitive whether or not the file system should be | * @param isCaseSensitive whether or not the file system should be | ||||
* regarded as a case sensitive one. | * regarded as a case sensitive one. | ||||
*/ | */ | ||||
@Override | |||||
public synchronized void setCaseSensitive(boolean isCaseSensitive) { | |||||
public synchronized void setCaseSensitive(final boolean isCaseSensitive) { | |||||
this.isCaseSensitive = isCaseSensitive; | this.isCaseSensitive = isCaseSensitive; | ||||
} | } | ||||
@@ -677,7 +673,7 @@ public class DirectoryScanner | |||||
* is an error | * is an error | ||||
* @since Ant 1.7.1 | * @since Ant 1.7.1 | ||||
*/ | */ | ||||
public void setErrorOnMissingDir(boolean errorOnMissingDir) { | |||||
public void setErrorOnMissingDir(final boolean errorOnMissingDir) { | |||||
this.errorOnMissingDir = errorOnMissingDir; | this.errorOnMissingDir = errorOnMissingDir; | ||||
} | } | ||||
@@ -697,7 +693,7 @@ public class DirectoryScanner | |||||
* | * | ||||
* @param followSymlinks whether or not symbolic links should be followed. | * @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; | this.followSymlinks = followSymlinks; | ||||
} | } | ||||
@@ -707,7 +703,7 @@ public class DirectoryScanner | |||||
* | * | ||||
* @since Ant 1.8.0 | * @since Ant 1.8.0 | ||||
*/ | */ | ||||
public void setMaxLevelsOfSymlinks(int max) { | |||||
public void setMaxLevelsOfSymlinks(final int max) { | |||||
maxLevelsOfSymlinks = max; | maxLevelsOfSymlinks = max; | ||||
} | } | ||||
@@ -724,8 +720,7 @@ public class DirectoryScanner | |||||
* list is given, all elements must be | * list is given, all elements must be | ||||
* non-<code>null</code>. | * non-<code>null</code>. | ||||
*/ | */ | ||||
@Override | |||||
public synchronized void setIncludes(String[] includes) { | |||||
public synchronized void setIncludes(final String[] includes) { | |||||
if (includes == null) { | if (includes == null) { | ||||
this.includes = null; | this.includes = null; | ||||
} else { | } else { | ||||
@@ -748,8 +743,7 @@ public class DirectoryScanner | |||||
* should be excluded. If a non-<code>null</code> list is | * should be excluded. If a non-<code>null</code> list is | ||||
* given, all elements must be non-<code>null</code>. | * given, all elements must be non-<code>null</code>. | ||||
*/ | */ | ||||
@Override | |||||
public synchronized void setExcludes(String[] excludes) { | |||||
public synchronized void setExcludes(final String[] excludes) { | |||||
if (excludes == null) { | if (excludes == null) { | ||||
this.excludes = null; | this.excludes = null; | ||||
} else { | } else { | ||||
@@ -773,10 +767,10 @@ public class DirectoryScanner | |||||
* | * | ||||
* @since Ant 1.6.3 | * @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 (excludes != null && excludes.length > 0) { | ||||
if (this.excludes != null && this.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]; | + this.excludes.length]; | ||||
System.arraycopy(this.excludes, 0, tmp, 0, | System.arraycopy(this.excludes, 0, tmp, 0, | ||||
this.excludes.length); | this.excludes.length); | ||||
@@ -800,7 +794,7 @@ public class DirectoryScanner | |||||
* | * | ||||
* @since Ant 1.6.3 | * @since Ant 1.6.3 | ||||
*/ | */ | ||||
private static String normalizePattern(String p) { | |||||
private static String normalizePattern(final String p) { | |||||
String pattern = p.replace('/', File.separatorChar) | String pattern = p.replace('/', File.separatorChar) | ||||
.replace('\\', File.separatorChar); | .replace('\\', File.separatorChar); | ||||
if (pattern.endsWith(File.separator)) { | if (pattern.endsWith(File.separator)) { | ||||
@@ -814,8 +808,7 @@ public class DirectoryScanner | |||||
* | * | ||||
* @param selectors specifies the selectors to be invoked on a scan. | * @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; | this.selectors = selectors; | ||||
} | } | ||||
@@ -840,14 +833,13 @@ public class DirectoryScanner | |||||
* @exception IllegalStateException if the base directory was set | * @exception IllegalStateException if the base directory was set | ||||
* incorrectly (i.e. if it doesn't exist or isn't a directory). | * incorrectly (i.e. if it doesn't exist or isn't a directory). | ||||
*/ | */ | ||||
@Override | |||||
public void scan() throws IllegalStateException { | public void scan() throws IllegalStateException { | ||||
synchronized (scanLock) { | synchronized (scanLock) { | ||||
if (scanning) { | if (scanning) { | ||||
while (scanning) { | while (scanning) { | ||||
try { | try { | ||||
scanLock.wait(); | scanLock.wait(); | ||||
} catch (InterruptedException e) { | |||||
} catch (final InterruptedException e) { | |||||
continue; | continue; | ||||
} | } | ||||
} | } | ||||
@@ -858,17 +850,17 @@ public class DirectoryScanner | |||||
} | } | ||||
scanning = true; | scanning = true; | ||||
} | } | ||||
File savedBase = basedir; | |||||
final File savedBase = basedir; | |||||
try { | try { | ||||
synchronized (this) { | synchronized (this) { | ||||
illegal = null; | illegal = null; | ||||
clearResults(); | clearResults(); | ||||
// set in/excludes to reasonable defaults if needed: | // set in/excludes to reasonable defaults if needed: | ||||
boolean nullIncludes = (includes == null); | |||||
final boolean nullIncludes = (includes == null); | |||||
includes = nullIncludes | includes = nullIncludes | ||||
? new String[] {SelectorUtils.DEEP_TREE_MATCH} : includes; | ? new String[] {SelectorUtils.DEEP_TREE_MATCH} : includes; | ||||
boolean nullExcludes = (excludes == null); | |||||
final boolean nullExcludes = (excludes == null); | |||||
excludes = nullExcludes ? new String[0] : excludes; | excludes = nullExcludes ? new String[0] : excludes; | ||||
if (basedir != null && !followSymlinks | if (basedir != null && !followSymlinks | ||||
@@ -920,7 +912,7 @@ public class DirectoryScanner | |||||
includes = nullIncludes ? null : includes; | includes = nullIncludes ? null : includes; | ||||
excludes = nullExcludes ? null : excludes; | excludes = nullExcludes ? null : excludes; | ||||
} | } | ||||
} catch (IOException ex) { | |||||
} catch (final IOException ex) { | |||||
throw new BuildException(ex); | throw new BuildException(ex); | ||||
} finally { | } finally { | ||||
basedir = savedBase; | basedir = savedBase; | ||||
@@ -938,19 +930,19 @@ public class DirectoryScanner | |||||
*/ | */ | ||||
private void checkIncludePatterns() { | private void checkIncludePatterns() { | ||||
ensureNonPatternSetsReady(); | ensureNonPatternSetsReady(); | ||||
Map<TokenizedPath, String> newroots = new HashMap<TokenizedPath, String>(); | |||||
final Map<TokenizedPath, String> newroots = new HashMap<TokenizedPath, String>(); | |||||
// put in the newroots map the include patterns without | // put in the newroots map the include patterns without | ||||
// wildcard tokens | // wildcard tokens | ||||
for (int i = 0; i < includePatterns.length; i++) { | for (int i = 0; i < includePatterns.length; i++) { | ||||
String pattern = includePatterns[i].toString(); | |||||
final String pattern = includePatterns[i].toString(); | |||||
if (!shouldSkipPattern(pattern)) { | if (!shouldSkipPattern(pattern)) { | ||||
newroots.put(includePatterns[i].rtrimWildcardTokens(), | newroots.put(includePatterns[i].rtrimWildcardTokens(), | ||||
pattern); | pattern); | ||||
} | } | ||||
} | } | ||||
for (Map.Entry<String, TokenizedPath> entry : includeNonPatterns.entrySet()) { | |||||
String pattern = entry.getKey(); | |||||
for (final Map.Entry<String, TokenizedPath> entry : includeNonPatterns.entrySet()) { | |||||
final String pattern = entry.getKey(); | |||||
if (!shouldSkipPattern(pattern)) { | if (!shouldSkipPattern(pattern)) { | ||||
newroots.put(entry.getValue(), pattern); | newroots.put(entry.getValue(), pattern); | ||||
} | } | ||||
@@ -965,13 +957,13 @@ public class DirectoryScanner | |||||
if (basedir != null) { | if (basedir != null) { | ||||
try { | try { | ||||
canonBase = basedir.getCanonicalFile(); | canonBase = basedir.getCanonicalFile(); | ||||
} catch (IOException ex) { | |||||
} catch (final IOException ex) { | |||||
throw new BuildException(ex); | throw new BuildException(ex); | ||||
} | } | ||||
} | } | ||||
// only scan directories that can include matched files or | // only scan directories that can include matched files or | ||||
// directories | // directories | ||||
for (Map.Entry<TokenizedPath, String> entry : newroots.entrySet()) { | |||||
for (final Map.Entry<TokenizedPath, String> entry : newroots.entrySet()) { | |||||
TokenizedPath currentPath = entry.getKey(); | TokenizedPath currentPath = entry.getKey(); | ||||
String currentelement = currentPath.toString(); | String currentelement = currentPath.toString(); | ||||
if (basedir == null | if (basedir == null | ||||
@@ -985,7 +977,7 @@ public class DirectoryScanner | |||||
// the results to show what's really on the disk, so | // the results to show what's really on the disk, so | ||||
// we need to double check. | // we need to double check. | ||||
try { | try { | ||||
String path = (basedir == null) | |||||
final String path = (basedir == null) | |||||
? myfile.getCanonicalPath() | ? myfile.getCanonicalPath() | ||||
: FILE_UTILS.removeLeadingPath(canonBase, | : FILE_UTILS.removeLeadingPath(canonBase, | ||||
myfile.getCanonicalFile()); | myfile.getCanonicalFile()); | ||||
@@ -1001,13 +993,13 @@ public class DirectoryScanner | |||||
} | } | ||||
} | } | ||||
} | } | ||||
} catch (IOException ex) { | |||||
} catch (final IOException ex) { | |||||
throw new BuildException(ex); | throw new BuildException(ex); | ||||
} | } | ||||
} | } | ||||
if ((myfile == null || !myfile.exists()) && !isCaseSensitive()) { | if ((myfile == null || !myfile.exists()) && !isCaseSensitive()) { | ||||
File f = currentPath.findFile(basedir, false); | |||||
final File f = currentPath.findFile(basedir, false); | |||||
if (f != null && f.exists()) { | if (f != null && f.exists()) { | ||||
// adapt currentelement to the case we've | // adapt currentelement to the case we've | ||||
// actually found | // actually found | ||||
@@ -1032,8 +1024,8 @@ public class DirectoryScanner | |||||
scandir(myfile, currentPath, true); | scandir(myfile, currentPath, true); | ||||
} | } | ||||
} else if (myfile.isFile()) { | } else if (myfile.isFile()) { | ||||
String originalpattern = entry.getValue(); | |||||
boolean included = isCaseSensitive() | |||||
final String originalpattern = entry.getValue(); | |||||
final boolean included = isCaseSensitive() | |||||
? originalpattern.equals(currentelement) | ? originalpattern.equals(currentelement) | ||||
: originalpattern.equalsIgnoreCase(currentelement); | : originalpattern.equalsIgnoreCase(currentelement); | ||||
if (included) { | if (included) { | ||||
@@ -1051,7 +1043,7 @@ public class DirectoryScanner | |||||
* | * | ||||
* @since Ant 1.8.0 | * @since Ant 1.8.0 | ||||
*/ | */ | ||||
private boolean shouldSkipPattern(String pattern) { | |||||
private boolean shouldSkipPattern(final String pattern) { | |||||
if (FileUtils.isAbsolutePath(pattern)) { | if (FileUtils.isAbsolutePath(pattern)) { | ||||
//skip abs. paths not under basedir, if set: | //skip abs. paths not under basedir, if set: | ||||
if (basedir != null | if (basedir != null | ||||
@@ -1101,7 +1093,7 @@ public class DirectoryScanner | |||||
while (slowScanning) { | while (slowScanning) { | ||||
try { | try { | ||||
slowScanLock.wait(); | slowScanLock.wait(); | ||||
} catch (InterruptedException e) { | |||||
} catch (final InterruptedException e) { | |||||
// Empty | // Empty | ||||
} | } | ||||
} | } | ||||
@@ -1113,16 +1105,16 @@ public class DirectoryScanner | |||||
synchronized (this) { | synchronized (this) { | ||||
// set in/excludes to reasonable defaults if needed: | // set in/excludes to reasonable defaults if needed: | ||||
boolean nullIncludes = (includes == null); | |||||
final boolean nullIncludes = (includes == null); | |||||
includes = nullIncludes | includes = nullIncludes | ||||
? new String[] {SelectorUtils.DEEP_TREE_MATCH} : includes; | ? new String[] {SelectorUtils.DEEP_TREE_MATCH} : includes; | ||||
boolean nullExcludes = (excludes == null); | |||||
final boolean nullExcludes = (excludes == null); | |||||
excludes = nullExcludes ? new String[0] : excludes; | excludes = nullExcludes ? new String[0] : excludes; | ||||
String[] excl = new String[dirsExcluded.size()]; | |||||
final String[] excl = new String[dirsExcluded.size()]; | |||||
dirsExcluded.copyInto(excl); | dirsExcluded.copyInto(excl); | ||||
String[] notIncl = new String[dirsNotIncluded.size()]; | |||||
final String[] notIncl = new String[dirsNotIncluded.size()]; | |||||
dirsNotIncluded.copyInto(notIncl); | dirsNotIncluded.copyInto(notIncl); | ||||
ensureNonPatternSetsReady(); | 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++) { | 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)) { | if (!couldHoldIncluded(path) || contentsExcluded(path)) { | ||||
scandir(new File(basedir, arr[i]), path, false); | scandir(new File(basedir, arr[i]), path, false); | ||||
} | } | ||||
@@ -1171,7 +1163,7 @@ public class DirectoryScanner | |||||
* @see #dirsExcluded | * @see #dirsExcluded | ||||
* @see #slowScan | * @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); | scandir(dir, new TokenizedPath(vpath), fast); | ||||
} | } | ||||
@@ -1195,11 +1187,11 @@ public class DirectoryScanner | |||||
* @see #dirsExcluded | * @see #dirsExcluded | ||||
* @see #slowScan | * @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) { | if (dir == null) { | ||||
throw new BuildException("dir must not be null."); | throw new BuildException("dir must not be null."); | ||||
} | } | ||||
String[] newfiles = dir.list(); | |||||
final String[] newfiles = dir.list(); | |||||
if (newfiles == null) { | if (newfiles == null) { | ||||
if (!dir.exists()) { | if (!dir.exists()) { | ||||
throw new BuildException(dir + DOES_NOT_EXIST_POSTFIX); | throw new BuildException(dir + DOES_NOT_EXIST_POSTFIX); | ||||
@@ -1213,8 +1205,8 @@ public class DirectoryScanner | |||||
scandir(dir, path, fast, newfiles, new LinkedList<String>()); | scandir(dir, path, fast, newfiles, new LinkedList<String>()); | ||||
} | } | ||||
private void scandir(File dir, TokenizedPath path, boolean fast, | |||||
String[] newfiles, LinkedList<String> directoryNamesFollowed) { | |||||
private void scandir(final File dir, final TokenizedPath path, final boolean fast, | |||||
String[] newfiles, final LinkedList<String> directoryNamesFollowed) { | |||||
String vpath = path.toString(); | String vpath = path.toString(); | ||||
if (vpath.length() > 0 && !vpath.endsWith(File.separator)) { | if (vpath.length() > 0 && !vpath.endsWith(File.separator)) { | ||||
vpath += File.separator; | vpath += File.separator; | ||||
@@ -1225,12 +1217,12 @@ public class DirectoryScanner | |||||
return; | return; | ||||
} | } | ||||
if (!followSymlinks) { | if (!followSymlinks) { | ||||
ArrayList<String> noLinks = new ArrayList<String>(); | |||||
final ArrayList<String> noLinks = new ArrayList<String>(); | |||||
for (int i = 0; i < newfiles.length; i++) { | for (int i = 0; i < newfiles.length; i++) { | ||||
try { | try { | ||||
if (SYMLINK_UTILS.isSymbolicLink(dir, newfiles[i])) { | 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()) { | if (file.isDirectory()) { | ||||
dirsExcluded.addElement(name); | dirsExcluded.addElement(name); | ||||
} else if (file.isFile()) { | } else if (file.isFile()) { | ||||
@@ -1240,8 +1232,8 @@ public class DirectoryScanner | |||||
} else { | } else { | ||||
noLinks.add(newfiles[i]); | 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!"; | + "for links, couldn't get canonical path!"; | ||||
// will be caught and redirected to Ant's logging system | // will be caught and redirected to Ant's logging system | ||||
System.err.println(msg); | System.err.println(msg); | ||||
@@ -1254,10 +1246,10 @@ public class DirectoryScanner | |||||
} | } | ||||
for (int i = 0; i < newfiles.length; i++) { | 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 (children == null || (children.length == 0 && file.isFile())) { | ||||
if (isIncluded(newPath)) { | if (isIncluded(newPath)) { | ||||
accountForIncludedFile(newPath, file); | accountForIncludedFile(newPath, file); | ||||
@@ -1307,7 +1299,7 @@ public class DirectoryScanner | |||||
* @param name path of the file relative to the directory of the FileSet. | * @param name path of the file relative to the directory of the FileSet. | ||||
* @param file included File. | * @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, | processIncluded(name, file, filesIncluded, filesExcluded, | ||||
filesDeselected); | filesDeselected); | ||||
} | } | ||||
@@ -1319,29 +1311,29 @@ public class DirectoryScanner | |||||
* @param file directory as File. | * @param file directory as File. | ||||
* @param fast whether to perform fast scans. | * @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); | processIncluded(name, file, dirsIncluded, dirsExcluded, dirsDeselected); | ||||
if (fast && couldHoldIncluded(name) && !contentsExcluded(name)) { | if (fast && couldHoldIncluded(name) && !contentsExcluded(name)) { | ||||
scandir(file, name, fast); | scandir(file, name, fast); | ||||
} | } | ||||
} | } | ||||
private void accountForIncludedDir(TokenizedPath name, | |||||
File file, boolean fast, | |||||
String[] children, | |||||
LinkedList<String> directoryNamesFollowed) { | |||||
private void accountForIncludedDir(final TokenizedPath name, | |||||
final File file, final boolean fast, | |||||
final String[] children, | |||||
final LinkedList<String> directoryNamesFollowed) { | |||||
processIncluded(name, file, dirsIncluded, dirsExcluded, dirsDeselected); | processIncluded(name, file, dirsIncluded, dirsExcluded, dirsDeselected); | ||||
if (fast && couldHoldIncluded(name) && !contentsExcluded(name)) { | if (fast && couldHoldIncluded(name) && !contentsExcluded(name)) { | ||||
scandir(file, name, fast, children, directoryNamesFollowed); | 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); | accountForNotFollowedSymlink(new TokenizedPath(name), file); | ||||
} | } | ||||
private void accountForNotFollowedSymlink(TokenizedPath name, File file) { | |||||
private void accountForNotFollowedSymlink(final TokenizedPath name, final File file) { | |||||
if (!isExcluded(name) && | if (!isExcluded(name) && | ||||
(isIncluded(name) | (isIncluded(name) | ||||
|| (file.isDirectory() && couldHoldIncluded(name) | || (file.isDirectory() && couldHoldIncluded(name) | ||||
@@ -1350,10 +1342,10 @@ public class DirectoryScanner | |||||
} | } | ||||
} | } | ||||
private void processIncluded(TokenizedPath path, | |||||
File file, Vector<String> inc, Vector<String> exc, | |||||
Vector<String> des) { | |||||
String name = path.toString(); | |||||
private void processIncluded(final TokenizedPath path, | |||||
final File file, final Vector<String> inc, final Vector<String> exc, | |||||
final Vector<String> des) { | |||||
final String name = path.toString(); | |||||
if (inc.contains(name) || exc.contains(name) || des.contains(name)) { | if (inc.contains(name) || exc.contains(name) || des.contains(name)) { | ||||
return; | return; | ||||
} | } | ||||
@@ -1378,7 +1370,7 @@ public class DirectoryScanner | |||||
* @return <code>true</code> when the name matches against at least one | * @return <code>true</code> when the name matches against at least one | ||||
* include pattern, or <code>false</code> otherwise. | * include pattern, or <code>false</code> otherwise. | ||||
*/ | */ | ||||
protected boolean isIncluded(String name) { | |||||
protected boolean isIncluded(final String name) { | |||||
return isIncluded(new TokenizedPath(name)); | return isIncluded(new TokenizedPath(name)); | ||||
} | } | ||||
@@ -1390,7 +1382,7 @@ public class DirectoryScanner | |||||
* @return <code>true</code> when the name matches against at least one | * @return <code>true</code> when the name matches against at least one | ||||
* include pattern, or <code>false</code> otherwise. | * include pattern, or <code>false</code> otherwise. | ||||
*/ | */ | ||||
private boolean isIncluded(TokenizedPath path) { | |||||
private boolean isIncluded(final TokenizedPath path) { | |||||
ensureNonPatternSetsReady(); | ensureNonPatternSetsReady(); | ||||
if (isCaseSensitive() | if (isCaseSensitive() | ||||
@@ -1414,7 +1406,7 @@ public class DirectoryScanner | |||||
* @return <code>true</code> when the name matches against the start of at | * @return <code>true</code> when the name matches against the start of at | ||||
* least one include pattern, or <code>false</code> otherwise. | * least one include pattern, or <code>false</code> otherwise. | ||||
*/ | */ | ||||
protected boolean couldHoldIncluded(String name) { | |||||
protected boolean couldHoldIncluded(final String name) { | |||||
return couldHoldIncluded(new TokenizedPath(name)); | return couldHoldIncluded(new TokenizedPath(name)); | ||||
} | } | ||||
@@ -1426,13 +1418,13 @@ public class DirectoryScanner | |||||
* @return <code>true</code> when the name matches against the start of at | * @return <code>true</code> when the name matches against the start of at | ||||
* least one include pattern, or <code>false</code> otherwise. | * least one include pattern, or <code>false</code> otherwise. | ||||
*/ | */ | ||||
private boolean couldHoldIncluded(TokenizedPath tokenizedName) { | |||||
private boolean couldHoldIncluded(final TokenizedPath tokenizedName) { | |||||
for (int i = 0; i < includePatterns.length; i++) { | for (int i = 0; i < includePatterns.length; i++) { | ||||
if (couldHoldIncluded(tokenizedName, includePatterns[i])) { | if (couldHoldIncluded(tokenizedName, includePatterns[i])) { | ||||
return true; | return true; | ||||
} | } | ||||
} | } | ||||
for (Iterator<TokenizedPath> iter = includeNonPatterns.values().iterator(); | |||||
for (final Iterator<TokenizedPath> iter = includeNonPatterns.values().iterator(); | |||||
iter.hasNext();) { | iter.hasNext();) { | ||||
if (couldHoldIncluded(tokenizedName, | if (couldHoldIncluded(tokenizedName, | ||||
iter.next().toPattern())) { | iter.next().toPattern())) { | ||||
@@ -1450,8 +1442,8 @@ public class DirectoryScanner | |||||
* @return <code>true</code> when the name matches against the start of the | * @return <code>true</code> when the name matches against the start of the | ||||
* include pattern, or <code>false</code> otherwise. | * include pattern, or <code>false</code> otherwise. | ||||
*/ | */ | ||||
private boolean couldHoldIncluded(TokenizedPath tokenizedName, | |||||
TokenizedPattern tokenizedInclude) { | |||||
private boolean couldHoldIncluded(final TokenizedPath tokenizedName, | |||||
final TokenizedPattern tokenizedInclude) { | |||||
return tokenizedInclude.matchStartOf(tokenizedName, isCaseSensitive()) | return tokenizedInclude.matchStartOf(tokenizedName, isCaseSensitive()) | ||||
&& isMorePowerfulThanExcludes(tokenizedName.toString()) | && isMorePowerfulThanExcludes(tokenizedName.toString()) | ||||
&& isDeeper(tokenizedInclude, tokenizedName); | && isDeeper(tokenizedInclude, tokenizedName); | ||||
@@ -1465,7 +1457,7 @@ public class DirectoryScanner | |||||
* @return whether the pattern is deeper than the name. | * @return whether the pattern is deeper than the name. | ||||
* @since Ant 1.6.3 | * @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) | return pattern.containsPattern(SelectorUtils.DEEP_TREE_MATCH) | ||||
|| pattern.depth() > name.depth(); | || pattern.depth() > name.depth(); | ||||
} | } | ||||
@@ -1486,7 +1478,7 @@ public class DirectoryScanner | |||||
* this include pattern. | * this include pattern. | ||||
* @since Ant 1.6 | * @since Ant 1.6 | ||||
*/ | */ | ||||
private boolean isMorePowerfulThanExcludes(String name) { | |||||
private boolean isMorePowerfulThanExcludes(final String name) { | |||||
final String soughtexclude = | final String soughtexclude = | ||||
name + File.separatorChar + SelectorUtils.DEEP_TREE_MATCH; | name + File.separatorChar + SelectorUtils.DEEP_TREE_MATCH; | ||||
for (int counter = 0; counter < excludePatterns.length; counter++) { | for (int counter = 0; counter < excludePatterns.length; counter++) { | ||||
@@ -1502,7 +1494,7 @@ public class DirectoryScanner | |||||
* @param path the path to check. | * @param path the path to check. | ||||
* @return whether all the specified directory's contents are excluded. | * @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++) { | for (int i = 0; i < excludePatterns.length; i++) { | ||||
if (excludePatterns[i].endsWith(SelectorUtils.DEEP_TREE_MATCH) | if (excludePatterns[i].endsWith(SelectorUtils.DEEP_TREE_MATCH) | ||||
&& excludePatterns[i].withoutLastToken() | && excludePatterns[i].withoutLastToken() | ||||
@@ -1521,7 +1513,7 @@ public class DirectoryScanner | |||||
* @return <code>true</code> when the name matches against at least one | * @return <code>true</code> when the name matches against at least one | ||||
* exclude pattern, or <code>false</code> otherwise. | * exclude pattern, or <code>false</code> otherwise. | ||||
*/ | */ | ||||
protected boolean isExcluded(String name) { | |||||
protected boolean isExcluded(final String name) { | |||||
return isExcluded(new TokenizedPath(name)); | return isExcluded(new TokenizedPath(name)); | ||||
} | } | ||||
@@ -1533,7 +1525,7 @@ public class DirectoryScanner | |||||
* @return <code>true</code> when the name matches against at least one | * @return <code>true</code> when the name matches against at least one | ||||
* exclude pattern, or <code>false</code> otherwise. | * exclude pattern, or <code>false</code> otherwise. | ||||
*/ | */ | ||||
private boolean isExcluded(TokenizedPath name) { | |||||
private boolean isExcluded(final TokenizedPath name) { | |||||
ensureNonPatternSetsReady(); | ensureNonPatternSetsReady(); | ||||
if (isCaseSensitive() | if (isCaseSensitive() | ||||
@@ -1557,7 +1549,7 @@ public class DirectoryScanner | |||||
* @return <code>false</code> when the selectors says that the file | * @return <code>false</code> when the selectors says that the file | ||||
* should not be selected, <code>true</code> otherwise. | * should not be selected, <code>true</code> otherwise. | ||||
*/ | */ | ||||
protected boolean isSelected(String name, File file) { | |||||
protected boolean isSelected(final String name, final File file) { | |||||
if (selectors != null) { | if (selectors != null) { | ||||
for (int i = 0; i < selectors.length; i++) { | for (int i = 0; i < selectors.length; i++) { | ||||
if (!selectors[i].isSelected(basedir, name, file)) { | 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 | * @return the names of the files which matched at least one of the | ||||
* include patterns and none of the exclude patterns. | * include patterns and none of the exclude patterns. | ||||
*/ | */ | ||||
@Override | |||||
public String[] getIncludedFiles() { | public String[] getIncludedFiles() { | ||||
String[] files; | String[] files; | ||||
synchronized (this) { | synchronized (this) { | ||||
@@ -1612,10 +1603,9 @@ public class DirectoryScanner | |||||
* | * | ||||
* @see #slowScan | * @see #slowScan | ||||
*/ | */ | ||||
@Override | |||||
public synchronized String[] getNotIncludedFiles() { | public synchronized String[] getNotIncludedFiles() { | ||||
slowScan(); | slowScan(); | ||||
String[] files = new String[filesNotIncluded.size()]; | |||||
final String[] files = new String[filesNotIncluded.size()]; | |||||
filesNotIncluded.copyInto(files); | filesNotIncluded.copyInto(files); | ||||
return files; | return files; | ||||
} | } | ||||
@@ -1631,10 +1621,9 @@ public class DirectoryScanner | |||||
* | * | ||||
* @see #slowScan | * @see #slowScan | ||||
*/ | */ | ||||
@Override | |||||
public synchronized String[] getExcludedFiles() { | public synchronized String[] getExcludedFiles() { | ||||
slowScan(); | slowScan(); | ||||
String[] files = new String[filesExcluded.size()]; | |||||
final String[] files = new String[filesExcluded.size()]; | |||||
filesExcluded.copyInto(files); | filesExcluded.copyInto(files); | ||||
return files; | return files; | ||||
} | } | ||||
@@ -1650,10 +1639,9 @@ public class DirectoryScanner | |||||
* | * | ||||
* @see #slowScan | * @see #slowScan | ||||
*/ | */ | ||||
@Override | |||||
public synchronized String[] getDeselectedFiles() { | public synchronized String[] getDeselectedFiles() { | ||||
slowScan(); | slowScan(); | ||||
String[] files = new String[filesDeselected.size()]; | |||||
final String[] files = new String[filesDeselected.size()]; | |||||
filesDeselected.copyInto(files); | filesDeselected.copyInto(files); | ||||
return files; | return files; | ||||
} | } | ||||
@@ -1666,7 +1654,6 @@ public class DirectoryScanner | |||||
* @return the names of the directories which matched at least one of the | * @return the names of the directories which matched at least one of the | ||||
* include patterns and none of the exclude patterns. | * include patterns and none of the exclude patterns. | ||||
*/ | */ | ||||
@Override | |||||
public String[] getIncludedDirectories() { | public String[] getIncludedDirectories() { | ||||
String[] directories; | String[] directories; | ||||
synchronized (this) { | synchronized (this) { | ||||
@@ -1702,10 +1689,9 @@ public class DirectoryScanner | |||||
* | * | ||||
* @see #slowScan | * @see #slowScan | ||||
*/ | */ | ||||
@Override | |||||
public synchronized String[] getNotIncludedDirectories() { | public synchronized String[] getNotIncludedDirectories() { | ||||
slowScan(); | slowScan(); | ||||
String[] directories = new String[dirsNotIncluded.size()]; | |||||
final String[] directories = new String[dirsNotIncluded.size()]; | |||||
dirsNotIncluded.copyInto(directories); | dirsNotIncluded.copyInto(directories); | ||||
return directories; | return directories; | ||||
} | } | ||||
@@ -1721,10 +1707,9 @@ public class DirectoryScanner | |||||
* | * | ||||
* @see #slowScan | * @see #slowScan | ||||
*/ | */ | ||||
@Override | |||||
public synchronized String[] getExcludedDirectories() { | public synchronized String[] getExcludedDirectories() { | ||||
slowScan(); | slowScan(); | ||||
String[] directories = new String[dirsExcluded.size()]; | |||||
final String[] directories = new String[dirsExcluded.size()]; | |||||
dirsExcluded.copyInto(directories); | dirsExcluded.copyInto(directories); | ||||
return directories; | return directories; | ||||
} | } | ||||
@@ -1740,10 +1725,9 @@ public class DirectoryScanner | |||||
* | * | ||||
* @see #slowScan | * @see #slowScan | ||||
*/ | */ | ||||
@Override | |||||
public synchronized String[] getDeselectedDirectories() { | public synchronized String[] getDeselectedDirectories() { | ||||
slowScan(); | slowScan(); | ||||
String[] directories = new String[dirsDeselected.size()]; | |||||
final String[] directories = new String[dirsDeselected.size()]; | |||||
dirsDeselected.copyInto(directories); | dirsDeselected.copyInto(directories); | ||||
return directories; | return directories; | ||||
} | } | ||||
@@ -1770,11 +1754,10 @@ public class DirectoryScanner | |||||
/** | /** | ||||
* Add default exclusions to the current exclusions set. | * Add default exclusions to the current exclusions set. | ||||
*/ | */ | ||||
@Override | |||||
public synchronized void addDefaultExcludes() { | public synchronized void addDefaultExcludes() { | ||||
int excludesLength = excludes == null ? 0 : excludes.length; | |||||
final int excludesLength = excludes == null ? 0 : excludes.length; | |||||
String[] newExcludes; | String[] newExcludes; | ||||
String[] defaultExcludesTemp = getDefaultExcludes(); | |||||
final String[] defaultExcludesTemp = getDefaultExcludes(); | |||||
newExcludes = new String[excludesLength + defaultExcludesTemp.length]; | newExcludes = new String[excludesLength + defaultExcludesTemp.length]; | ||||
if (excludesLength > 0) { | if (excludesLength > 0) { | ||||
System.arraycopy(excludes, 0, newExcludes, 0, excludesLength); | System.arraycopy(excludes, 0, newExcludes, 0, excludesLength); | ||||
@@ -1794,8 +1777,7 @@ public class DirectoryScanner | |||||
* @return the resource with the given name. | * @return the resource with the given name. | ||||
* @since Ant 1.5.2 | * @since Ant 1.5.2 | ||||
*/ | */ | ||||
@Override | |||||
public synchronized Resource getResource(String name) { | |||||
public synchronized Resource getResource(final String name) { | |||||
return new FileResource(basedir, name); | return new FileResource(basedir, name); | ||||
} | } | ||||
@@ -1807,7 +1789,7 @@ public class DirectoryScanner | |||||
* | * | ||||
* @since Ant 1.6 | * @since Ant 1.6 | ||||
*/ | */ | ||||
private boolean hasBeenScanned(String vpath) { | |||||
private boolean hasBeenScanned(final String vpath) { | |||||
return !scannedDirs.add(vpath); | return !scannedDirs.add(vpath); | ||||
} | } | ||||
@@ -1855,11 +1837,11 @@ public class DirectoryScanner | |||||
* @param patterns String[] of patterns. | * @param patterns String[] of patterns. | ||||
* @since Ant 1.8.0 | * @since Ant 1.8.0 | ||||
*/ | */ | ||||
private TokenizedPattern[] fillNonPatternSet(Map<String, TokenizedPath> map, String[] patterns) { | |||||
ArrayList<TokenizedPattern> al = new ArrayList<TokenizedPattern>(patterns.length); | |||||
private TokenizedPattern[] fillNonPatternSet(final Map<String, TokenizedPath> map, final String[] patterns) { | |||||
final ArrayList<TokenizedPattern> al = new ArrayList<TokenizedPattern>(patterns.length); | |||||
for (int i = 0; i < patterns.length; i++) { | for (int i = 0; i < patterns.length; i++) { | ||||
if (!SelectorUtils.hasWildcards(patterns[i])) { | if (!SelectorUtils.hasWildcards(patterns[i])) { | ||||
String s = isCaseSensitive() | |||||
final String s = isCaseSensitive() | |||||
? patterns[i] : patterns[i].toUpperCase(); | ? patterns[i] : patterns[i].toUpperCase(); | ||||
map.put(s, new TokenizedPath(s)); | map.put(s, new TokenizedPath(s)); | ||||
} else { | } else { | ||||
@@ -1880,21 +1862,21 @@ public class DirectoryScanner | |||||
* | * | ||||
* @since Ant 1.8.0 | * @since Ant 1.8.0 | ||||
*/ | */ | ||||
private boolean causesIllegalSymlinkLoop(String dirName, File parent, | |||||
LinkedList<String> directoryNamesFollowed) { | |||||
private boolean causesIllegalSymlinkLoop(final String dirName, final File parent, | |||||
final LinkedList<String> directoryNamesFollowed) { | |||||
try { | try { | ||||
if (directoryNamesFollowed.size() >= maxLevelsOfSymlinks | if (directoryNamesFollowed.size() >= maxLevelsOfSymlinks | ||||
&& CollectionUtils.frequency(directoryNamesFollowed, dirName) | && CollectionUtils.frequency(directoryNamesFollowed, dirName) | ||||
>= maxLevelsOfSymlinks | >= maxLevelsOfSymlinks | ||||
&& SYMLINK_UTILS.isSymbolicLink(parent, dirName)) { | && SYMLINK_UTILS.isSymbolicLink(parent, dirName)) { | ||||
ArrayList<String> files = new ArrayList<String>(); | |||||
final ArrayList<String> files = new ArrayList<String>(); | |||||
File f = FILE_UTILS.resolveFile(parent, dirName); | File f = FILE_UTILS.resolveFile(parent, dirName); | ||||
String target = f.getCanonicalPath(); | |||||
final String target = f.getCanonicalPath(); | |||||
files.add(target); | files.add(target); | ||||
String relPath = ""; | String relPath = ""; | ||||
for (String dir : directoryNamesFollowed) { | |||||
for (final String dir : directoryNamesFollowed) { | |||||
relPath += "../"; | relPath += "../"; | ||||
if (dirName.equals(dir)) { | if (dirName.equals(dir)) { | ||||
f = FILE_UTILS.resolveFile(parent, relPath + dir); | f = FILE_UTILS.resolveFile(parent, relPath + dir); | ||||
@@ -1909,7 +1891,7 @@ public class DirectoryScanner | |||||
} | } | ||||
return false; | return false; | ||||
} catch (IOException ex) { | |||||
} catch (final IOException ex) { | |||||
throw new BuildException("Caught error while checking for" | throw new BuildException("Caught error while checking for" | ||||
+ " symbolic links", ex); | + " symbolic links", ex); | ||||
} | } | ||||
@@ -157,7 +157,6 @@ public class Main implements AntMain { | |||||
private final Map<Class<?>, List<String>> extraArguments = new HashMap<Class<?>, List<String>>(); | private final Map<Class<?>, List<String>> extraArguments = new HashMap<Class<?>, List<String>>(); | ||||
private static final GetProperty NOPROPERTIES = new GetProperty() { | private static final GetProperty NOPROPERTIES = new GetProperty() { | ||||
@Override | |||||
public Object getProperty(final String aName) { | public Object getProperty(final String aName) { | ||||
// No existing property takes precedence | // No existing property takes precedence | ||||
return null; | return null; | ||||
@@ -208,7 +207,6 @@ public class Main implements AntMain { | |||||
* | * | ||||
* @since Ant 1.6 | * @since Ant 1.6 | ||||
*/ | */ | ||||
@Override | |||||
public void startAnt(final String[] args, final Properties additionalUserProperties, | public void startAnt(final String[] args, final Properties additionalUserProperties, | ||||
final ClassLoader coreLoader) { | final ClassLoader coreLoader) { | ||||
@@ -2487,7 +2487,6 @@ public class Project implements ResourceFactory { | |||||
* @return the file resource. | * @return the file resource. | ||||
* @since Ant 1.7 | * @since Ant 1.7 | ||||
*/ | */ | ||||
@Override | |||||
public Resource getResource(final String name) { | public Resource getResource(final String name) { | ||||
return new FileResource(getBaseDir(), name); | return new FileResource(getBaseDir(), name); | ||||
} | } | ||||
@@ -171,9 +171,8 @@ public final class ConcatFilter extends BaseParamFilterReader | |||||
* @return a new filter based on this configuration, but filtering | * @return a new filter based on this configuration, but filtering | ||||
* the specified reader | * the specified reader | ||||
*/ | */ | ||||
@Override | |||||
public Reader chain(final Reader rdr) { | public Reader chain(final Reader rdr) { | ||||
ConcatFilter newFilter = new ConcatFilter(rdr); | |||||
final ConcatFilter newFilter = new ConcatFilter(rdr); | |||||
newFilter.setPrepend(getPrepend()); | newFilter.setPrepend(getPrepend()); | ||||
newFilter.setAppend(getAppend()); | newFilter.setAppend(getAppend()); | ||||
// Usually the initialized is set to true. But here it must not. | // 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 { | private void initialize() throws IOException { | ||||
// get parameters | // get parameters | ||||
Parameter[] params = getParameters(); | |||||
final Parameter[] params = getParameters(); | |||||
if (params != null) { | if (params != null) { | ||||
for (int i = 0; i < params.length; i++) { | for (int i = 0; i < params.length; i++) { | ||||
if ("prepend".equals(params[i].getName())) { | if ("prepend".equals(params[i].getName())) { | ||||
@@ -182,12 +182,10 @@ public class AntStructure extends Task { | |||||
private final Hashtable<String, String> visited = new Hashtable<String, String>(); | private final Hashtable<String, String> visited = new Hashtable<String, String>(); | ||||
@Override | |||||
public void printTail(final PrintWriter out) { | public void printTail(final PrintWriter out) { | ||||
visited.clear(); | visited.clear(); | ||||
} | } | ||||
@Override | |||||
public void printHead(final PrintWriter out, final Project p, final Hashtable<String, Class<?>> tasks, | public void printHead(final PrintWriter out, final Project p, final Hashtable<String, Class<?>> tasks, | ||||
final Hashtable<String, Class<?>> types) { | final Hashtable<String, Class<?>> types) { | ||||
printHead(out, tasks.keys(), types.keys()); | printHead(out, tasks.keys(), types.keys()); | ||||
@@ -246,7 +244,6 @@ public class AntStructure extends Task { | |||||
/** | /** | ||||
* Prints the definition for the target element. | * Prints the definition for the target element. | ||||
*/ | */ | ||||
@Override | |||||
public void printTargetDecl(final PrintWriter out) { | public void printTargetDecl(final PrintWriter out) { | ||||
out.print("<!ELEMENT target ("); | out.print("<!ELEMENT target ("); | ||||
out.print(TASKS); | out.print(TASKS); | ||||
@@ -280,7 +277,6 @@ public class AntStructure extends Task { | |||||
/** | /** | ||||
* Print the definition for a given element. | * Print the definition for a given element. | ||||
*/ | */ | ||||
@Override | |||||
public void printElementDecl(final PrintWriter out, final Project p, | public void printElementDecl(final PrintWriter out, final Project p, | ||||
final String name, final Class<?> element) { | final String name, final Class<?> element) { | ||||
@@ -823,16 +823,16 @@ public class Copy extends Task { | |||||
toCopy = new Resource[v.size()]; | toCopy = new Resource[v.size()]; | ||||
v.copyInto(toCopy); | v.copyInto(toCopy); | ||||
} else { | } else { | ||||
toCopy = | |||||
ResourceUtils.selectOutOfDateSources(this, fromResources, | |||||
mapper, | |||||
new ResourceFactory() { | |||||
@Override | |||||
toCopy = ResourceUtils.selectOutOfDateSources( | |||||
this, | |||||
fromResources, | |||||
mapper, | |||||
new ResourceFactory() { | |||||
public Resource getResource(final String name) { | 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++) { | for (int i = 0; i < toCopy.length; i++) { | ||||
final String[] mappedFiles = mapper.mapFileName(toCopy[i].getName()); | final String[] mappedFiles = mapper.mapFileName(toCopy[i].getName()); | ||||
@@ -71,7 +71,7 @@ public class Get extends Task { | |||||
private static final String DEFAULT_AGENT_PREFIX = "Apache Ant"; | private static final String DEFAULT_AGENT_PREFIX = "Apache Ant"; | ||||
private static final String GZIP_CONTENT_ENCODING = "gzip"; | private static final String GZIP_CONTENT_ENCODING = "gzip"; | ||||
private Resources sources = new Resources(); | |||||
private final Resources sources = new Resources(); | |||||
private File destination; // required | private File destination; // required | ||||
private boolean verbose = false; | private boolean verbose = false; | ||||
private boolean quiet = false; | private boolean quiet = false; | ||||
@@ -98,9 +98,9 @@ public class Get extends Task { | |||||
public void execute() throws BuildException { | public void execute() throws BuildException { | ||||
checkAttributes(); | 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; | File dest = destination; | ||||
if (destination.isDirectory()) { | if (destination.isDirectory()) { | ||||
@@ -109,14 +109,14 @@ public class Get extends Task { | |||||
if (path.endsWith("/")) { | if (path.endsWith("/")) { | ||||
path = path.substring(0, path.length() - 1); | path = path.substring(0, path.length() - 1); | ||||
} | } | ||||
int slash = path.lastIndexOf("/"); | |||||
final int slash = path.lastIndexOf("/"); | |||||
if (slash > -1) { | if (slash > -1) { | ||||
path = path.substring(slash + 1); | path = path.substring(slash + 1); | ||||
} | } | ||||
dest = new File(destination, path); | dest = new File(destination, path); | ||||
} else { | } 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) { | if (d == null) { | ||||
log("skipping " + r + " - mapper can't handle it", | log("skipping " + r + " - mapper can't handle it", | ||||
Project.MSG_WARN); | Project.MSG_WARN); | ||||
@@ -135,7 +135,7 @@ public class Get extends Task { | |||||
} | } | ||||
//set up logging | //set up logging | ||||
int logLevel = Project.MSG_INFO; | |||||
final int logLevel = Project.MSG_INFO; | |||||
DownloadProgress progress = null; | DownloadProgress progress = null; | ||||
if (verbose) { | if (verbose) { | ||||
progress = new VerboseProgress(System.out); | progress = new VerboseProgress(System.out); | ||||
@@ -144,7 +144,7 @@ public class Get extends Task { | |||||
//execute the get | //execute the get | ||||
try { | try { | ||||
doGet(source, dest, logLevel, progress); | doGet(source, dest, logLevel, progress); | ||||
} catch (IOException ioe) { | |||||
} catch (final IOException ioe) { | |||||
log("Error getting " + source + " to " + dest); | log("Error getting " + source + " to " + dest); | ||||
if (!ignoreErrors) { | if (!ignoreErrors) { | ||||
throw new BuildException(ioe, getLocation()); | throw new BuildException(ioe, getLocation()); | ||||
@@ -168,12 +168,12 @@ public class Get extends Task { | |||||
* @deprecated only gets the first configured resource | * @deprecated only gets the first configured resource | ||||
*/ | */ | ||||
@Deprecated | @Deprecated | ||||
public boolean doGet(int logLevel, DownloadProgress progress) | |||||
public boolean doGet(final int logLevel, final DownloadProgress progress) | |||||
throws IOException { | throws IOException { | ||||
checkAttributes(); | 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); | return doGet(source, destination, logLevel, progress); | ||||
} | } | ||||
/*NOTREACHED*/ | /*NOTREACHED*/ | ||||
@@ -197,7 +197,7 @@ public class Get extends Task { | |||||
* is false. | * is false. | ||||
* @since Ant 1.8.0 | * @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) | DownloadProgress progress) | ||||
throws IOException { | throws IOException { | ||||
@@ -221,13 +221,13 @@ public class Get extends Task { | |||||
if (useTimestamp && dest.exists()) { | if (useTimestamp && dest.exists()) { | ||||
timestamp = dest.lastModified(); | timestamp = dest.lastModified(); | ||||
if (verbose) { | if (verbose) { | ||||
Date t = new Date(timestamp); | |||||
final Date t = new Date(timestamp); | |||||
log("local file date : " + t.toString(), logLevel); | log("local file date : " + t.toString(), logLevel); | ||||
} | } | ||||
hasTimestamp = true; | hasTimestamp = true; | ||||
} | } | ||||
GetThread getThread = new GetThread(source, dest, | |||||
final GetThread getThread = new GetThread(source, dest, | |||||
hasTimestamp, timestamp, progress, | hasTimestamp, timestamp, progress, | ||||
logLevel, userAgent); | logLevel, userAgent); | ||||
getThread.setDaemon(true); | getThread.setDaemon(true); | ||||
@@ -235,13 +235,13 @@ public class Get extends Task { | |||||
getThread.start(); | getThread.start(); | ||||
try { | try { | ||||
getThread.join(maxTime * 1000); | getThread.join(maxTime * 1000); | ||||
} catch (InterruptedException ie) { | |||||
} catch (final InterruptedException ie) { | |||||
log("interrupted waiting for GET to finish", | log("interrupted waiting for GET to finish", | ||||
Project.MSG_VERBOSE); | Project.MSG_VERBOSE); | ||||
} | } | ||||
if (getThread.isAlive()) { | 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."; | + " seconds, stopping it."; | ||||
if (ignoreErrors) { | if (ignoreErrors) { | ||||
log(msg); | log(msg); | ||||
@@ -257,7 +257,7 @@ public class Get extends Task { | |||||
} | } | ||||
@Override | @Override | ||||
public void log(String msg, int msgLevel) { | |||||
public void log(final String msg, final int msgLevel) { | |||||
if (!quiet || msgLevel >= Project.MSG_ERR) { | if (!quiet || msgLevel >= Project.MSG_ERR) { | ||||
super.log(msg, msgLevel); | super.log(msg, msgLevel); | ||||
} | } | ||||
@@ -276,8 +276,8 @@ public class Get extends Task { | |||||
throw new BuildException("at least one source is required", | throw new BuildException("at least one source is required", | ||||
getLocation()); | 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) { | if (up == null) { | ||||
throw new BuildException("Only URLProvider resources are" | throw new BuildException("Only URLProvider resources are" | ||||
+ " supported", getLocation()); | + " supported", getLocation()); | ||||
@@ -311,7 +311,7 @@ public class Get extends Task { | |||||
* | * | ||||
* @param u URL for the file. | * @param u URL for the file. | ||||
*/ | */ | ||||
public void setSrc(URL u) { | |||||
public void setSrc(final URL u) { | |||||
add(new URLResource(u)); | add(new URLResource(u)); | ||||
} | } | ||||
@@ -319,7 +319,7 @@ public class Get extends Task { | |||||
* Adds URLs to get. | * Adds URLs to get. | ||||
* @since Ant 1.8.0 | * @since Ant 1.8.0 | ||||
*/ | */ | ||||
public void add(ResourceCollection rc) { | |||||
public void add(final ResourceCollection rc) { | |||||
sources.add(rc); | sources.add(rc); | ||||
} | } | ||||
@@ -328,7 +328,7 @@ public class Get extends Task { | |||||
* | * | ||||
* @param dest Path to file. | * @param dest Path to file. | ||||
*/ | */ | ||||
public void setDest(File dest) { | |||||
public void setDest(final File dest) { | |||||
this.destination = dest; | this.destination = dest; | ||||
} | } | ||||
@@ -337,7 +337,7 @@ public class Get extends Task { | |||||
* | * | ||||
* @param v if "true" then be verbose | * @param v if "true" then be verbose | ||||
*/ | */ | ||||
public void setVerbose(boolean v) { | |||||
public void setVerbose(final boolean v) { | |||||
verbose = v; | verbose = v; | ||||
} | } | ||||
@@ -347,7 +347,7 @@ public class Get extends Task { | |||||
* @param v if "true" then be quiet | * @param v if "true" then be quiet | ||||
* @since Ant 1.9.4 | * @since Ant 1.9.4 | ||||
*/ | */ | ||||
public void setQuiet(boolean v){ | |||||
public void setQuiet(final boolean v){ | |||||
this.quiet = 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 | * @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; | ignoreErrors = v; | ||||
} | } | ||||
@@ -378,7 +378,7 @@ public class Get extends Task { | |||||
* cause no end of grief.</p> | * cause no end of grief.</p> | ||||
* @param v "true" to enable file time fetching | * @param v "true" to enable file time fetching | ||||
*/ | */ | ||||
public void setUseTimestamp(boolean v) { | |||||
public void setUseTimestamp(final boolean v) { | |||||
useTimestamp = v; | useTimestamp = v; | ||||
} | } | ||||
@@ -388,7 +388,7 @@ public class Get extends Task { | |||||
* | * | ||||
* @param u username for authentication | * @param u username for authentication | ||||
*/ | */ | ||||
public void setUsername(String u) { | |||||
public void setUsername(final String u) { | |||||
this.uname = u; | this.uname = u; | ||||
} | } | ||||
@@ -397,7 +397,7 @@ public class Get extends Task { | |||||
* | * | ||||
* @param p password for authentication | * @param p password for authentication | ||||
*/ | */ | ||||
public void setPassword(String p) { | |||||
public void setPassword(final String p) { | |||||
this.pword = p; | this.pword = p; | ||||
} | } | ||||
@@ -407,7 +407,7 @@ public class Get extends Task { | |||||
* | * | ||||
* @since Ant 1.8.0 | * @since Ant 1.8.0 | ||||
*/ | */ | ||||
public void setMaxTime(long maxTime) { | |||||
public void setMaxTime(final long maxTime) { | |||||
this.maxTime = maxTime; | this.maxTime = maxTime; | ||||
} | } | ||||
@@ -418,7 +418,7 @@ public class Get extends Task { | |||||
* | * | ||||
* @since Ant 1.8.0 | * @since Ant 1.8.0 | ||||
*/ | */ | ||||
public void setRetries(int r) { | |||||
public void setRetries(final int r) { | |||||
this.numberRetries = r; | this.numberRetries = r; | ||||
} | } | ||||
@@ -429,7 +429,7 @@ public class Get extends Task { | |||||
* | * | ||||
* @since Ant 1.8.0 | * @since Ant 1.8.0 | ||||
*/ | */ | ||||
public void setSkipExisting(boolean s) { | |||||
public void setSkipExisting(final boolean s) { | |||||
this.skipExisting = s; | this.skipExisting = s; | ||||
} | } | ||||
@@ -441,7 +441,7 @@ public class Get extends Task { | |||||
* | * | ||||
* @since Ant 1.9.3 | * @since Ant 1.9.3 | ||||
*/ | */ | ||||
public void setUserAgent(String userAgent) { | |||||
public void setUserAgent(final String userAgent) { | |||||
this.userAgent = userAgent; | this.userAgent = userAgent; | ||||
} | } | ||||
@@ -455,7 +455,7 @@ public class Get extends Task { | |||||
* | * | ||||
* @since Ant 1.8.0 | * @since Ant 1.8.0 | ||||
*/ | */ | ||||
public void setHttpUseCaches(boolean httpUseCache) { | |||||
public void setHttpUseCaches(final boolean httpUseCache) { | |||||
this.httpUseCaches = httpUseCache; | this.httpUseCaches = httpUseCache; | ||||
} | } | ||||
@@ -479,7 +479,7 @@ public class Get extends Task { | |||||
* @param fileNameMapper the mapper to add. | * @param fileNameMapper the mapper to add. | ||||
* @since Ant 1.8.0 | * @since Ant 1.8.0 | ||||
*/ | */ | ||||
public void add(FileNameMapper fileNameMapper) { | |||||
public void add(final FileNameMapper fileNameMapper) { | |||||
createMapper().add(fileNameMapper); | createMapper().add(fileNameMapper); | ||||
} | } | ||||
@@ -520,25 +520,20 @@ public class Get extends Task { | |||||
/** | /** | ||||
* begin a download | * begin a download | ||||
*/ | */ | ||||
@Override | |||||
public void beginDownload() { | public void beginDownload() { | ||||
} | } | ||||
/** | /** | ||||
* tick handler | * tick handler | ||||
* | * | ||||
*/ | */ | ||||
@Override | |||||
public void onTick() { | public void onTick() { | ||||
} | } | ||||
/** | /** | ||||
* end a download | * end a download | ||||
*/ | */ | ||||
@Override | |||||
public void endDownload() { | public void endDownload() { | ||||
} | } | ||||
} | } | ||||
@@ -555,14 +550,13 @@ public class Get extends Task { | |||||
* Construct a verbose progress reporter. | * Construct a verbose progress reporter. | ||||
* @param out the output stream. | * @param out the output stream. | ||||
*/ | */ | ||||
public VerboseProgress(PrintStream out) { | |||||
public VerboseProgress(final PrintStream out) { | |||||
this.out = out; | this.out = out; | ||||
} | } | ||||
/** | /** | ||||
* begin a download | * begin a download | ||||
*/ | */ | ||||
@Override | |||||
public void beginDownload() { | public void beginDownload() { | ||||
dots = 0; | dots = 0; | ||||
} | } | ||||
@@ -571,7 +565,6 @@ public class Get extends Task { | |||||
* tick handler | * tick handler | ||||
* | * | ||||
*/ | */ | ||||
@Override | |||||
public void onTick() { | public void onTick() { | ||||
out.print("."); | out.print("."); | ||||
if (dots++ > DOTS_PER_LINE) { | if (dots++ > DOTS_PER_LINE) { | ||||
@@ -583,7 +576,6 @@ public class Get extends Task { | |||||
/** | /** | ||||
* end a download | * end a download | ||||
*/ | */ | ||||
@Override | |||||
public void endDownload() { | public void endDownload() { | ||||
out.println(); | out.println(); | ||||
out.flush(); | out.flush(); | ||||
@@ -608,8 +600,8 @@ public class Get extends Task { | |||||
private int redirections = 0; | private int redirections = 0; | ||||
private String userAgent = null; | 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.source = source; | ||||
this.dest = dest; | this.dest = dest; | ||||
hasTimestamp = h; | hasTimestamp = h; | ||||
@@ -623,9 +615,9 @@ public class Get extends Task { | |||||
public void run() { | public void run() { | ||||
try { | try { | ||||
success = get(); | success = get(); | ||||
} catch (IOException ioex) { | |||||
} catch (final IOException ioex) { | |||||
ioexception = ioex; | ioexception = ioex; | ||||
} catch (BuildException bex) { | |||||
} catch (final BuildException bex) { | |||||
exception = bex; | exception = bex; | ||||
} | } | ||||
} | } | ||||
@@ -638,7 +630,7 @@ public class Get extends Task { | |||||
return false; | return false; | ||||
} | } | ||||
boolean downloadSucceeded = downloadFile(); | |||||
final boolean downloadSucceeded = downloadFile(); | |||||
//if (and only if) the use file time option is set, then | //if (and only if) the use file time option is set, then | ||||
//the saved file now has its timestamp set to that of the | //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 | if (!(aSource.getProtocol().equals(aDest.getProtocol()) || (HTTP | ||||
.equals(aSource.getProtocol()) && HTTPS.equals(aDest | .equals(aSource.getProtocol()) && HTTPS.equals(aDest | ||||
.getProtocol())))) { | .getProtocol())))) { | ||||
String message = "Redirection detected from " | |||||
final String message = "Redirection detected from " | |||||
+ aSource.getProtocol() + " to " + aDest.getProtocol() | + aSource.getProtocol() + " to " + aDest.getProtocol() | ||||
+ ". Protocol switch unsafe, not allowed."; | + ". Protocol switch unsafe, not allowed."; | ||||
if (ignoreErrors) { | if (ignoreErrors) { | ||||
@@ -668,7 +660,7 @@ public class Get extends Task { | |||||
redirections++; | redirections++; | ||||
if (redirections > REDIRECT_LIMIT) { | if (redirections > REDIRECT_LIMIT) { | ||||
String message = "More than " + REDIRECT_LIMIT | |||||
final String message = "More than " + REDIRECT_LIMIT | |||||
+ " times redirected, giving up"; | + " times redirected, giving up"; | ||||
if (ignoreErrors) { | if (ignoreErrors) { | ||||
log(message, logLevel); | log(message, logLevel); | ||||
@@ -682,10 +674,10 @@ public class Get extends Task { | |||||
return true; | return true; | ||||
} | } | ||||
private URLConnection openConnection(URL aSource) throws IOException { | |||||
private URLConnection openConnection(final URL aSource) throws IOException { | |||||
// set up the URL connection | // set up the URL connection | ||||
URLConnection connection = aSource.openConnection(); | |||||
final URLConnection connection = aSource.openConnection(); | |||||
// modify the headers | // modify the headers | ||||
// NB: things like user authentication could go in here too. | // NB: things like user authentication could go in here too. | ||||
if (hasTimestamp) { | if (hasTimestamp) { | ||||
@@ -696,12 +688,12 @@ public class Get extends Task { | |||||
// prepare Java 1.1 style credentials | // prepare Java 1.1 style credentials | ||||
if (uname != null || pword != null) { | if (uname != null || pword != null) { | ||||
String up = uname + ":" + pword; | |||||
final String up = uname + ":" + pword; | |||||
String encoding; | String encoding; | ||||
// we do not use the sun impl for portability, | // we do not use the sun impl for portability, | ||||
// and always use our own implementation for consistent | // and always use our own implementation for consistent | ||||
// testing | // testing | ||||
Base64Converter encoder = new Base64Converter(); | |||||
final Base64Converter encoder = new Base64Converter(); | |||||
encoding = encoder.encode(up.getBytes()); | encoding = encoder.encode(up.getBytes()); | ||||
connection.setRequestProperty("Authorization", "Basic " | connection.setRequestProperty("Authorization", "Basic " | ||||
+ encoding); | + encoding); | ||||
@@ -718,29 +710,29 @@ public class Get extends Task { | |||||
// connect to the remote site (may take some time) | // connect to the remote site (may take some time) | ||||
try { | try { | ||||
connection.connect(); | connection.connect(); | ||||
} catch (NullPointerException e) { | |||||
} catch (final NullPointerException e) { | |||||
//bad URLs can trigger NPEs in some JVMs | //bad URLs can trigger NPEs in some JVMs | ||||
throw new BuildException("Failed to parse " + source.toString(), e); | throw new BuildException("Failed to parse " + source.toString(), e); | ||||
} | } | ||||
// First check on a 301 / 302 (moved) response (HTTP only) | // First check on a 301 / 302 (moved) response (HTTP only) | ||||
if (connection instanceof HttpURLConnection) { | 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)) { | 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" | + (responseCode == HttpURLConnection.HTTP_MOVED_PERM ? " permanently" | ||||
: "") + " moved to " + newLocation; | : "") + " moved to " + newLocation; | ||||
log(message, logLevel); | log(message, logLevel); | ||||
URL newURL = new URL(aSource, newLocation); | |||||
final URL newURL = new URL(aSource, newLocation); | |||||
if (!redirectionAllowed(aSource, newURL)) { | if (!redirectionAllowed(aSource, newURL)) { | ||||
return null; | return null; | ||||
} | } | ||||
return openConnection(newURL); | return openConnection(newURL); | ||||
} | } | ||||
// next test for a 304 result (HTTP only) | // next test for a 304 result (HTTP only) | ||||
long lastModified = httpConnection.getLastModified(); | |||||
final long lastModified = httpConnection.getLastModified(); | |||||
if (responseCode == HttpURLConnection.HTTP_NOT_MODIFIED | if (responseCode == HttpURLConnection.HTTP_NOT_MODIFIED | ||||
|| (lastModified != 0 && hasTimestamp && timestamp >= lastModified)) { | || (lastModified != 0 && hasTimestamp && timestamp >= lastModified)) { | ||||
// not modified so no file download. just return | // not modified so no file download. just return | ||||
@@ -752,7 +744,7 @@ public class Get extends Task { | |||||
} | } | ||||
// test for 401 result (HTTP only) | // test for 401 result (HTTP only) | ||||
if (responseCode == HttpURLConnection.HTTP_UNAUTHORIZED) { | if (responseCode == HttpURLConnection.HTTP_UNAUTHORIZED) { | ||||
String message = "HTTP Authorization failure"; | |||||
final String message = "HTTP Authorization failure"; | |||||
if (ignoreErrors) { | if (ignoreErrors) { | ||||
log(message, logLevel); | log(message, logLevel); | ||||
return null; | return null; | ||||
@@ -770,7 +762,7 @@ public class Get extends Task { | |||||
return connection; | return connection; | ||||
} | } | ||||
private boolean isMoved(int responseCode) { | |||||
private boolean isMoved(final int responseCode) { | |||||
return responseCode == HttpURLConnection.HTTP_MOVED_PERM || | return responseCode == HttpURLConnection.HTTP_MOVED_PERM || | ||||
responseCode == HttpURLConnection.HTTP_MOVED_TEMP || | responseCode == HttpURLConnection.HTTP_MOVED_TEMP || | ||||
responseCode == HttpURLConnection.HTTP_SEE_OTHER || | responseCode == HttpURLConnection.HTTP_SEE_OTHER || | ||||
@@ -786,7 +778,7 @@ public class Get extends Task { | |||||
try { | try { | ||||
is = connection.getInputStream(); | is = connection.getInputStream(); | ||||
break; | break; | ||||
} catch (IOException ex) { | |||||
} catch (final IOException ex) { | |||||
log("Error opening connection " + ex, logLevel); | log("Error opening connection " + ex, logLevel); | ||||
} | } | ||||
} | } | ||||
@@ -807,7 +799,7 @@ public class Get extends Task { | |||||
progress.beginDownload(); | progress.beginDownload(); | ||||
boolean finished = false; | boolean finished = false; | ||||
try { | try { | ||||
byte[] buffer = new byte[BIG_BUFFER_SIZE]; | |||||
final byte[] buffer = new byte[BIG_BUFFER_SIZE]; | |||||
int length; | int length; | ||||
while (!isInterrupted() && (length = is.read(buffer)) >= 0) { | while (!isInterrupted() && (length = is.read(buffer)) >= 0) { | ||||
os.write(buffer, 0, length); | os.write(buffer, 0, length); | ||||
@@ -830,9 +822,9 @@ public class Get extends Task { | |||||
} | } | ||||
private void updateTimeStamp() { | private void updateTimeStamp() { | ||||
long remoteTimestamp = connection.getLastModified(); | |||||
final long remoteTimestamp = connection.getLastModified(); | |||||
if (verbose) { | if (verbose) { | ||||
Date t = new Date(remoteTimestamp); | |||||
final Date t = new Date(remoteTimestamp); | |||||
log("last modified = " + t.toString() | log("last modified = " + t.toString() | ||||
+ ((remoteTimestamp == 0) | + ((remoteTimestamp == 0) | ||||
? " - using current time instead" | ? " - using current time instead" | ||||
@@ -24,10 +24,13 @@ import java.io.FileOutputStream; | |||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.io.InputStream; | import java.io.InputStream; | ||||
import java.io.OutputStream; | import java.io.OutputStream; | ||||
import java.util.Enumeration; | |||||
import java.util.Collection; | |||||
import java.util.HashMap; | import java.util.HashMap; | ||||
import java.util.HashSet; | import java.util.HashSet; | ||||
import java.util.Iterator; | import java.util.Iterator; | ||||
import java.util.List; | |||||
import java.util.Map; | |||||
import java.util.Set; | |||||
import java.util.Vector; | import java.util.Vector; | ||||
import java.util.zip.GZIPOutputStream; | import java.util.zip.GZIPOutputStream; | ||||
@@ -68,31 +71,36 @@ public class Tar extends MatchingTask { | |||||
* Tar.WARN is deprecated and is replaced with | * Tar.WARN is deprecated and is replaced with | ||||
* Tar.TarLongFileMode.WARN | * Tar.TarLongFileMode.WARN | ||||
*/ | */ | ||||
public static final String WARN = "warn"; | |||||
@Deprecated | |||||
public static final String WARN = "warn"; | |||||
/** | /** | ||||
* @deprecated since 1.5.x. | * @deprecated since 1.5.x. | ||||
* Tar.FAIL is deprecated and is replaced with | * Tar.FAIL is deprecated and is replaced with | ||||
* Tar.TarLongFileMode.FAIL | * Tar.TarLongFileMode.FAIL | ||||
*/ | */ | ||||
public static final String FAIL = "fail"; | |||||
@Deprecated | |||||
public static final String FAIL = "fail"; | |||||
/** | /** | ||||
* @deprecated since 1.5.x. | * @deprecated since 1.5.x. | ||||
* Tar.TRUNCATE is deprecated and is replaced with | * Tar.TRUNCATE is deprecated and is replaced with | ||||
* Tar.TarLongFileMode.TRUNCATE | * Tar.TarLongFileMode.TRUNCATE | ||||
*/ | */ | ||||
public static final String TRUNCATE = "truncate"; | |||||
@Deprecated | |||||
public static final String TRUNCATE = "truncate"; | |||||
/** | /** | ||||
* @deprecated since 1.5.x. | * @deprecated since 1.5.x. | ||||
* Tar.GNU is deprecated and is replaced with | * Tar.GNU is deprecated and is replaced with | ||||
* Tar.TarLongFileMode.GNU | * Tar.TarLongFileMode.GNU | ||||
*/ | */ | ||||
public static final String GNU = "gnu"; | |||||
@Deprecated | |||||
public static final String GNU = "gnu"; | |||||
/** | /** | ||||
* @deprecated since 1.5.x. | * @deprecated since 1.5.x. | ||||
* Tar.OMIT is deprecated and is replaced with | * Tar.OMIT is deprecated and is replaced with | ||||
* Tar.TarLongFileMode.OMIT | * Tar.TarLongFileMode.OMIT | ||||
*/ | */ | ||||
public static final String OMIT = "omit"; | |||||
@Deprecated | |||||
public static final String OMIT = "omit"; | |||||
// CheckStyle:VisibilityModifier OFF - bc | // CheckStyle:VisibilityModifier OFF - bc | ||||
File tarFile; | File tarFile; | ||||
@@ -101,12 +109,10 @@ public class Tar extends MatchingTask { | |||||
private TarLongFileMode longFileMode = new TarLongFileMode(); | private TarLongFileMode longFileMode = new TarLongFileMode(); | ||||
// need to keep the package private version for backwards compatibility | // need to keep the package private version for backwards compatibility | ||||
Vector filesets = new Vector(); | |||||
Vector<TarFileSet> filesets = new Vector<TarFileSet>(); | |||||
// we must keep two lists since other classes may modify the | // we must keep two lists since other classes may modify the | ||||
// filesets Vector (it is package private) without us noticing | // filesets Vector (it is package private) without us noticing | ||||
private Vector resourceCollections = new Vector(); | |||||
Vector fileSetFiles = new Vector(); | |||||
private final Vector<ResourceCollection> resourceCollections = new Vector<ResourceCollection>(); | |||||
// CheckStyle:VisibilityModifier ON | // CheckStyle:VisibilityModifier ON | ||||
@@ -122,7 +128,7 @@ public class Tar extends MatchingTask { | |||||
* @return the tar fileset to be used as the nested element. | * @return the tar fileset to be used as the nested element. | ||||
*/ | */ | ||||
public TarFileSet createTarFileSet() { | public TarFileSet createTarFileSet() { | ||||
TarFileSet fs = new TarFileSet(); | |||||
final TarFileSet fs = new TarFileSet(); | |||||
fs.setProject(getProject()); | fs.setProject(getProject()); | ||||
filesets.addElement(fs); | filesets.addElement(fs); | ||||
return fs; | return fs; | ||||
@@ -133,7 +139,7 @@ public class Tar extends MatchingTask { | |||||
* @param res a resource collection to archive. | * @param res a resource collection to archive. | ||||
* @since Ant 1.7 | * @since Ant 1.7 | ||||
*/ | */ | ||||
public void add(ResourceCollection res) { | |||||
public void add(final ResourceCollection res) { | |||||
resourceCollections.add(res); | resourceCollections.add(res); | ||||
} | } | ||||
@@ -143,7 +149,8 @@ public class Tar extends MatchingTask { | |||||
* @deprecated since 1.5.x. | * @deprecated since 1.5.x. | ||||
* For consistency with other tasks, please use setDestFile(). | * For consistency with other tasks, please use setDestFile(). | ||||
*/ | */ | ||||
public void setTarfile(File tarFile) { | |||||
@Deprecated | |||||
public void setTarfile(final File tarFile) { | |||||
this.tarFile = tarFile; | this.tarFile = tarFile; | ||||
} | } | ||||
@@ -152,7 +159,7 @@ public class Tar extends MatchingTask { | |||||
* @since Ant 1.5 | * @since Ant 1.5 | ||||
* @param destFile The output of the tar | * @param destFile The output of the tar | ||||
*/ | */ | ||||
public void setDestFile(File destFile) { | |||||
public void setDestFile(final File destFile) { | |||||
this.tarFile = 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. | * This is the base directory to look in for things to tar. | ||||
* @param baseDir the base directory. | * @param baseDir the base directory. | ||||
*/ | */ | ||||
public void setBasedir(File baseDir) { | |||||
public void setBasedir(final File baseDir) { | |||||
this.baseDir = baseDir; | this.baseDir = baseDir; | ||||
} | } | ||||
@@ -183,7 +190,8 @@ public class Tar extends MatchingTask { | |||||
* mechanism do the work and also to encapsulate operations on | * mechanism do the work and also to encapsulate operations on | ||||
* the mode in its own class. | * 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." | log("DEPRECATED - The setLongfile(String) method has been deprecated." | ||||
+ " Use setLongfile(Tar.TarLongFileMode) instead."); | + " Use setLongfile(Tar.TarLongFileMode) instead."); | ||||
this.longFileMode = new TarLongFileMode(); | this.longFileMode = new TarLongFileMode(); | ||||
@@ -205,7 +213,7 @@ public class Tar extends MatchingTask { | |||||
* </ul> | * </ul> | ||||
* @param mode the mode to handle long file names. | * @param mode the mode to handle long file names. | ||||
*/ | */ | ||||
public void setLongfile(TarLongFileMode mode) { | |||||
public void setLongfile(final TarLongFileMode mode) { | |||||
this.longFileMode = mode; | this.longFileMode = mode; | ||||
} | } | ||||
@@ -219,7 +227,7 @@ public class Tar extends MatchingTask { | |||||
* </ul> | * </ul> | ||||
* @param mode the compression method. | * @param mode the compression method. | ||||
*/ | */ | ||||
public void setCompression(TarCompressionMethod mode) { | |||||
public void setCompression(final TarCompressionMethod mode) { | |||||
this.compression = mode; | this.compression = mode; | ||||
} | } | ||||
@@ -227,7 +235,8 @@ public class Tar extends MatchingTask { | |||||
* do the business | * do the business | ||||
* @throws BuildException on error | * @throws BuildException on error | ||||
*/ | */ | ||||
public void execute() throws BuildException { | |||||
@Override | |||||
public void execute() throws BuildException { | |||||
if (tarFile == null) { | if (tarFile == null) { | ||||
throw new BuildException("tarfile attribute must be set!", | throw new BuildException("tarfile attribute must be set!", | ||||
getLocation()); | getLocation()); | ||||
@@ -243,7 +252,8 @@ public class Tar extends MatchingTask { | |||||
getLocation()); | getLocation()); | ||||
} | } | ||||
Vector savedFileSets = (Vector) filesets.clone(); | |||||
@SuppressWarnings("unchecked") | |||||
final Vector<TarFileSet> savedFileSets = (Vector<TarFileSet>) filesets.clone(); | |||||
try { | try { | ||||
if (baseDir != null) { | if (baseDir != null) { | ||||
if (!baseDir.exists()) { | if (!baseDir.exists()) { | ||||
@@ -252,7 +262,7 @@ public class Tar extends MatchingTask { | |||||
} | } | ||||
// add the main fileset to the list of filesets to process. | // 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); | mainFileSet.setDir(baseDir); | ||||
filesets.addElement(mainFileSet); | filesets.addElement(mainFileSet); | ||||
} | } | ||||
@@ -267,12 +277,11 @@ public class Tar extends MatchingTask { | |||||
// check if tar is out of date with respect to each | // check if tar is out of date with respect to each | ||||
// fileset | // fileset | ||||
boolean upToDate = true; | 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) { | if (upToDate) { | ||||
@@ -281,7 +290,7 @@ public class Tar extends MatchingTask { | |||||
return; | return; | ||||
} | } | ||||
File parent = tarFile.getParentFile(); | |||||
final File parent = tarFile.getParentFile(); | |||||
if (parent != null && !parent.isDirectory() | if (parent != null && !parent.isDirectory() | ||||
&& !(parent.mkdirs() || parent.isDirectory())) { | && !(parent.mkdirs() || parent.isDirectory())) { | ||||
throw new BuildException("Failed to create missing parent" | throw new BuildException("Failed to create missing parent" | ||||
@@ -310,16 +319,14 @@ public class Tar extends MatchingTask { | |||||
} | } | ||||
longWarningGiven = false; | 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()); | throw new BuildException(msg, ioe, getLocation()); | ||||
} finally { | } finally { | ||||
FileUtils.close(tOut); | FileUtils.close(tOut); | ||||
@@ -337,8 +344,8 @@ public class Tar extends MatchingTask { | |||||
* @param tarFileSet the fileset that the file came from. | * @param tarFileSet the fileset that the file came from. | ||||
* @throws IOException on error | * @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 { | throws IOException { | ||||
if (file.equals(tarFile)) { | if (file.equals(tarFile)) { | ||||
// If the archive is built for the first time and it is | // 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 | * @throws IOException on error | ||||
* @since Ant 1.7 | * @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 { | throws IOException { | ||||
if (!r.isExists()) { | if (!r.isExists()) { | ||||
@@ -375,7 +382,7 @@ public class Tar extends MatchingTask { | |||||
boolean preserveLeadingSlashes = false; | boolean preserveLeadingSlashes = false; | ||||
if (tarFileSet != null) { | if (tarFileSet != null) { | ||||
String fullpath = tarFileSet.getFullpath(this.getProject()); | |||||
final String fullpath = tarFileSet.getFullpath(this.getProject()); | |||||
if (fullpath.length() > 0) { | if (fullpath.length() > 0) { | ||||
vPath = fullpath; | vPath = fullpath; | ||||
} else { | } else { | ||||
@@ -395,7 +402,7 @@ public class Tar extends MatchingTask { | |||||
preserveLeadingSlashes = tarFileSet.getPreserveLeadingSlashes(); | preserveLeadingSlashes = tarFileSet.getPreserveLeadingSlashes(); | ||||
if (vPath.startsWith("/") && !preserveLeadingSlashes) { | if (vPath.startsWith("/") && !preserveLeadingSlashes) { | ||||
int l = vPath.length(); | |||||
final int l = vPath.length(); | |||||
if (l <= 1) { | if (l <= 1) { | ||||
// we would end up adding "" to the archive | // we would end up adding "" to the archive | ||||
return; | 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()); | te.setModTime(r.getLastModified()); | ||||
// preserve permissions | // preserve permissions | ||||
if (r instanceof ArchiveResource) { | if (r instanceof ArchiveResource) { | ||||
ArchiveResource ar = (ArchiveResource) r; | |||||
final ArchiveResource ar = (ArchiveResource) r; | |||||
te.setMode(ar.getMode()); | te.setMode(ar.getMode()); | ||||
if (r instanceof TarResource) { | if (r instanceof TarResource) { | ||||
TarResource tr = (TarResource) r; | |||||
final TarResource tr = (TarResource) r; | |||||
te.setUserName(tr.getUserName()); | te.setUserName(tr.getUserName()); | ||||
te.setUserId(tr.getUid()); | te.setUserId(tr.getUid()); | ||||
te.setGroupName(tr.getGroup()); | te.setGroupName(tr.getGroup()); | ||||
@@ -483,7 +490,7 @@ public class Tar extends MatchingTask { | |||||
if (!r.isDirectory()) { | if (!r.isDirectory()) { | ||||
in = r.getInputStream(); | in = r.getInputStream(); | ||||
byte[] buffer = new byte[BUFFER_SIZE]; | |||||
final byte[] buffer = new byte[BUFFER_SIZE]; | |||||
int count = 0; | int count = 0; | ||||
do { | do { | ||||
tOut.write(buffer, 0, count); | tOut.write(buffer, 0, count); | ||||
@@ -504,7 +511,8 @@ public class Tar extends MatchingTask { | |||||
* @deprecated since 1.5.x. | * @deprecated since 1.5.x. | ||||
* use the two-arg version instead. | * use the two-arg version instead. | ||||
*/ | */ | ||||
protected boolean archiveIsUpToDate(String[] files) { | |||||
@Deprecated | |||||
protected boolean archiveIsUpToDate(final String[] files) { | |||||
return archiveIsUpToDate(files, baseDir); | return archiveIsUpToDate(files, baseDir); | ||||
} | } | ||||
@@ -515,9 +523,9 @@ public class Tar extends MatchingTask { | |||||
* @return true if the archive is up to date. | * @return true if the archive is up to date. | ||||
* @since Ant 1.5.2 | * @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()); | mm.setTo(tarFile.getAbsolutePath()); | ||||
return sfs.restrict(files, dir, null, mm).length == 0; | 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. | * @return true if the archive is up to date. | ||||
* @since Ant 1.7 | * @since Ant 1.7 | ||||
*/ | */ | ||||
protected boolean archiveIsUpToDate(Resource r) { | |||||
protected boolean archiveIsUpToDate(final Resource r) { | |||||
return SelectorUtils.isOutOfDate(new FileResource(tarFile), r, | return SelectorUtils.isOutOfDate(new FileResource(tarFile), r, | ||||
FileUtils.getFileUtils() | FileUtils.getFileUtils() | ||||
.getFileTimestampGranularity()); | .getFileTimestampGranularity()); | ||||
@@ -563,27 +571,27 @@ public class Tar extends MatchingTask { | |||||
* @return whether the archive is up-to-date | * @return whether the archive is up-to-date | ||||
* @since Ant 1.7 | * @since Ant 1.7 | ||||
*/ | */ | ||||
protected boolean check(ResourceCollection rc) { | |||||
protected boolean check(final ResourceCollection rc) { | |||||
boolean upToDate = true; | boolean upToDate = true; | ||||
if (isFileFileSet(rc)) { | if (isFileFileSet(rc)) { | ||||
FileSet fs = (FileSet) rc; | |||||
final FileSet fs = (FileSet) rc; | |||||
upToDate = check(fs.getDir(getProject()), getFileNames(fs)); | upToDate = check(fs.getDir(getProject()), getFileNames(fs)); | ||||
} else if (!rc.isFilesystemOnly() && !supportsNonFileResources()) { | } else if (!rc.isFilesystemOnly() && !supportsNonFileResources()) { | ||||
throw new BuildException("only filesystem resources are supported"); | throw new BuildException("only filesystem resources are supported"); | ||||
} else if (rc.isFilesystemOnly()) { | } else if (rc.isFilesystemOnly()) { | ||||
HashSet basedirs = new HashSet(); | |||||
HashMap basedirToFilesMap = new HashMap(); | |||||
for (Resource res : rc) { | |||||
FileResource r = ResourceUtils | |||||
final Set<File> basedirs = new HashSet<File>(); | |||||
final Map<File, List<String>> basedirToFilesMap = new HashMap<File, List<String>>(); | |||||
for (final Resource res : rc) { | |||||
final FileResource r = ResourceUtils | |||||
.asFileResource(res.as(FileProvider.class)); | .asFileResource(res.as(FileProvider.class)); | ||||
File base = r.getBaseDir(); | File base = r.getBaseDir(); | ||||
if (base == null) { | if (base == null) { | ||||
base = Copy.NULL_FILE_PLACEHOLDER; | base = Copy.NULL_FILE_PLACEHOLDER; | ||||
} | } | ||||
basedirs.add(base); | basedirs.add(base); | ||||
Vector files = (Vector) basedirToFilesMap.get(base); | |||||
List<String> files = basedirToFilesMap.get(base); | |||||
if (files == null) { | if (files == null) { | ||||
files = new Vector(); | |||||
files = new Vector<String>(); | |||||
basedirToFilesMap.put(base, files); | basedirToFilesMap.put(base, files); | ||||
} | } | ||||
if (base == Copy.NULL_FILE_PLACEHOLDER) { | if (base == Copy.NULL_FILE_PLACEHOLDER) { | ||||
@@ -592,19 +600,15 @@ public class Tar extends MatchingTask { | |||||
files.add(r.getName()); | 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<String> files = basedirToFilesMap.get(base); | |||||
check(tmpBase, files); | |||||
} | } | ||||
} else { // non-file resources | } else { // non-file resources | ||||
Iterator<Resource> iter = rc.iterator(); | |||||
final Iterator<Resource> iter = rc.iterator(); | |||||
while (upToDate && iter.hasNext()) { | while (upToDate && iter.hasNext()) { | ||||
Resource r = iter.next(); | |||||
final Resource r = iter.next(); | |||||
upToDate = archiveIsUpToDate(r); | upToDate = archiveIsUpToDate(r); | ||||
} | } | ||||
} | } | ||||
@@ -620,7 +624,7 @@ public class Tar extends MatchingTask { | |||||
* @return whether the archive is up-to-date | * @return whether the archive is up-to-date | ||||
* @since Ant 1.7 | * @since Ant 1.7 | ||||
*/ | */ | ||||
protected boolean check(File basedir, String[] files) { | |||||
protected boolean check(final File basedir, final String[] files) { | |||||
boolean upToDate = true; | boolean upToDate = true; | ||||
if (!archiveIsUpToDate(files, basedir)) { | if (!archiveIsUpToDate(files, basedir)) { | ||||
upToDate = false; | upToDate = false; | ||||
@@ -635,6 +639,20 @@ public class Tar extends MatchingTask { | |||||
return upToDate; | return upToDate; | ||||
} | } | ||||
/** | |||||
* <p>Checks whether the archive is out-of-date with respect to the | |||||
* given files, ensures that the archive won't contain itself.</p> | |||||
* | |||||
* @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<String> files) { | |||||
return check(basedir, files.toArray(new String[files.size()])); | |||||
} | |||||
/** | /** | ||||
* Adds the resources contained in this collection to the archive. | * Adds the resources contained in this collection to the archive. | ||||
* | * | ||||
@@ -646,7 +664,7 @@ public class Tar extends MatchingTask { | |||||
* @throws IOException on error. | * @throws IOException on error. | ||||
* @since Ant 1.7 | * @since Ant 1.7 | ||||
*/ | */ | ||||
protected void tar(ResourceCollection rc, TarOutputStream tOut) | |||||
protected void tar(final ResourceCollection rc, final TarOutputStream tOut) | |||||
throws IOException { | throws IOException { | ||||
ArchiveFileSet afs = null; | ArchiveFileSet afs = null; | ||||
if (rc instanceof ArchiveFileSet) { | if (rc instanceof ArchiveFileSet) { | ||||
@@ -659,23 +677,23 @@ public class Tar extends MatchingTask { | |||||
+ "filesets that specify a " | + "filesets that specify a " | ||||
+ "single file."); | + "single file."); | ||||
} | } | ||||
TarFileSet tfs = asTarFileSet(afs); | |||||
final TarFileSet tfs = asTarFileSet(afs); | |||||
if (isFileFileSet(rc)) { | 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++) { | 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); | tarFile(f, tOut, name, tfs); | ||||
} | } | ||||
} else if (rc.isFilesystemOnly()) { | } 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); | tarFile(f, tOut, f.getName(), tfs); | ||||
} | } | ||||
} else { // non-file resources | } else { // non-file resources | ||||
for (Resource r : rc) { | |||||
for (final Resource r : rc) { | |||||
tarResource(r, tOut, r.getName(), tfs); | tarResource(r, tOut, r.getName(), tfs); | ||||
} | } | ||||
} | } | ||||
@@ -688,7 +706,7 @@ public class Tar extends MatchingTask { | |||||
* @return true if the collection is a fileset. | * @return true if the collection is a fileset. | ||||
* @since Ant 1.7 | * @since Ant 1.7 | ||||
*/ | */ | ||||
protected static boolean isFileFileSet(ResourceCollection rc) { | |||||
protected static boolean isFileFileSet(final ResourceCollection rc) { | |||||
return rc instanceof FileSet && rc.isFilesystemOnly(); | return rc instanceof FileSet && rc.isFilesystemOnly(); | ||||
} | } | ||||
@@ -699,11 +717,11 @@ public class Tar extends MatchingTask { | |||||
* @return a list of the filenames. | * @return a list of the filenames. | ||||
* @since Ant 1.7 | * @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(directories, 0, files, 0, directories.length); | ||||
System.arraycopy(filesPerSe, 0, files, directories.length, | System.arraycopy(filesPerSe, 0, files, directories.length, | ||||
filesPerSe.length); | filesPerSe.length); | ||||
@@ -719,7 +737,7 @@ public class Tar extends MatchingTask { | |||||
* @return a new TarFileSet. | * @return a new TarFileSet. | ||||
* @since Ant 1.7 | * @since Ant 1.7 | ||||
*/ | */ | ||||
protected TarFileSet asTarFileSet(ArchiveFileSet archiveFileSet) { | |||||
protected TarFileSet asTarFileSet(final ArchiveFileSet archiveFileSet) { | |||||
TarFileSet tfs = null; | TarFileSet tfs = null; | ||||
if (archiveFileSet != null && archiveFileSet instanceof TarFileSet) { | if (archiveFileSet != null && archiveFileSet instanceof TarFileSet) { | ||||
tfs = (TarFileSet) archiveFileSet; | tfs = (TarFileSet) archiveFileSet; | ||||
@@ -740,7 +758,7 @@ public class Tar extends MatchingTask { | |||||
if (archiveFileSet | if (archiveFileSet | ||||
instanceof org.apache.tools.ant.types.TarFileSet) { | 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; | (org.apache.tools.ant.types.TarFileSet) archiveFileSet; | ||||
if (t.hasUserNameBeenSet()) { | if (t.hasUserNameBeenSet()) { | ||||
tfs.setUserName(t.getUserName()); | tfs.setUserName(t.getUserName()); | ||||
@@ -776,7 +794,7 @@ public class Tar extends MatchingTask { | |||||
* | * | ||||
* @param fileset a <code>FileSet</code> value | * @param fileset a <code>FileSet</code> value | ||||
*/ | */ | ||||
public TarFileSet(FileSet fileset) { | |||||
public TarFileSet(final FileSet fileset) { | |||||
super(fileset); | super(fileset); | ||||
} | } | ||||
@@ -794,7 +812,7 @@ public class Tar extends MatchingTask { | |||||
* @return a list of file and directory names, relative to | * @return a list of file and directory names, relative to | ||||
* the baseDir for the project. | * the baseDir for the project. | ||||
*/ | */ | ||||
public String[] getFiles(Project p) { | |||||
public String[] getFiles(final Project p) { | |||||
if (files == null) { | if (files == null) { | ||||
files = getFileNames(this); | files = getFileNames(this); | ||||
} | } | ||||
@@ -808,7 +826,7 @@ public class Tar extends MatchingTask { | |||||
* optional, default=0644 | * optional, default=0644 | ||||
* @param octalString a 3 digit octal string. | * @param octalString a 3 digit octal string. | ||||
*/ | */ | ||||
public void setMode(String octalString) { | |||||
public void setMode(final String octalString) { | |||||
setFileMode(octalString); | setFileMode(octalString); | ||||
} | } | ||||
@@ -825,7 +843,7 @@ public class Tar extends MatchingTask { | |||||
* Optional, default is <code>false</code>. | * Optional, default is <code>false</code>. | ||||
* @param b the leading slashes flag. | * @param b the leading slashes flag. | ||||
*/ | */ | ||||
public void setPreserveLeadingSlashes(boolean b) { | |||||
public void setPreserveLeadingSlashes(final boolean b) { | |||||
this.preserveLeadingSlashes = b; | this.preserveLeadingSlashes = b; | ||||
} | } | ||||
@@ -865,7 +883,8 @@ public class Tar extends MatchingTask { | |||||
/** | /** | ||||
* @return the possible values for this enumerated type. | * @return the possible values for this enumerated type. | ||||
*/ | */ | ||||
public String[] getValues() { | |||||
@Override | |||||
public String[] getValues() { | |||||
return validModes; | return validModes; | ||||
} | } | ||||
@@ -945,7 +964,8 @@ public class Tar extends MatchingTask { | |||||
* Get valid enumeration values. | * Get valid enumeration values. | ||||
* @return valid enumeration values | * @return valid enumeration values | ||||
*/ | */ | ||||
public String[] getValues() { | |||||
@Override | |||||
public String[] getValues() { | |||||
return new String[] {NONE, GZIP, BZIP2 }; | return new String[] {NONE, GZIP, BZIP2 }; | ||||
} | } | ||||
@@ -90,7 +90,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
private String fileDirParameter = null; | private String fileDirParameter = null; | ||||
/** additional parameters to be passed to the stylesheets */ | /** additional parameters to be passed to the stylesheets */ | ||||
private List<Param> params = new ArrayList<Param>(); | |||||
private final List<Param> params = new ArrayList<Param>(); | |||||
/** Input XML document to be used */ | /** Input XML document to be used */ | ||||
private File inFile = null; | private File inFile = null; | ||||
@@ -116,10 +116,10 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
private boolean force = false; | private boolean force = false; | ||||
/** XSL output properties to be used */ | /** XSL output properties to be used */ | ||||
private Vector outputProperties = new Vector(); | |||||
private final Vector outputProperties = new Vector(); | |||||
/** for resolving entities such as dtds */ | /** for resolving entities such as dtds */ | ||||
private XMLCatalog xmlCatalog = new XMLCatalog(); | |||||
private final XMLCatalog xmlCatalog = new XMLCatalog(); | |||||
/** Utilities used for file operations */ | /** Utilities used for file operations */ | ||||
private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | ||||
@@ -167,7 +167,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* | * | ||||
* @since Ant 1.7 | * @since Ant 1.7 | ||||
*/ | */ | ||||
private Union resources = new Union(); | |||||
private final Union resources = new Union(); | |||||
/** | /** | ||||
* Whether to use the implicit fileset. | * Whether to use the implicit fileset. | ||||
@@ -229,7 +229,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* | * | ||||
* @since Ant 1.8.0 | * @since Ant 1.8.0 | ||||
*/ | */ | ||||
private CommandlineJava.SysProperties sysProperties = | |||||
private final CommandlineJava.SysProperties sysProperties = | |||||
new CommandlineJava.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. | * @param b true if files in included directories are processed. | ||||
* @since Ant 1.5 | * @since Ant 1.5 | ||||
*/ | */ | ||||
public void setScanIncludedDirectories(boolean b) { | |||||
public void setScanIncludedDirectories(final boolean b) { | |||||
performDirectoryScan = b; | performDirectoryScan = b; | ||||
} | } | ||||
@@ -264,7 +264,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* @param b a <code>boolean</code> value | * @param b a <code>boolean</code> value | ||||
* @since Ant 1.5.2 | * @since Ant 1.5.2 | ||||
*/ | */ | ||||
public void setReloadStylesheet(boolean b) { | |||||
public void setReloadStylesheet(final boolean b) { | |||||
reuseLoadedStylesheet = !b; | reuseLoadedStylesheet = !b; | ||||
} | } | ||||
@@ -274,7 +274,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* @exception BuildException if more than one mapper is defined | * @exception BuildException if more than one mapper is defined | ||||
* @since Ant 1.6.2 | * @since Ant 1.6.2 | ||||
*/ | */ | ||||
public void addMapper(Mapper mapper) { | |||||
public void addMapper(final Mapper mapper) { | |||||
if (mapperElement != null) { | if (mapperElement != null) { | ||||
handleError("Cannot define more than one mapper"); | handleError("Cannot define more than one mapper"); | ||||
} else { | } else { | ||||
@@ -289,7 +289,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* @param rc the collection of resources to style | * @param rc the collection of resources to style | ||||
* @since Ant 1.7 | * @since Ant 1.7 | ||||
*/ | */ | ||||
public void add(ResourceCollection rc) { | |||||
public void add(final ResourceCollection rc) { | |||||
resources.add(rc); | resources.add(rc); | ||||
} | } | ||||
@@ -298,7 +298,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* @param rc the configured Resources object represented as <style>. | * @param rc the configured Resources object represented as <style>. | ||||
* @since Ant 1.7 | * @since Ant 1.7 | ||||
*/ | */ | ||||
public void addConfiguredStyle(Resources rc) { | |||||
public void addConfiguredStyle(final Resources rc) { | |||||
if (rc.size() != 1) { | if (rc.size() != 1) { | ||||
handleError("The style element must be specified with exactly one" | handleError("The style element must be specified with exactly one" | ||||
+ " nested resource."); | + " nested resource."); | ||||
@@ -312,7 +312,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* @param xslResource Resource to set as the stylesheet. | * @param xslResource Resource to set as the stylesheet. | ||||
* @since Ant 1.7 | * @since Ant 1.7 | ||||
*/ | */ | ||||
public void setXslResource(Resource xslResource) { | |||||
public void setXslResource(final Resource xslResource) { | |||||
this.xslResource = xslResource; | this.xslResource = xslResource; | ||||
} | } | ||||
@@ -322,8 +322,8 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* @exception BuildException if more than one mapper is defined | * @exception BuildException if more than one mapper is defined | ||||
* @since Ant 1.7.0 | * @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); | mapper.add(fileNameMapper); | ||||
addMapper(mapper); | addMapper(mapper); | ||||
} | } | ||||
@@ -340,13 +340,13 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
log("Warning: the task name <style> is deprecated. Use <xslt> instead.", | log("Warning: the task name <style> is deprecated. Use <xslt> instead.", | ||||
Project.MSG_WARN); | Project.MSG_WARN); | ||||
} | } | ||||
File savedBaseDir = baseDir; | |||||
final File savedBaseDir = baseDir; | |||||
DirectoryScanner scanner; | DirectoryScanner scanner; | ||||
String[] list; | String[] list; | ||||
String[] dirs; | String[] dirs; | ||||
String baseMessage = | |||||
final String baseMessage = | |||||
"specify the stylesheet either as a filename in style attribute " | "specify the stylesheet either as a filename in style attribute " | ||||
+ "or as a nested resource"; | + "or as a nested resource"; | ||||
@@ -386,7 +386,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
// via style attribute | // via style attribute | ||||
File stylesheet = getProject().resolveFile(xslFile); | File stylesheet = getProject().resolveFile(xslFile); | ||||
if (!stylesheet.exists()) { | if (!stylesheet.exists()) { | ||||
File alternative = FILE_UTILS.resolveFile(baseDir, xslFile); | |||||
final File alternative = FILE_UTILS.resolveFile(baseDir, xslFile); | |||||
/* | /* | ||||
* shouldn't throw out deprecation warnings before we know, | * shouldn't throw out deprecation warnings before we know, | ||||
* the wrong version has been used. | * the wrong version has been used. | ||||
@@ -398,7 +398,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
stylesheet = alternative; | stylesheet = alternative; | ||||
} | } | ||||
} | } | ||||
FileResource fr = new FileResource(); | |||||
final FileResource fr = new FileResource(); | |||||
fr.setProject(getProject()); | fr.setProject(getProject()); | ||||
fr.setFile(stylesheet); | fr.setFile(stylesheet); | ||||
styleResource = fr; | styleResource = fr; | ||||
@@ -474,7 +474,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* | * | ||||
* @param force true if always generate. | * @param force true if always generate. | ||||
*/ | */ | ||||
public void setForce(boolean force) { | |||||
public void setForce(final boolean force) { | |||||
this.force = force; | this.force = force; | ||||
} | } | ||||
@@ -484,7 +484,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* | * | ||||
* @param dir the base directory | * @param dir the base directory | ||||
**/ | **/ | ||||
public void setBasedir(File dir) { | |||||
public void setBasedir(final File dir) { | |||||
baseDir = dir; | baseDir = dir; | ||||
} | } | ||||
@@ -495,7 +495,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* specified. | * specified. | ||||
* @param dir the name of the destination directory | * @param dir the name of the destination directory | ||||
**/ | **/ | ||||
public void setDestdir(File dir) { | |||||
public void setDestdir(final File dir) { | |||||
destDir = dir; | destDir = dir; | ||||
} | } | ||||
@@ -504,7 +504,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* optional, default is html. | * optional, default is html. | ||||
* @param name the extension to use | * @param name the extension to use | ||||
**/ | **/ | ||||
public void setExtension(String name) { | |||||
public void setExtension(final String name) { | |||||
targetExtension = name; | targetExtension = name; | ||||
} | } | ||||
@@ -514,7 +514,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* | * | ||||
* @param xslFile the stylesheet to use | * @param xslFile the stylesheet to use | ||||
*/ | */ | ||||
public void setStyle(String xslFile) { | |||||
public void setStyle(final String xslFile) { | |||||
this.xslFile = xslFile; | this.xslFile = xslFile; | ||||
} | } | ||||
@@ -523,7 +523,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* | * | ||||
* @param classpath the classpath to use when loading the XSL processor | * @param classpath the classpath to use when loading the XSL processor | ||||
*/ | */ | ||||
public void setClasspath(Path classpath) { | |||||
public void setClasspath(final Path classpath) { | |||||
createClasspath().append(classpath); | createClasspath().append(classpath); | ||||
} | } | ||||
@@ -545,7 +545,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* @param r the id of the Ant path instance to act as the classpath | * @param r the id of the Ant path instance to act as the classpath | ||||
* for loading the XSL processor | * for loading the XSL processor | ||||
*/ | */ | ||||
public void setClasspathRef(Reference r) { | |||||
public void setClasspathRef(final Reference r) { | |||||
createClasspath().setRefid(r); | createClasspath().setRefid(r); | ||||
} | } | ||||
@@ -554,7 +554,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* | * | ||||
* @param processor the name of the XSL processor | * @param processor the name of the XSL processor | ||||
*/ | */ | ||||
public void setProcessor(String processor) { | |||||
public void setProcessor(final String processor) { | |||||
this.processor = processor; | this.processor = processor; | ||||
} | } | ||||
@@ -566,7 +566,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* @param useimplicitfileset set to true if you want to use implicit fileset | * @param useimplicitfileset set to true if you want to use implicit fileset | ||||
* @since Ant 1.7 | * @since Ant 1.7 | ||||
*/ | */ | ||||
public void setUseImplicitFileset(boolean useimplicitfileset) { | |||||
public void setUseImplicitFileset(final boolean useimplicitfileset) { | |||||
useImplicitFileset = useimplicitfileset; | useImplicitFileset = useimplicitfileset; | ||||
} | } | ||||
@@ -575,7 +575,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* | * | ||||
* @param xmlCatalog the XMLCatalog instance to use to look up DTDs | * @param xmlCatalog the XMLCatalog instance to use to look up DTDs | ||||
*/ | */ | ||||
public void addConfiguredXMLCatalog(XMLCatalog xmlCatalog) { | |||||
public void addConfiguredXMLCatalog(final XMLCatalog xmlCatalog) { | |||||
this.xmlCatalog.addConfiguredXMLCatalog(xmlCatalog); | this.xmlCatalog.addConfiguredXMLCatalog(xmlCatalog); | ||||
} | } | ||||
@@ -586,7 +586,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* @param fileNameParameter name of the xsl parameter retrieving the | * @param fileNameParameter name of the xsl parameter retrieving the | ||||
* current file name | * current file name | ||||
*/ | */ | ||||
public void setFileNameParameter(String fileNameParameter) { | |||||
public void setFileNameParameter(final String fileNameParameter) { | |||||
this.fileNameParameter = fileNameParameter; | this.fileNameParameter = fileNameParameter; | ||||
} | } | ||||
@@ -597,7 +597,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* @param fileDirParameter name of the xsl parameter retrieving the | * @param fileDirParameter name of the xsl parameter retrieving the | ||||
* current file directory | * current file directory | ||||
*/ | */ | ||||
public void setFileDirParameter(String fileDirParameter) { | |||||
public void setFileDirParameter(final String fileDirParameter) { | |||||
this.fileDirParameter = fileDirParameter; | this.fileDirParameter = fileDirParameter; | ||||
} | } | ||||
@@ -606,7 +606,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* | * | ||||
* @since Ant 1.8.0 | * @since Ant 1.8.0 | ||||
*/ | */ | ||||
public void setSuppressWarnings(boolean b) { | |||||
public void setSuppressWarnings(final boolean b) { | |||||
suppressWarnings = b; | suppressWarnings = b; | ||||
} | } | ||||
@@ -624,7 +624,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* | * | ||||
* @since Ant 1.8.0 | * @since Ant 1.8.0 | ||||
*/ | */ | ||||
public void setFailOnTransformationError(boolean b) { | |||||
public void setFailOnTransformationError(final boolean b) { | |||||
failOnTransformationError = b; | failOnTransformationError = b; | ||||
} | } | ||||
@@ -633,7 +633,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* | * | ||||
* @since Ant 1.8.0 | * @since Ant 1.8.0 | ||||
*/ | */ | ||||
public void setFailOnError(boolean b) { | |||||
public void setFailOnError(final boolean b) { | |||||
failOnError = b; | failOnError = b; | ||||
} | } | ||||
@@ -642,7 +642,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* | * | ||||
* @since Ant 1.8.0 | * @since Ant 1.8.0 | ||||
*/ | */ | ||||
public void setFailOnNoResources(boolean b) { | |||||
public void setFailOnNoResources(final boolean b) { | |||||
failOnNoResources = b; | failOnNoResources = b; | ||||
} | } | ||||
@@ -651,7 +651,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* | * | ||||
* @since Ant 1.8.0 | * @since Ant 1.8.0 | ||||
*/ | */ | ||||
public void addSysproperty(Environment.Variable sysp) { | |||||
public void addSysproperty(final Environment.Variable sysp) { | |||||
sysProperties.addVariable(sysp); | sysProperties.addVariable(sysp); | ||||
} | } | ||||
@@ -660,7 +660,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* | * | ||||
* @since Ant 1.8.0 | * @since Ant 1.8.0 | ||||
*/ | */ | ||||
public void addSyspropertyset(PropertySet sysp) { | |||||
public void addSyspropertyset(final PropertySet sysp) { | |||||
sysProperties.addSyspropertyset(sysp); | sysProperties.addSyspropertyset(sysp); | ||||
} | } | ||||
@@ -699,12 +699,12 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* @param proc the name of the processor to load. | * @param proc the name of the processor to load. | ||||
* @exception Exception if the processor cannot be loaded. | * @exception Exception if the processor cannot be loaded. | ||||
*/ | */ | ||||
private void resolveProcessor(String proc) throws Exception { | |||||
private void resolveProcessor(final String proc) throws Exception { | |||||
if (proc.equals(PROCESSOR_TRAX)) { | if (proc.equals(PROCESSOR_TRAX)) { | ||||
liaison = new org.apache.tools.ant.taskdefs.optional.TraXLiaison(); | liaison = new org.apache.tools.ant.taskdefs.optional.TraXLiaison(); | ||||
} else { | } else { | ||||
//anything else is a classname | //anything else is a classname | ||||
Class clazz = loadClass(proc); | |||||
final Class clazz = loadClass(proc); | |||||
liaison = (XSLTLiaison) clazz.newInstance(); | liaison = (XSLTLiaison) clazz.newInstance(); | ||||
} | } | ||||
} | } | ||||
@@ -718,7 +718,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* @return the requested class. | * @return the requested class. | ||||
* @exception Exception if the class could not be loaded. | * @exception Exception if the class could not be loaded. | ||||
*/ | */ | ||||
private Class loadClass(String classname) throws Exception { | |||||
private Class loadClass(final String classname) throws Exception { | |||||
setupLoader(); | setupLoader(); | ||||
if (loader == null) { | if (loader == null) { | ||||
return Class.forName(classname); | return Class.forName(classname); | ||||
@@ -744,7 +744,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* | * | ||||
* @param outFile the output File instance. | * @param outFile the output File instance. | ||||
*/ | */ | ||||
public void setOut(File outFile) { | |||||
public void setOut(final File outFile) { | |||||
this.outFile = outFile; | this.outFile = outFile; | ||||
} | } | ||||
@@ -754,7 +754,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* | * | ||||
* @param inFile the input file | * @param inFile the input file | ||||
*/ | */ | ||||
public void setIn(File inFile) { | |||||
public void setIn(final File inFile) { | |||||
this.inFile = inFile; | this.inFile = inFile; | ||||
} | } | ||||
@@ -775,16 +775,16 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* @param stylesheet style sheet to use | * @param stylesheet style sheet to use | ||||
* @since Ant 1.7 | * @since Ant 1.7 | ||||
*/ | */ | ||||
private void processResources(Resource stylesheet) { | |||||
for (Resource r : resources) { | |||||
private void processResources(final Resource stylesheet) { | |||||
for (final Resource r : resources) { | |||||
if (!r.isExists()) { | if (!r.isExists()) { | ||||
continue; | continue; | ||||
} | } | ||||
File base = baseDir; | File base = baseDir; | ||||
String name = r.getName(); | String name = r.getName(); | ||||
FileProvider fp = r.as(FileProvider.class); | |||||
final FileProvider fp = r.as(FileProvider.class); | |||||
if (fp != null) { | if (fp != null) { | ||||
FileResource f = ResourceUtils.asFileResource(fp); | |||||
final FileResource f = ResourceUtils.asFileResource(fp); | |||||
base = f.getBaseDir(); | base = f.getBaseDir(); | ||||
if (base == null) { | if (base == null) { | ||||
name = f.getFile().getAbsolutePath(); | name = f.getFile().getAbsolutePath(); | ||||
@@ -804,14 +804,14 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* @param stylesheet the stylesheet to use. | * @param stylesheet the stylesheet to use. | ||||
* @exception BuildException if the processing fails. | * @exception BuildException if the processing fails. | ||||
*/ | */ | ||||
private void process(File baseDir, String xmlFile, File destDir, Resource stylesheet) | |||||
private void process(final File baseDir, final String xmlFile, final File destDir, final Resource stylesheet) | |||||
throws BuildException { | throws BuildException { | ||||
File outF = null; | File outF = null; | ||||
File inF = null; | File inF = null; | ||||
try { | try { | ||||
long styleSheetLastModified = stylesheet.getLastModified(); | |||||
final long styleSheetLastModified = stylesheet.getLastModified(); | |||||
inF = new File(baseDir, xmlFile); | inF = new File(baseDir, xmlFile); | ||||
if (inF.isDirectory()) { | if (inF.isDirectory()) { | ||||
@@ -825,7 +825,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
mapper = new StyleMapper(); | mapper = new StyleMapper(); | ||||
} | } | ||||
String[] outFileName = mapper.mapFileName(xmlFile); | |||||
final String[] outFileName = mapper.mapFileName(xmlFile); | |||||
if (outFileName == null || outFileName.length == 0) { | if (outFileName == null || outFileName.length == 0) { | ||||
log("Skipping " + inFile + " it cannot get mapped to output.", Project.MSG_VERBOSE); | log("Skipping " + inFile + " it cannot get mapped to output.", Project.MSG_VERBOSE); | ||||
return; | return; | ||||
@@ -843,7 +843,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
setLiaisonDynamicFileParameters(liaison, inF); | setLiaisonDynamicFileParameters(liaison, inF); | ||||
liaison.transform(inF, outF); | liaison.transform(inF, outF); | ||||
} | } | ||||
} catch (Exception ex) { | |||||
} catch (final Exception ex) { | |||||
// If failed to process document, must delete target document, | // If failed to process document, must delete target document, | ||||
// or it will not attempt to process it the second time | // or it will not attempt to process it the second time | ||||
log("Failed to process " + inFile, Project.MSG_INFO); | log("Failed to process " + inFile, Project.MSG_INFO); | ||||
@@ -863,9 +863,9 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* @param stylesheet the stylesheet to use. | * @param stylesheet the stylesheet to use. | ||||
* @exception BuildException if the processing fails. | * @exception BuildException if the processing fails. | ||||
*/ | */ | ||||
private void process(File inFile, File outFile, Resource stylesheet) throws BuildException { | |||||
private void process(final File inFile, final File outFile, final Resource stylesheet) throws BuildException { | |||||
try { | try { | ||||
long styleSheetLastModified = stylesheet.getLastModified(); | |||||
final long styleSheetLastModified = stylesheet.getLastModified(); | |||||
log("In file " + inFile + " time: " + inFile.lastModified(), Project.MSG_DEBUG); | log("In file " + inFile + " time: " + inFile.lastModified(), Project.MSG_DEBUG); | ||||
log("Out file " + outFile + " time: " + outFile.lastModified(), Project.MSG_DEBUG); | log("Out file " + outFile + " time: " + outFile.lastModified(), Project.MSG_DEBUG); | ||||
log("Style file " + xslFile + " time: " + styleSheetLastModified, Project.MSG_DEBUG); | log("Style file " + xslFile + " time: " + styleSheetLastModified, Project.MSG_DEBUG); | ||||
@@ -880,7 +880,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
log("Skipping input file " + inFile + " because it is older than output file " | log("Skipping input file " + inFile + " because it is older than output file " | ||||
+ outFile + " and so is the stylesheet " + stylesheet, Project.MSG_DEBUG); | + outFile + " and so is the stylesheet " + stylesheet, Project.MSG_DEBUG); | ||||
} | } | ||||
} catch (Exception ex) { | |||||
} catch (final Exception ex) { | |||||
log("Failed to process " + inFile, Project.MSG_INFO); | log("Failed to process " + inFile, Project.MSG_INFO); | ||||
if (outFile != null) { | if (outFile != null) { | ||||
outFile.delete(); | outFile.delete(); | ||||
@@ -895,8 +895,8 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* @param targetFile the file for which the directories are required. | * @param targetFile the file for which the directories are required. | ||||
* @exception BuildException if the directories cannot be created. | * @exception BuildException if the directories cannot be created. | ||||
*/ | */ | ||||
private void ensureDirectoryFor(File targetFile) throws BuildException { | |||||
File directory = targetFile.getParentFile(); | |||||
private void ensureDirectoryFor(final File targetFile) throws BuildException { | |||||
final File directory = targetFile.getParentFile(); | |||||
if (!directory.exists()) { | if (!directory.exists()) { | ||||
if (!(directory.mkdirs() || directory.isDirectory())) { | if (!(directory.mkdirs() || directory.isDirectory())) { | ||||
handleError("Unable to create directory: " | handleError("Unable to create directory: " | ||||
@@ -943,13 +943,13 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
if (processor != null) { | if (processor != null) { | ||||
try { | try { | ||||
resolveProcessor(processor); | resolveProcessor(processor); | ||||
} catch (Exception e) { | |||||
} catch (final Exception e) { | |||||
handleError(e); | handleError(e); | ||||
} | } | ||||
} else { | } else { | ||||
try { | try { | ||||
resolveProcessor(PROCESSOR_TRAX); | resolveProcessor(PROCESSOR_TRAX); | ||||
} catch (Throwable e1) { | |||||
} catch (final Throwable e1) { | |||||
e1.printStackTrace(); | e1.printStackTrace(); | ||||
handleError(e1); | handleError(e1); | ||||
} | } | ||||
@@ -964,7 +964,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* @return an instance of the Param class to be configured. | * @return an instance of the Param class to be configured. | ||||
*/ | */ | ||||
public Param createParam() { | public Param createParam() { | ||||
Param p = new Param(); | |||||
final Param p = new Param(); | |||||
params.add(p); | params.add(p); | ||||
return p; | return p; | ||||
} | } | ||||
@@ -994,7 +994,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* | * | ||||
* @param project the current project | * @param project the current project | ||||
*/ | */ | ||||
public void setProject(Project project) { | |||||
public void setProject(final Project project) { | |||||
this.project = project; | this.project = project; | ||||
} | } | ||||
@@ -1003,7 +1003,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* | * | ||||
* @param name the name of the parameter. | * @param name the name of the parameter. | ||||
*/ | */ | ||||
public void setName(String name) { | |||||
public void setName(final String name) { | |||||
this.name = name; | this.name = name; | ||||
} | } | ||||
@@ -1013,7 +1013,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* @param expression the parameter's value/expression. | * @param expression the parameter's value/expression. | ||||
* @see #setType(java.lang.String) | * @see #setType(java.lang.String) | ||||
*/ | */ | ||||
public void setExpression(String expression) { | |||||
public void setExpression(final String expression) { | |||||
this.expression = expression; | this.expression = expression; | ||||
} | } | ||||
@@ -1021,7 +1021,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* @see ParamType | * @see ParamType | ||||
* @since Ant 1.9.3 | * @since Ant 1.9.3 | ||||
*/ | */ | ||||
public void setType(String type) { | |||||
public void setType(final String type) { | |||||
this.type = type; | this.type = type; | ||||
} | } | ||||
@@ -1067,7 +1067,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* @param ifCond evaluated expression | * @param ifCond evaluated expression | ||||
* @since Ant 1.8.0 | * @since Ant 1.8.0 | ||||
*/ | */ | ||||
public void setIf(Object ifCond) { | |||||
public void setIf(final Object ifCond) { | |||||
this.ifCond = ifCond; | this.ifCond = ifCond; | ||||
} | } | ||||
@@ -1077,7 +1077,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* which has been set, otherwise it won't. | * which has been set, otherwise it won't. | ||||
* @param ifProperty evaluated expression | * @param ifProperty evaluated expression | ||||
*/ | */ | ||||
public void setIf(String ifProperty) { | |||||
public void setIf(final String ifProperty) { | |||||
setIf((Object) ifProperty); | setIf((Object) ifProperty); | ||||
} | } | ||||
@@ -1088,7 +1088,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* @param unlessCond evaluated expression | * @param unlessCond evaluated expression | ||||
* @since Ant 1.8.0 | * @since Ant 1.8.0 | ||||
*/ | */ | ||||
public void setUnless(Object unlessCond) { | |||||
public void setUnless(final Object unlessCond) { | |||||
this.unlessCond = unlessCond; | this.unlessCond = unlessCond; | ||||
} | } | ||||
@@ -1098,7 +1098,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* property which has been set, otherwise it will be used. | * property which has been set, otherwise it will be used. | ||||
* @param unlessProperty evaluated expression | * @param unlessProperty evaluated expression | ||||
*/ | */ | ||||
public void setUnless(String unlessProperty) { | |||||
public void setUnless(final String unlessProperty) { | |||||
setUnless((Object) unlessProperty); | setUnless((Object) unlessProperty); | ||||
} | } | ||||
@@ -1108,7 +1108,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* @return true if the task passes the "if" and "unless" parameters | * @return true if the task passes the "if" and "unless" parameters | ||||
*/ | */ | ||||
public boolean shouldUse() { | public boolean shouldUse() { | ||||
PropertyHelper ph = PropertyHelper.getPropertyHelper(project); | |||||
final PropertyHelper ph = PropertyHelper.getPropertyHelper(project); | |||||
return ph.testIfCondition(ifCond) | return ph.testIfCondition(ifCond) | ||||
&& ph.testUnlessCondition(unlessCond); | && ph.testUnlessCondition(unlessCond); | ||||
} | } | ||||
@@ -1155,7 +1155,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
public static final Map<ParamType, QName> XPATH_TYPES; | public static final Map<ParamType, QName> XPATH_TYPES; | ||||
static { | static { | ||||
Map<ParamType, QName> m = new EnumMap<ParamType, QName>(ParamType.class); | |||||
final Map<ParamType, QName> m = new EnumMap<ParamType, QName>(ParamType.class); | |||||
m.put(XPATH_STRING, XPathConstants.STRING); | m.put(XPATH_STRING, XPathConstants.STRING); | ||||
m.put(XPATH_BOOLEAN, XPathConstants.BOOLEAN); | m.put(XPATH_BOOLEAN, XPathConstants.BOOLEAN); | ||||
m.put(XPATH_NUMBER, XPathConstants.NUMBER); | m.put(XPATH_NUMBER, XPathConstants.NUMBER); | ||||
@@ -1171,7 +1171,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* @since Ant 1.5 | * @since Ant 1.5 | ||||
*/ | */ | ||||
public OutputProperty createOutputProperty() { | public OutputProperty createOutputProperty() { | ||||
OutputProperty p = new OutputProperty(); | |||||
final OutputProperty p = new OutputProperty(); | |||||
outputProperties.addElement(p); | outputProperties.addElement(p); | ||||
return p; | return p; | ||||
} | } | ||||
@@ -1201,7 +1201,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* @param name A non-null String that specifies an | * @param name A non-null String that specifies an | ||||
* output property name, which may be namespace qualified. | * output property name, which may be namespace qualified. | ||||
*/ | */ | ||||
public void setName(String name) { | |||||
public void setName(final String name) { | |||||
this.name = name; | this.name = name; | ||||
} | } | ||||
@@ -1216,7 +1216,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* set the value for this property | * set the value for this property | ||||
* @param value The non-null string value of the output property. | * @param value The non-null string value of the output property. | ||||
*/ | */ | ||||
public void setValue(String value) { | |||||
public void setValue(final String value) { | |||||
this.value = value; | this.value = value; | ||||
} | } | ||||
} | } | ||||
@@ -1234,8 +1234,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
xpathFactory = XPathFactory.newInstance(); | xpathFactory = XPathFactory.newInstance(); | ||||
xpath = xpathFactory.newXPath(); | xpath = xpathFactory.newXPath(); | ||||
xpath.setXPathVariableResolver(new XPathVariableResolver() { | xpath.setXPathVariableResolver(new XPathVariableResolver() { | ||||
@Override | |||||
public Object resolveVariable(QName variableName) { | |||||
public Object resolveVariable(final QName variableName) { | |||||
return getProject().getProperty(variableName.toString()); | return getProject().getProperty(variableName.toString()); | ||||
} | } | ||||
}); | }); | ||||
@@ -1249,8 +1248,8 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* @deprecated since Ant 1.7 | * @deprecated since Ant 1.7 | ||||
*/ | */ | ||||
@Deprecated | @Deprecated | ||||
protected void configureLiaison(File stylesheet) throws BuildException { | |||||
FileResource fr = new FileResource(); | |||||
protected void configureLiaison(final File stylesheet) throws BuildException { | |||||
final FileResource fr = new FileResource(); | |||||
fr.setProject(getProject()); | fr.setProject(getProject()); | ||||
fr.setFile(stylesheet); | fr.setFile(stylesheet); | ||||
configureLiaison(fr); | configureLiaison(fr); | ||||
@@ -1263,7 +1262,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* @exception BuildException if the stylesheet cannot be loaded. | * @exception BuildException if the stylesheet cannot be loaded. | ||||
* @since Ant 1.7 | * @since Ant 1.7 | ||||
*/ | */ | ||||
protected void configureLiaison(Resource stylesheet) throws BuildException { | |||||
protected void configureLiaison(final Resource stylesheet) throws BuildException { | |||||
if (stylesheetLoaded && reuseLoadedStylesheet) { | if (stylesheetLoaded && reuseLoadedStylesheet) { | ||||
return; | return; | ||||
} | } | ||||
@@ -1284,7 +1283,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
// If we are here we cannot set the stylesheet as | // If we are here we cannot set the stylesheet as | ||||
// a resource, but we can set it as a file. So, | // a resource, but we can set it as a file. So, | ||||
// we make an attempt to get it as a file | // we make an attempt to get it as a file | ||||
FileProvider fp = | |||||
final FileProvider fp = | |||||
stylesheet.as(FileProvider.class); | stylesheet.as(FileProvider.class); | ||||
if (fp != null) { | if (fp != null) { | ||||
liaison.setStylesheet(fp.getFile()); | liaison.setStylesheet(fp.getFile()); | ||||
@@ -1294,9 +1293,9 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
return; | return; | ||||
} | } | ||||
} | } | ||||
for (Param p : params) { | |||||
for (final Param p : params) { | |||||
if (p.shouldUse()) { | if (p.shouldUse()) { | ||||
Object evaluatedParam = evaluateParam(p); | |||||
final Object evaluatedParam = evaluateParam(p); | |||||
if (liaison instanceof XSLTLiaison4) { | if (liaison instanceof XSLTLiaison4) { | ||||
((XSLTLiaison4)liaison).addParam(p.getName(), evaluatedParam); | ((XSLTLiaison4)liaison).addParam(p.getName(), evaluatedParam); | ||||
} else { | } else { | ||||
@@ -1311,7 +1310,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
} | } | ||||
} | } | ||||
} | } | ||||
} catch (Exception ex) { | |||||
} catch (final Exception ex) { | |||||
log("Failed to transform using stylesheet " + stylesheet, Project.MSG_INFO); | log("Failed to transform using stylesheet " + stylesheet, Project.MSG_INFO); | ||||
handleTransformationError(ex); | handleTransformationError(ex); | ||||
} | } | ||||
@@ -1328,9 +1327,9 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* @throws XPathExpressionException if XPath expression can not be compiled | * @throws XPathExpressionException if XPath expression can not be compiled | ||||
* @since Ant 1.9.3 | * @since Ant 1.9.3 | ||||
*/ | */ | ||||
private Object evaluateParam(Param param) throws XPathExpressionException { | |||||
String typeName = param.getType(); | |||||
String expression = param.getExpression(); | |||||
private Object evaluateParam(final Param param) throws XPathExpressionException { | |||||
final String typeName = param.getType(); | |||||
final String expression = param.getExpression(); | |||||
ParamType type; | ParamType type; | ||||
@@ -1339,7 +1338,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
} else { | } else { | ||||
try { | try { | ||||
type = ParamType.valueOf(typeName); | type = ParamType.valueOf(typeName); | ||||
} catch (IllegalArgumentException e) { | |||||
} catch (final IllegalArgumentException e) { | |||||
throw new IllegalArgumentException("Invalid XSLT parameter type: " + typeName, e); | throw new IllegalArgumentException("Invalid XSLT parameter type: " + typeName, e); | ||||
} | } | ||||
} | } | ||||
@@ -1356,11 +1355,11 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
case LONG: | case LONG: | ||||
return Long.parseLong(expression); | return Long.parseLong(expression); | ||||
default: // XPath expression | default: // XPath expression | ||||
QName xpathType = ParamType.XPATH_TYPES.get(type); | |||||
final QName xpathType = ParamType.XPATH_TYPES.get(type); | |||||
if (xpathType == null) { | if (xpathType == null) { | ||||
throw new IllegalArgumentException("Invalid XSLT parameter type: " + typeName); | throw new IllegalArgumentException("Invalid XSLT parameter type: " + typeName); | ||||
} else { | } else { | ||||
XPathExpression xpe = xpath.compile(expression); | |||||
final XPathExpression xpe = xpath.compile(expression); | |||||
// null = evaluate XPath on empty XML document | // null = evaluate XPath on empty XML document | ||||
return xpe.evaluate((Object) null, xpathType); | return xpe.evaluate((Object) null, xpathType); | ||||
} | } | ||||
@@ -1378,13 +1377,13 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* @since Ant 1.7 | * @since Ant 1.7 | ||||
*/ | */ | ||||
private void setLiaisonDynamicFileParameters( | private void setLiaisonDynamicFileParameters( | ||||
XSLTLiaison liaison, File inFile) throws Exception { | |||||
final XSLTLiaison liaison, final File inFile) throws Exception { | |||||
if (fileNameParameter != null) { | if (fileNameParameter != null) { | ||||
liaison.addParam(fileNameParameter, inFile.getName()); | liaison.addParam(fileNameParameter, inFile.getName()); | ||||
} | } | ||||
if (fileDirParameter != null) { | if (fileDirParameter != null) { | ||||
String fileName = FileUtils.getRelativePath(baseDir, inFile); | |||||
File file = new File(fileName); | |||||
final String fileName = FileUtils.getRelativePath(baseDir, inFile); | |||||
final File file = new File(fileName); | |||||
// Give always a slash as file separator, so the stylesheet could be sure about that | // Give always a slash as file separator, so the stylesheet could be sure about that | ||||
// Use '.' so a dir+"/"+name would not result in an absolute path | // Use '.' so a dir+"/"+name would not result in an absolute path | ||||
liaison.addParam(fileDirParameter, file.getParent() != null ? file.getParent().replace( | liaison.addParam(fileDirParameter, file.getParent() != null ? file.getParent().replace( | ||||
@@ -1412,7 +1411,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* | * | ||||
* @since Ant 1.8.0 | * @since Ant 1.8.0 | ||||
*/ | */ | ||||
protected void handleError(String msg) { | |||||
protected void handleError(final String msg) { | |||||
if (failOnError) { | if (failOnError) { | ||||
throw new BuildException(msg, getLocation()); | throw new BuildException(msg, getLocation()); | ||||
} | } | ||||
@@ -1427,7 +1426,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* | * | ||||
* @since Ant 1.8.0 | * @since Ant 1.8.0 | ||||
*/ | */ | ||||
protected void handleError(Throwable ex) { | |||||
protected void handleError(final Throwable ex) { | |||||
if (failOnError) { | if (failOnError) { | ||||
throw new BuildException(ex); | throw new BuildException(ex); | ||||
} else { | } else { | ||||
@@ -1442,7 +1441,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* | * | ||||
* @since Ant 1.8.0 | * @since Ant 1.8.0 | ||||
*/ | */ | ||||
protected void handleTransformationError(Exception ex) { | |||||
protected void handleTransformationError(final Exception ex) { | |||||
if (failOnError && failOnTransformationError) { | if (failOnError && failOnTransformationError) { | ||||
throw new BuildException(ex); | throw new BuildException(ex); | ||||
} else { | } else { | ||||
@@ -1463,7 +1462,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
/** | /** | ||||
* the list of factory attributes to use for TraXLiaison | * the list of factory attributes to use for TraXLiaison | ||||
*/ | */ | ||||
private Vector attributes = new Vector(); | |||||
private final Vector attributes = new Vector(); | |||||
/** | /** | ||||
* @return the name of the factory. | * @return the name of the factory. | ||||
@@ -1476,7 +1475,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* Set the name of the factory | * Set the name of the factory | ||||
* @param name the name of the factory. | * @param name the name of the factory. | ||||
*/ | */ | ||||
public void setName(String name) { | |||||
public void setName(final String name) { | |||||
this.name = name; | this.name = name; | ||||
} | } | ||||
@@ -1484,7 +1483,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* Create an instance of a factory attribute. | * Create an instance of a factory attribute. | ||||
* @param attr the newly created factory attribute | * @param attr the newly created factory attribute | ||||
*/ | */ | ||||
public void addAttribute(Attribute attr) { | |||||
public void addAttribute(final Attribute attr) { | |||||
attributes.addElement(attr); | attributes.addElement(attr); | ||||
} | } | ||||
@@ -1532,8 +1531,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* @return null | * @return null | ||||
* @throws BuildException never | * @throws BuildException never | ||||
*/ | */ | ||||
@Override | |||||
public Object createDynamicElement(String name) throws BuildException { | |||||
public Object createDynamicElement(final String name) throws BuildException { | |||||
return null; | return null; | ||||
} | } | ||||
@@ -1544,8 +1542,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* @param value the value of the attribute | * @param value the value of the attribute | ||||
* @throws BuildException on error | * @throws BuildException on error | ||||
*/ | */ | ||||
@Override | |||||
public void setDynamicAttribute(String name, String value) throws BuildException { | |||||
public void setDynamicAttribute(final String name, final String value) throws BuildException { | |||||
// only 'name' and 'value' exist. | // only 'name' and 'value' exist. | ||||
if ("name".equalsIgnoreCase(name)) { | if ("name".equalsIgnoreCase(name)) { | ||||
this.name = value; | this.name = value; | ||||
@@ -1559,7 +1556,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
} else { | } else { | ||||
try { | try { | ||||
this.value = new Integer(value); | this.value = new Integer(value); | ||||
} catch (NumberFormatException e) { | |||||
} catch (final NumberFormatException e) { | |||||
this.value = value; | this.value = value; | ||||
} | } | ||||
} | } | ||||
@@ -1580,15 +1577,12 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* @since Ant 1.6.2 | * @since Ant 1.6.2 | ||||
*/ | */ | ||||
private class StyleMapper implements FileNameMapper { | private class StyleMapper implements FileNameMapper { | ||||
@Override | |||||
public void setFrom(String from) { | |||||
public void setFrom(final String from) { | |||||
} | } | ||||
@Override | |||||
public void setTo(String to) { | |||||
public void setTo(final String to) { | |||||
} | } | ||||
@Override | |||||
public String[] mapFileName(String xmlFile) { | public String[] mapFileName(String xmlFile) { | ||||
int dotPos = xmlFile.lastIndexOf('.'); | |||||
final int dotPos = xmlFile.lastIndexOf('.'); | |||||
if (dotPos > 0) { | if (dotPos > 0) { | ||||
xmlFile = xmlFile.substring(0, dotPos); | xmlFile = xmlFile.substring(0, dotPos); | ||||
} | } | ||||
@@ -1608,7 +1602,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* Set to true if the listener is to print events that occur | * Set to true if the listener is to print events that occur | ||||
* as each node is 'executed' in the stylesheet. | * as each node is 'executed' in the stylesheet. | ||||
*/ | */ | ||||
public void setElements(boolean b) { | |||||
public void setElements(final boolean b) { | |||||
elements = b; | elements = b; | ||||
} | } | ||||
@@ -1624,7 +1618,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* Set to true if the listener is to print information after | * Set to true if the listener is to print information after | ||||
* each extension event. | * each extension event. | ||||
*/ | */ | ||||
public void setExtension(boolean b) { | |||||
public void setExtension(final boolean b) { | |||||
extension = b; | extension = b; | ||||
} | } | ||||
@@ -1640,7 +1634,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* Set to true if the listener is to print information after | * Set to true if the listener is to print information after | ||||
* each result-tree generation event. | * each result-tree generation event. | ||||
*/ | */ | ||||
public void setGeneration(boolean b) { | |||||
public void setGeneration(final boolean b) { | |||||
generation = b; | generation = b; | ||||
} | } | ||||
@@ -1656,7 +1650,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* Set to true if the listener is to print information after | * Set to true if the listener is to print information after | ||||
* each selection event. | * each selection event. | ||||
*/ | */ | ||||
public void setSelection(boolean b) { | |||||
public void setSelection(final boolean b) { | |||||
selection = b; | selection = b; | ||||
} | } | ||||
@@ -1672,7 +1666,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
* Set to true if the listener is to print an event whenever a | * Set to true if the listener is to print an event whenever a | ||||
* template is invoked. | * template is invoked. | ||||
*/ | */ | ||||
public void setTemplates(boolean b) { | |||||
public void setTemplates(final boolean b) { | |||||
templates = b; | templates = b; | ||||
} | } | ||||
@@ -100,35 +100,35 @@ public class AptCompilerAdapter extends DefaultCompilerAdapter { | |||||
* @param cmd command that is set up with the various switches from the task | * @param cmd command that is set up with the various switches from the task | ||||
* options | * options | ||||
*/ | */ | ||||
static void setAptCommandlineSwitches(Apt apt, Commandline cmd) { | |||||
static void setAptCommandlineSwitches(final Apt apt, final Commandline cmd) { | |||||
if (!apt.isCompile()) { | if (!apt.isCompile()) { | ||||
cmd.createArgument().setValue("-nocompile"); | cmd.createArgument().setValue("-nocompile"); | ||||
} | } | ||||
// Process the factory class | // Process the factory class | ||||
String factory = apt.getFactory(); | |||||
final String factory = apt.getFactory(); | |||||
if (factory != null) { | if (factory != null) { | ||||
cmd.createArgument().setValue("-factory"); | cmd.createArgument().setValue("-factory"); | ||||
cmd.createArgument().setValue(factory); | cmd.createArgument().setValue(factory); | ||||
} | } | ||||
// Process the factory path | // Process the factory path | ||||
Path factoryPath = apt.getFactoryPath(); | |||||
final Path factoryPath = apt.getFactoryPath(); | |||||
if (factoryPath != null) { | if (factoryPath != null) { | ||||
cmd.createArgument().setValue("-factorypath"); | cmd.createArgument().setValue("-factorypath"); | ||||
cmd.createArgument().setPath(factoryPath); | cmd.createArgument().setPath(factoryPath); | ||||
} | } | ||||
File preprocessDir = apt.getPreprocessDir(); | |||||
final File preprocessDir = apt.getPreprocessDir(); | |||||
if (preprocessDir != null) { | if (preprocessDir != null) { | ||||
cmd.createArgument().setValue("-s"); | cmd.createArgument().setValue("-s"); | ||||
cmd.createArgument().setFile(preprocessDir); | cmd.createArgument().setFile(preprocessDir); | ||||
} | } | ||||
// Process the processor options | // Process the processor options | ||||
Vector options = apt.getOptions(); | |||||
Enumeration elements = options.elements(); | |||||
final Vector options = apt.getOptions(); | |||||
final Enumeration elements = options.elements(); | |||||
Apt.Option opt; | Apt.Option opt; | ||||
StringBuffer arg = null; | StringBuffer arg = null; | ||||
while (elements.hasMoreElements()) { | while (elements.hasMoreElements()) { | ||||
@@ -147,8 +147,8 @@ public class AptCompilerAdapter extends DefaultCompilerAdapter { | |||||
* | * | ||||
* @param cmd command line to set up | * @param cmd command line to set up | ||||
*/ | */ | ||||
protected void setAptCommandlineSwitches(Commandline cmd) { | |||||
Apt apt = getApt(); | |||||
protected void setAptCommandlineSwitches(final Commandline cmd) { | |||||
final Apt apt = getApt(); | |||||
setAptCommandlineSwitches(apt, cmd); | setAptCommandlineSwitches(apt, cmd); | ||||
} | } | ||||
@@ -157,29 +157,28 @@ public class AptCompilerAdapter extends DefaultCompilerAdapter { | |||||
* @return true on success. | * @return true on success. | ||||
* @throws BuildException if the compilation has problems. | * @throws BuildException if the compilation has problems. | ||||
*/ | */ | ||||
@Override | |||||
public boolean execute() throws BuildException { | public boolean execute() throws BuildException { | ||||
attributes.log("Using apt compiler", Project.MSG_VERBOSE); | attributes.log("Using apt compiler", Project.MSG_VERBOSE); | ||||
//set up the javac options | //set up the javac options | ||||
Commandline cmd = setupModernJavacCommand(); | |||||
final Commandline cmd = setupModernJavacCommand(); | |||||
//then add the Apt options | //then add the Apt options | ||||
setAptCommandlineSwitches(cmd); | setAptCommandlineSwitches(cmd); | ||||
//finally invoke APT | //finally invoke APT | ||||
// Use reflection to be able to build on all JDKs: | // Use reflection to be able to build on all JDKs: | ||||
try { | try { | ||||
Class c = Class.forName(APT_ENTRY_POINT); | |||||
Object compiler = c.newInstance(); | |||||
Method compile = c.getMethod(APT_METHOD_NAME, | |||||
final Class c = Class.forName(APT_ENTRY_POINT); | |||||
final Object compiler = c.newInstance(); | |||||
final Method compile = c.getMethod(APT_METHOD_NAME, | |||||
new Class[]{(new String[]{}).getClass()}); | new Class[]{(new String[]{}).getClass()}); | ||||
int result = ((Integer) compile.invoke | |||||
final int result = ((Integer) compile.invoke | |||||
(compiler, new Object[]{cmd.getArguments()})) | (compiler, new Object[]{cmd.getArguments()})) | ||||
.intValue(); | .intValue(); | ||||
return (result == APT_COMPILER_SUCCESS); | return (result == APT_COMPILER_SUCCESS); | ||||
} catch (BuildException be) { | |||||
} catch (final BuildException be) { | |||||
//rethrow build exceptions | //rethrow build exceptions | ||||
throw be; | throw be; | ||||
} catch (Exception ex) { | |||||
} catch (final Exception ex) { | |||||
//cast everything else to a build exception | //cast everything else to a build exception | ||||
throw new BuildException("Error starting apt compiler", | throw new BuildException("Error starting apt compiler", | ||||
ex, location); | ex, location); | ||||
@@ -97,7 +97,6 @@ public abstract class DefaultCompilerAdapter | |||||
* | * | ||||
* @param attributes a configured Javac task. | * @param attributes a configured Javac task. | ||||
*/ | */ | ||||
@Override | |||||
public void setJavac(final Javac attributes) { | public void setJavac(final Javac attributes) { | ||||
this.attributes = attributes; | this.attributes = attributes; | ||||
src = attributes.getSrcdir(); | src = attributes.getSrcdir(); | ||||
@@ -136,7 +135,6 @@ public abstract class DefaultCompilerAdapter | |||||
* but specialized compilers can recognize multiple kinds | * but specialized compilers can recognize multiple kinds | ||||
* of files. | * of files. | ||||
*/ | */ | ||||
@Override | |||||
public String[] getSupportedFileExtensions() { | public String[] getSupportedFileExtensions() { | ||||
return new String[] {"java"}; | return new String[] {"java"}; | ||||
} | } | ||||
@@ -96,7 +96,7 @@ public class IsReachable extends ProjectComponent implements Condition { | |||||
* | * | ||||
* @param host the host to ping. | * @param host the host to ping. | ||||
*/ | */ | ||||
public void setHost(String host) { | |||||
public void setHost(final String host) { | |||||
this.host = host; | this.host = host; | ||||
} | } | ||||
@@ -105,7 +105,7 @@ public class IsReachable extends ProjectComponent implements Condition { | |||||
* | * | ||||
* @param url a URL object. | * @param url a URL object. | ||||
*/ | */ | ||||
public void setUrl(String url) { | |||||
public void setUrl(final String url) { | |||||
this.url = url; | this.url = url; | ||||
} | } | ||||
@@ -114,7 +114,7 @@ public class IsReachable extends ProjectComponent implements Condition { | |||||
* | * | ||||
* @param timeout the timeout in seconds. | * @param timeout the timeout in seconds. | ||||
*/ | */ | ||||
public void setTimeout(int timeout) { | |||||
public void setTimeout(final int timeout) { | |||||
this.timeout = timeout; | this.timeout = timeout; | ||||
} | } | ||||
@@ -125,7 +125,7 @@ public class IsReachable extends ProjectComponent implements Condition { | |||||
* | * | ||||
* @return true if it is empty | * @return true if it is empty | ||||
*/ | */ | ||||
private boolean empty(String string) { | |||||
private boolean empty(final String string) { | |||||
return string == null || string.length() == 0; | return string == null || string.length() == 0; | ||||
} | } | ||||
@@ -139,7 +139,6 @@ public class IsReachable extends ProjectComponent implements Condition { | |||||
* @throws org.apache.tools.ant.BuildException | * @throws org.apache.tools.ant.BuildException | ||||
* if an error occurs | * if an error occurs | ||||
*/ | */ | ||||
@Override | |||||
public boolean eval() throws BuildException { | public boolean eval() throws BuildException { | ||||
if (empty(host) && empty(url)) { | if (empty(host) && empty(url)) { | ||||
throw new BuildException(ERROR_NO_HOSTNAME); | throw new BuildException(ERROR_NO_HOSTNAME); | ||||
@@ -154,12 +153,12 @@ public class IsReachable extends ProjectComponent implements Condition { | |||||
} | } | ||||
try { | try { | ||||
//get the host of a url | //get the host of a url | ||||
URL realURL = new URL(url); | |||||
final URL realURL = new URL(url); | |||||
target = realURL.getHost(); | target = realURL.getHost(); | ||||
if (empty(target)) { | if (empty(target)) { | ||||
throw new BuildException(ERROR_NO_HOST_IN_URL + url); | throw new BuildException(ERROR_NO_HOST_IN_URL + url); | ||||
} | } | ||||
} catch (MalformedURLException e) { | |||||
} catch (final MalformedURLException e) { | |||||
throw new BuildException(ERROR_BAD_URL + url, e); | throw new BuildException(ERROR_BAD_URL + url, e); | ||||
} | } | ||||
} | } | ||||
@@ -167,7 +166,7 @@ public class IsReachable extends ProjectComponent implements Condition { | |||||
InetAddress address; | InetAddress address; | ||||
try { | try { | ||||
address = InetAddress.getByName(target); | address = InetAddress.getByName(target); | ||||
} catch (UnknownHostException e1) { | |||||
} catch (final UnknownHostException e1) { | |||||
log(WARN_UNKNOWN_HOST + target); | log(WARN_UNKNOWN_HOST + target); | ||||
return false; | return false; | ||||
} | } | ||||
@@ -179,22 +178,22 @@ public class IsReachable extends ProjectComponent implements Condition { | |||||
try { | try { | ||||
reachableMethod = InetAddress.class.getMethod(METHOD_NAME, | reachableMethod = InetAddress.class.getMethod(METHOD_NAME, | ||||
parameterTypes); | parameterTypes); | ||||
Object[] params = new Object[1]; | |||||
final Object[] params = new Object[1]; | |||||
params[0] = new Integer(timeout * SECOND); | params[0] = new Integer(timeout * SECOND); | ||||
try { | try { | ||||
reachable = ((Boolean) reachableMethod.invoke(address, params)) | reachable = ((Boolean) reachableMethod.invoke(address, params)) | ||||
.booleanValue(); | .booleanValue(); | ||||
} catch (IllegalAccessException e) { | |||||
} catch (final IllegalAccessException e) { | |||||
//utterly implausible, but catered for anyway | //utterly implausible, but catered for anyway | ||||
throw new BuildException("When calling " + reachableMethod); | throw new BuildException("When calling " + reachableMethod); | ||||
} catch (InvocationTargetException e) { | |||||
} catch (final InvocationTargetException e) { | |||||
//assume this is an IOexception about un readability | //assume this is an IOexception about un readability | ||||
Throwable nested = e.getTargetException(); | |||||
final Throwable nested = e.getTargetException(); | |||||
log(ERROR_ON_NETWORK + target + ": " + nested.toString()); | log(ERROR_ON_NETWORK + target + ": " + nested.toString()); | ||||
//any kind of fault: not reachable. | //any kind of fault: not reachable. | ||||
reachable = false; | reachable = false; | ||||
} | } | ||||
} catch (NoSuchMethodException e) { | |||||
} catch (final NoSuchMethodException e) { | |||||
//java1.4 | //java1.4 | ||||
log("Not found: InetAddress." + METHOD_NAME, Project.MSG_VERBOSE); | log("Not found: InetAddress." + METHOD_NAME, Project.MSG_VERBOSE); | ||||
log(MSG_NO_REACHABLE_TEST); | log(MSG_NO_REACHABLE_TEST); | ||||
@@ -117,13 +117,13 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||||
private URIResolver uriResolver; | private URIResolver uriResolver; | ||||
/** transformer output properties */ | /** transformer output properties */ | ||||
private Vector outputProperties = new Vector(); | |||||
private final Vector outputProperties = new Vector(); | |||||
/** stylesheet parameters */ | /** stylesheet parameters */ | ||||
private Hashtable<String, Object> params = new Hashtable<String, Object>(); | |||||
private final Hashtable<String, Object> params = new Hashtable<String, Object>(); | |||||
/** factory attributes */ | /** factory attributes */ | ||||
private Vector attributes = new Vector(); | |||||
private final Vector attributes = new Vector(); | |||||
/** whether to suppress warnings */ | /** whether to suppress warnings */ | ||||
private boolean suppressWarnings = false; | private boolean suppressWarnings = false; | ||||
@@ -143,9 +143,8 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||||
* @param stylesheet a <code>File</code> value | * @param stylesheet a <code>File</code> value | ||||
* @throws Exception on error | * @throws Exception on error | ||||
*/ | */ | ||||
@Override | |||||
public void setStylesheet(File stylesheet) throws Exception { | |||||
FileResource fr = new FileResource(); | |||||
public void setStylesheet(final File stylesheet) throws Exception { | |||||
final FileResource fr = new FileResource(); | |||||
fr.setProject(project); | fr.setProject(project); | ||||
fr.setFile(stylesheet); | fr.setFile(stylesheet); | ||||
setStylesheet(fr); | setStylesheet(fr); | ||||
@@ -156,8 +155,7 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||||
* @param stylesheet a {@link org.apache.tools.ant.types.Resource} value | * @param stylesheet a {@link org.apache.tools.ant.types.Resource} value | ||||
* @throws Exception on error | * @throws Exception on error | ||||
*/ | */ | ||||
@Override | |||||
public void setStylesheet(Resource stylesheet) throws Exception { | |||||
public void setStylesheet(final Resource stylesheet) throws Exception { | |||||
if (this.stylesheet != null) { | if (this.stylesheet != null) { | ||||
// resetting the stylesheet - reset transformer | // resetting the stylesheet - reset transformer | ||||
transformer = null; | transformer = null; | ||||
@@ -177,8 +175,7 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||||
* @param outfile the result file | * @param outfile the result file | ||||
* @throws Exception on error | * @throws Exception on error | ||||
*/ | */ | ||||
@Override | |||||
public void transform(File infile, File outfile) throws Exception { | |||||
public void transform(final File infile, final File outfile) throws Exception { | |||||
if (transformer == null) { | if (transformer == null) { | ||||
createTransformer(); | createTransformer(); | ||||
} | } | ||||
@@ -188,10 +185,10 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||||
try { | try { | ||||
fis = new BufferedInputStream(new FileInputStream(infile)); | fis = new BufferedInputStream(new FileInputStream(infile)); | ||||
fos = new BufferedOutputStream(new FileOutputStream(outfile)); | fos = new BufferedOutputStream(new FileOutputStream(outfile)); | ||||
StreamResult res = new StreamResult(fos); | |||||
final StreamResult res = new StreamResult(fos); | |||||
// not sure what could be the need of this... | // not sure what could be the need of this... | ||||
res.setSystemId(JAXPUtils.getSystemId(outfile)); | res.setSystemId(JAXPUtils.getSystemId(outfile)); | ||||
Source src = getSource(fis, infile); | |||||
final Source src = getSource(fis, infile); | |||||
// set parameters on each transformation, maybe something has changed | // set parameters on each transformation, maybe something has changed | ||||
//(e.g. value of file name parameter) | //(e.g. value of file name parameter) | ||||
@@ -216,7 +213,7 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||||
* satisfies the requested configuration. | * satisfies the requested configuration. | ||||
* @throws SAXException in case of problem detected by the SAX parser. | * @throws SAXException in case of problem detected by the SAX parser. | ||||
*/ | */ | ||||
private Source getSource(InputStream is, File infile) | |||||
private Source getSource(final InputStream is, final File infile) | |||||
throws ParserConfigurationException, SAXException { | throws ParserConfigurationException, SAXException { | ||||
// todo: is this comment still relevant ?? | // todo: is this comment still relevant ?? | ||||
// FIXME: need to use a SAXSource as the source for the transform | // FIXME: need to use a SAXSource as the source for the transform | ||||
@@ -224,9 +221,9 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||||
Source src = null; | Source src = null; | ||||
if (entityResolver != null) { | if (entityResolver != null) { | ||||
if (getFactory().getFeature(SAXSource.FEATURE)) { | if (getFactory().getFeature(SAXSource.FEATURE)) { | ||||
SAXParserFactory spFactory = SAXParserFactory.newInstance(); | |||||
final SAXParserFactory spFactory = SAXParserFactory.newInstance(); | |||||
spFactory.setNamespaceAware(true); | spFactory.setNamespaceAware(true); | ||||
XMLReader reader = spFactory.newSAXParser().getXMLReader(); | |||||
final XMLReader reader = spFactory.newSAXParser().getXMLReader(); | |||||
reader.setEntityResolver(entityResolver); | reader.setEntityResolver(entityResolver); | ||||
src = new SAXSource(reader, new InputSource(is)); | src = new SAXSource(reader, new InputSource(is)); | ||||
} else { | } else { | ||||
@@ -242,7 +239,7 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||||
return src; | return src; | ||||
} | } | ||||
private Source getSource(InputStream is, Resource resource) | |||||
private Source getSource(final InputStream is, final Resource resource) | |||||
throws ParserConfigurationException, SAXException { | throws ParserConfigurationException, SAXException { | ||||
// todo: is this comment still relevant ?? | // todo: is this comment still relevant ?? | ||||
// FIXME: need to use a SAXSource as the source for the transform | // FIXME: need to use a SAXSource as the source for the transform | ||||
@@ -250,9 +247,9 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||||
Source src = null; | Source src = null; | ||||
if (entityResolver != null) { | if (entityResolver != null) { | ||||
if (getFactory().getFeature(SAXSource.FEATURE)) { | if (getFactory().getFeature(SAXSource.FEATURE)) { | ||||
SAXParserFactory spFactory = SAXParserFactory.newInstance(); | |||||
final SAXParserFactory spFactory = SAXParserFactory.newInstance(); | |||||
spFactory.setNamespaceAware(true); | spFactory.setNamespaceAware(true); | ||||
XMLReader reader = spFactory.newSAXParser().getXMLReader(); | |||||
final XMLReader reader = spFactory.newSAXParser().getXMLReader(); | |||||
reader.setEntityResolver(entityResolver); | reader.setEntityResolver(entityResolver); | ||||
src = new SAXSource(reader, new InputSource(is)); | src = new SAXSource(reader, new InputSource(is)); | ||||
} else { | } else { | ||||
@@ -271,14 +268,14 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||||
return src; | return src; | ||||
} | } | ||||
private String resourceToURI(Resource resource) { | |||||
FileProvider fp = resource.as(FileProvider.class); | |||||
private String resourceToURI(final Resource resource) { | |||||
final FileProvider fp = resource.as(FileProvider.class); | |||||
if (fp != null) { | if (fp != null) { | ||||
return FILE_UTILS.toURI(fp.getFile().getAbsolutePath()); | return FILE_UTILS.toURI(fp.getFile().getAbsolutePath()); | ||||
} | } | ||||
URLProvider up = resource.as(URLProvider.class); | |||||
final URLProvider up = resource.as(URLProvider.class); | |||||
if (up != null) { | if (up != null) { | ||||
URL u = up.getURL(); | |||||
final URL u = up.getURL(); | |||||
return String.valueOf(u); | return String.valueOf(u); | ||||
} else { | } else { | ||||
return resource.getName(); | return resource.getName(); | ||||
@@ -301,7 +298,7 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||||
xslStream | xslStream | ||||
= new BufferedInputStream(stylesheet.getInputStream()); | = new BufferedInputStream(stylesheet.getInputStream()); | ||||
templatesModTime = stylesheet.getLastModified(); | templatesModTime = stylesheet.getLastModified(); | ||||
Source src = getSource(xslStream, stylesheet); | |||||
final Source src = getSource(xslStream, stylesheet); | |||||
templates = getFactory().newTemplates(src); | templates = getFactory().newTemplates(src); | ||||
} finally { | } finally { | ||||
if (xslStream != null) { | if (xslStream != null) { | ||||
@@ -339,16 +336,16 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||||
if ("org.apache.xalan.transformer.TransformerImpl" | if ("org.apache.xalan.transformer.TransformerImpl" | ||||
.equals(transformer.getClass().getName())) { | .equals(transformer.getClass().getName())) { | ||||
try { | try { | ||||
Class traceSupport = | |||||
final Class traceSupport = | |||||
Class.forName("org.apache.tools.ant.taskdefs.optional." | Class.forName("org.apache.tools.ant.taskdefs.optional." | ||||
+ "Xalan2TraceSupport", true, | + "Xalan2TraceSupport", true, | ||||
Thread.currentThread() | Thread.currentThread() | ||||
.getContextClassLoader()); | .getContextClassLoader()); | ||||
XSLTTraceSupport ts = | |||||
final XSLTTraceSupport ts = | |||||
(XSLTTraceSupport) traceSupport.newInstance(); | (XSLTTraceSupport) traceSupport.newInstance(); | ||||
ts.configureTrace(transformer, traceConfiguration); | ts.configureTrace(transformer, traceConfiguration); | ||||
} catch (Exception e) { | |||||
String msg = "Failed to enable tracing because of " + e; | |||||
} catch (final Exception e) { | |||||
final String msg = "Failed to enable tracing because of " + e; | |||||
if (project != null) { | if (project != null) { | ||||
project.log(msg, Project.MSG_WARN); | project.log(msg, Project.MSG_WARN); | ||||
} else { | } else { | ||||
@@ -356,7 +353,7 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||||
} | } | ||||
} | } | ||||
} else { | } else { | ||||
String msg = "Not enabling trace support for transformer" | |||||
final String msg = "Not enabling trace support for transformer" | |||||
+ " implementation" + transformer.getClass().getName(); | + " implementation" + transformer.getClass().getName(); | ||||
if (project != null) { | if (project != null) { | ||||
project.log(msg, Project.MSG_WARN); | project.log(msg, Project.MSG_WARN); | ||||
@@ -402,8 +399,8 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||||
Class.forName(factoryName, true, | Class.forName(factoryName, true, | ||||
Thread.currentThread() | Thread.currentThread() | ||||
.getContextClassLoader()); | .getContextClassLoader()); | ||||
} catch (ClassNotFoundException cnfe) { | |||||
String msg = "Failed to load " + factoryName | |||||
} catch (final ClassNotFoundException cnfe) { | |||||
final String msg = "Failed to load " + factoryName | |||||
+ " via the configured classpath, will try" | + " via the configured classpath, will try" | ||||
+ " Ant's classpath instead."; | + " Ant's classpath instead."; | ||||
if (logger != null) { | if (logger != null) { | ||||
@@ -419,16 +416,16 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||||
clazz = Class.forName(factoryName); | clazz = Class.forName(factoryName); | ||||
} | } | ||||
tfactory = (TransformerFactory) clazz.newInstance(); | tfactory = (TransformerFactory) clazz.newInstance(); | ||||
} catch (Exception e) { | |||||
} catch (final Exception e) { | |||||
throw new BuildException(e); | throw new BuildException(e); | ||||
} | } | ||||
} | } | ||||
try { // #51668, #52382 | try { // #51668, #52382 | ||||
Field _isNotSecureProcessing = tfactory.getClass().getDeclaredField("_isNotSecureProcessing"); | |||||
final Field _isNotSecureProcessing = tfactory.getClass().getDeclaredField("_isNotSecureProcessing"); | |||||
_isNotSecureProcessing.setAccessible(true); | _isNotSecureProcessing.setAccessible(true); | ||||
_isNotSecureProcessing.set(tfactory, Boolean.TRUE); | _isNotSecureProcessing.set(tfactory, Boolean.TRUE); | ||||
} catch (Exception x) { | |||||
} catch (final Exception x) { | |||||
if (project != null) { | if (project != null) { | ||||
project.log(x.toString(), Project.MSG_DEBUG); | project.log(x.toString(), Project.MSG_DEBUG); | ||||
} | } | ||||
@@ -456,7 +453,7 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||||
* or null for the default JAXP look up mechanism. | * or null for the default JAXP look up mechanism. | ||||
* @since Ant 1.6 | * @since Ant 1.6 | ||||
*/ | */ | ||||
public void setFactory(String name) { | |||||
public void setFactory(final String name) { | |||||
factoryName = name; | factoryName = name; | ||||
} | } | ||||
@@ -467,7 +464,7 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||||
* string or object. | * string or object. | ||||
* @since Ant 1.6 | * @since Ant 1.6 | ||||
*/ | */ | ||||
public void setAttribute(String name, Object value) { | |||||
public void setAttribute(final String name, final Object value) { | |||||
final Object[] pair = new Object[]{name, value}; | final Object[] pair = new Object[]{name, value}; | ||||
attributes.addElement(pair); | attributes.addElement(pair); | ||||
} | } | ||||
@@ -481,7 +478,7 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||||
* @since Ant 1.5 | * @since Ant 1.5 | ||||
* @since Ant 1.5 | * @since Ant 1.5 | ||||
*/ | */ | ||||
public void setOutputProperty(String name, String value) { | |||||
public void setOutputProperty(final String name, final String value) { | |||||
final String[] pair = new String[]{name, value}; | final String[] pair = new String[]{name, value}; | ||||
outputProperties.addElement(pair); | outputProperties.addElement(pair); | ||||
} | } | ||||
@@ -490,7 +487,7 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||||
* Set the class to resolve entities during the transformation. | * Set the class to resolve entities during the transformation. | ||||
* @param aResolver the resolver class. | * @param aResolver the resolver class. | ||||
*/ | */ | ||||
public void setEntityResolver(EntityResolver aResolver) { | |||||
public void setEntityResolver(final EntityResolver aResolver) { | |||||
entityResolver = aResolver; | entityResolver = aResolver; | ||||
} | } | ||||
@@ -498,7 +495,7 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||||
* Set the class to resolve URIs during the transformation | * Set the class to resolve URIs during the transformation | ||||
* @param aResolver a <code>EntityResolver</code> value | * @param aResolver a <code>EntityResolver</code> value | ||||
*/ | */ | ||||
public void setURIResolver(URIResolver aResolver) { | |||||
public void setURIResolver(final URIResolver aResolver) { | |||||
uriResolver = aResolver; | uriResolver = aResolver; | ||||
} | } | ||||
@@ -507,8 +504,7 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||||
* @param name the name of the parameter | * @param name the name of the parameter | ||||
* @param value the value of the parameter | * @param value the value of the parameter | ||||
*/ | */ | ||||
@Override | |||||
public void addParam(String name, String value) { | |||||
public void addParam(final String name, final String value) { | |||||
params.put(name, value); | params.put(name, value); | ||||
} | } | ||||
@@ -518,8 +514,7 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||||
* @param value the value of the parameter | * @param value the value of the parameter | ||||
* @since Ant 1.9.3 | * @since Ant 1.9.3 | ||||
*/ | */ | ||||
@Override | |||||
public void addParam(String name, Object value) { | |||||
public void addParam(final String name, final Object value) { | |||||
params.put(name, value); | params.put(name, value); | ||||
} | } | ||||
@@ -527,8 +522,7 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||||
* Set a logger. | * Set a logger. | ||||
* @param l a logger. | * @param l a logger. | ||||
*/ | */ | ||||
@Override | |||||
public void setLogger(XSLTLogger l) { | |||||
public void setLogger(final XSLTLogger l) { | |||||
logger = l; | logger = l; | ||||
} | } | ||||
@@ -536,8 +530,7 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||||
* Log an error. | * Log an error. | ||||
* @param e the exception to log. | * @param e the exception to log. | ||||
*/ | */ | ||||
@Override | |||||
public void error(TransformerException e) { | |||||
public void error(final TransformerException e) { | |||||
logError(e, "Error"); | logError(e, "Error"); | ||||
} | } | ||||
@@ -545,8 +538,7 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||||
* Log a fatal error. | * Log a fatal error. | ||||
* @param e the exception to log. | * @param e the exception to log. | ||||
*/ | */ | ||||
@Override | |||||
public void fatalError(TransformerException e) { | |||||
public void fatalError(final TransformerException e) { | |||||
logError(e, "Fatal Error"); | logError(e, "Fatal Error"); | ||||
throw new BuildException("Fatal error during transformation using " + stylesheet + ": " + e.getMessageAndLocation(), e); | throw new BuildException("Fatal error during transformation using " + stylesheet + ": " + e.getMessageAndLocation(), e); | ||||
} | } | ||||
@@ -555,22 +547,21 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||||
* Log a warning. | * Log a warning. | ||||
* @param e the exception to log. | * @param e the exception to log. | ||||
*/ | */ | ||||
@Override | |||||
public void warning(TransformerException e) { | |||||
public void warning(final TransformerException e) { | |||||
if (!suppressWarnings) { | if (!suppressWarnings) { | ||||
logError(e, "Warning"); | logError(e, "Warning"); | ||||
} | } | ||||
} | } | ||||
private void logError(TransformerException e, String type) { | |||||
private void logError(final TransformerException e, final String type) { | |||||
if (logger == null) { | if (logger == null) { | ||||
return; | return; | ||||
} | } | ||||
StringBuffer msg = new StringBuffer(); | |||||
SourceLocator locator = e.getLocator(); | |||||
final StringBuffer msg = new StringBuffer(); | |||||
final SourceLocator locator = e.getLocator(); | |||||
if (locator != null) { | if (locator != null) { | ||||
String systemid = locator.getSystemId(); | |||||
final String systemid = locator.getSystemId(); | |||||
if (systemid != null) { | if (systemid != null) { | ||||
String url = systemid; | String url = systemid; | ||||
if (url.startsWith("file:")) { | if (url.startsWith("file:")) { | ||||
@@ -580,11 +571,11 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||||
} else { | } else { | ||||
msg.append("Unknown file"); | msg.append("Unknown file"); | ||||
} | } | ||||
int line = locator.getLineNumber(); | |||||
final int line = locator.getLineNumber(); | |||||
if (line != -1) { | if (line != -1) { | ||||
msg.append(":"); | msg.append(":"); | ||||
msg.append(line); | msg.append(line); | ||||
int column = locator.getColumnNumber(); | |||||
final int column = locator.getColumnNumber(); | |||||
if (column != -1) { | if (column != -1) { | ||||
msg.append(":"); | msg.append(":"); | ||||
msg.append(column); | msg.append(column); | ||||
@@ -611,7 +602,7 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||||
* Use org.apache.tools.ant.util.JAXPUtils#getSystemId instead. | * Use org.apache.tools.ant.util.JAXPUtils#getSystemId instead. | ||||
*/ | */ | ||||
@Deprecated | @Deprecated | ||||
protected String getSystemId(File file) { | |||||
protected String getSystemId(final File file) { | |||||
return JAXPUtils.getSystemId(file); | return JAXPUtils.getSystemId(file); | ||||
} | } | ||||
@@ -621,23 +612,22 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||||
* @param xsltTask the XSLTProcess task instance from which this liasion | * @param xsltTask the XSLTProcess task instance from which this liasion | ||||
* is to be configured. | * is to be configured. | ||||
*/ | */ | ||||
@Override | |||||
public void configure(XSLTProcess xsltTask) { | |||||
public void configure(final XSLTProcess xsltTask) { | |||||
project = xsltTask.getProject(); | project = xsltTask.getProject(); | ||||
XSLTProcess.Factory factory = xsltTask.getFactory(); | |||||
final XSLTProcess.Factory factory = xsltTask.getFactory(); | |||||
if (factory != null) { | if (factory != null) { | ||||
setFactory(factory.getName()); | setFactory(factory.getName()); | ||||
// configure factory attributes | // configure factory attributes | ||||
for (Enumeration attrs = factory.getAttributes(); | |||||
for (final Enumeration attrs = factory.getAttributes(); | |||||
attrs.hasMoreElements();) { | attrs.hasMoreElements();) { | ||||
XSLTProcess.Factory.Attribute attr = | |||||
final XSLTProcess.Factory.Attribute attr = | |||||
(XSLTProcess.Factory.Attribute) attrs.nextElement(); | (XSLTProcess.Factory.Attribute) attrs.nextElement(); | ||||
setAttribute(attr.getName(), attr.getValue()); | setAttribute(attr.getName(), attr.getValue()); | ||||
} | } | ||||
} | } | ||||
XMLCatalog xmlCatalog = xsltTask.getXMLCatalog(); | |||||
final XMLCatalog xmlCatalog = xsltTask.getXMLCatalog(); | |||||
// use XMLCatalog as the entity resolver and URI resolver | // use XMLCatalog as the entity resolver and URI resolver | ||||
if (xmlCatalog != null) { | if (xmlCatalog != null) { | ||||
setEntityResolver(xmlCatalog); | setEntityResolver(xmlCatalog); | ||||
@@ -646,9 +636,9 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||||
// configure output properties | // configure output properties | ||||
for (Enumeration props = xsltTask.getOutputProperties(); | |||||
for (final Enumeration props = xsltTask.getOutputProperties(); | |||||
props.hasMoreElements();) { | props.hasMoreElements();) { | ||||
XSLTProcess.OutputProperty prop | |||||
final XSLTProcess.OutputProperty prop | |||||
= (XSLTProcess.OutputProperty) props.nextElement(); | = (XSLTProcess.OutputProperty) props.nextElement(); | ||||
setOutputProperty(prop.getName(), prop.getValue()); | setOutputProperty(prop.getName(), prop.getValue()); | ||||
} | } | ||||
@@ -87,7 +87,6 @@ public class JUnit4TestMethodAdapter implements Test { | |||||
runner = request.getRunner(); | runner = request.getRunner(); | ||||
} | } | ||||
@Override | |||||
public int countTestCases() { | public int countTestCases() { | ||||
return runner.testCount(); | return runner.testCount(); | ||||
} | } | ||||
@@ -104,7 +103,6 @@ public class JUnit4TestMethodAdapter implements Test { | |||||
return testClass; | return testClass; | ||||
} | } | ||||
@Override | |||||
public void run(final TestResult result) { | public void run(final TestResult result) { | ||||
runner.run(cache.getNotifier(result)); | runner.run(cache.getNotifier(result)); | ||||
} | } | ||||
@@ -355,7 +355,6 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
/** | /** | ||||
* Run the test. | * Run the test. | ||||
*/ | */ | ||||
@Override | |||||
public void run() { | public void run() { | ||||
res = new IgnoredTestResult(); | res = new IgnoredTestResult(); | ||||
res.addListener(wrapListener(this)); | res.addListener(wrapListener(this)); | ||||
@@ -678,7 +677,6 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
* | * | ||||
* @return 2 if errors occurred, 1 if tests failed else 0. | * @return 2 if errors occurred, 1 if tests failed else 0. | ||||
*/ | */ | ||||
@Override | |||||
public int getRetCode() { | public int getRetCode() { | ||||
return retCode; | return retCode; | ||||
} | } | ||||
@@ -689,7 +687,6 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
* <p>A new Test is started. | * <p>A new Test is started. | ||||
* @param t the test. | * @param t the test. | ||||
*/ | */ | ||||
@Override | |||||
public void startTest(final Test t) { | public void startTest(final Test t) { | ||||
final String testName = JUnitVersionHelper.getTestCaseName(t); | final String testName = JUnitVersionHelper.getTestCaseName(t); | ||||
logTestListenerEvent("startTest(" + testName + ")"); | logTestListenerEvent("startTest(" + testName + ")"); | ||||
@@ -701,7 +698,6 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
* <p>A Test is finished. | * <p>A Test is finished. | ||||
* @param test the test. | * @param test the test. | ||||
*/ | */ | ||||
@Override | |||||
public void endTest(final Test test) { | public void endTest(final Test test) { | ||||
final String testName = JUnitVersionHelper.getTestCaseName(test); | final String testName = JUnitVersionHelper.getTestCaseName(test); | ||||
logTestListenerEvent("endTest(" + testName + ")"); | logTestListenerEvent("endTest(" + testName + ")"); | ||||
@@ -745,7 +741,6 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
* @param test the test. | * @param test the test. | ||||
* @param t the assertion thrown by the test. | * @param t the assertion thrown by the test. | ||||
*/ | */ | ||||
@Override | |||||
public void addFailure(final Test test, final AssertionFailedError t) { | public void addFailure(final Test test, final AssertionFailedError t) { | ||||
addFailure(test, (Throwable) t); | addFailure(test, (Throwable) t); | ||||
} | } | ||||
@@ -757,7 +752,6 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
* @param test the test. | * @param test the test. | ||||
* @param t the error thrown by the test. | * @param t the error thrown by the test. | ||||
*/ | */ | ||||
@Override | |||||
public void addError(final Test test, final Throwable t) { | public void addError(final Test test, final Throwable t) { | ||||
final String testName = JUnitVersionHelper.getTestCaseName(test); | final String testName = JUnitVersionHelper.getTestCaseName(test); | ||||
logTestListenerEvent("addError(" + testName + ", " + t.getMessage() + ")"); | logTestListenerEvent("addError(" + testName + ", " + t.getMessage() + ")"); | ||||
@@ -771,7 +765,6 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
* @since Ant 1.6 | * @since Ant 1.6 | ||||
* @param permissions the permissions to use. | * @param permissions the permissions to use. | ||||
*/ | */ | ||||
@Override | |||||
public void setPermissions(final Permissions permissions) { | public void setPermissions(final Permissions permissions) { | ||||
perm = permissions; | perm = permissions; | ||||
} | } | ||||
@@ -780,7 +773,6 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
* Handle a string destined for standard output. | * Handle a string destined for standard output. | ||||
* @param output the string to output | * @param output the string to output | ||||
*/ | */ | ||||
@Override | |||||
public void handleOutput(final String output) { | public void handleOutput(final String output) { | ||||
if (!logTestListenerEvents && output.startsWith(JUnitTask.TESTLISTENER_PREFIX)) { | if (!logTestListenerEvents && output.startsWith(JUnitTask.TESTLISTENER_PREFIX)) { | ||||
// ignore | // ignore | ||||
@@ -800,14 +792,12 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
* | * | ||||
* @since Ant 1.6 | * @since Ant 1.6 | ||||
*/ | */ | ||||
@Override | |||||
public int handleInput(final byte[] buffer, final int offset, final int length) | public int handleInput(final byte[] buffer, final int offset, final int length) | ||||
throws IOException { | throws IOException { | ||||
return -1; | return -1; | ||||
} | } | ||||
/** {@inheritDoc}. */ | /** {@inheritDoc}. */ | ||||
@Override | |||||
public void handleErrorOutput(final String output) { | public void handleErrorOutput(final String output) { | ||||
if (systemError != null) { | if (systemError != null) { | ||||
systemError.print(output); | systemError.print(output); | ||||
@@ -815,7 +805,6 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
} | } | ||||
/** {@inheritDoc}. */ | /** {@inheritDoc}. */ | ||||
@Override | |||||
public void handleFlush(final String output) { | public void handleFlush(final String output) { | ||||
if (systemOut != null) { | if (systemOut != null) { | ||||
systemOut.print(output); | systemOut.print(output); | ||||
@@ -823,7 +812,6 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
} | } | ||||
/** {@inheritDoc}. */ | /** {@inheritDoc}. */ | ||||
@Override | |||||
public void handleErrorFlush(final String output) { | public void handleErrorFlush(final String output) { | ||||
if (systemError != null) { | if (systemError != null) { | ||||
systemError.print(output); | systemError.print(output); | ||||
@@ -866,7 +854,6 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
} | } | ||||
/** {@inheritDoc}. */ | /** {@inheritDoc}. */ | ||||
@Override | |||||
public void addFormatter(final JUnitTaskMirror.JUnitResultFormatterMirror f) { | public void addFormatter(final JUnitTaskMirror.JUnitResultFormatterMirror f) { | ||||
formatters.addElement(f); | formatters.addElement(f); | ||||
} | } | ||||
@@ -1058,39 +1045,30 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
final JUnitTest test) { | final JUnitTest test) { | ||||
runner.addFormatter(new JUnitResultFormatter() { | runner.addFormatter(new JUnitResultFormatter() { | ||||
@Override | |||||
public void startTestSuite(final JUnitTest suite) throws BuildException { | public void startTestSuite(final JUnitTest suite) throws BuildException { | ||||
} | } | ||||
@Override | |||||
public void endTestSuite(final JUnitTest suite) throws BuildException { | public void endTestSuite(final JUnitTest suite) throws BuildException { | ||||
} | } | ||||
@Override | |||||
public void setOutput(final OutputStream out) { | public void setOutput(final OutputStream out) { | ||||
} | } | ||||
@Override | |||||
public void setSystemOutput(final String out) { | public void setSystemOutput(final String out) { | ||||
} | } | ||||
@Override | |||||
public void setSystemError(final String err) { | public void setSystemError(final String err) { | ||||
} | } | ||||
@Override | |||||
public void addError(final Test arg0, final Throwable arg1) { | public void addError(final Test arg0, final Throwable arg1) { | ||||
} | } | ||||
@Override | |||||
public void addFailure(final Test arg0, final AssertionFailedError arg1) { | public void addFailure(final Test arg0, final AssertionFailedError arg1) { | ||||
} | } | ||||
@Override | |||||
public void endTest(final Test arg0) { | public void endTest(final Test arg0) { | ||||
} | } | ||||
@Override | |||||
public void startTest(final Test arg0) { | public void startTest(final Test arg0) { | ||||
registerTestCase(JUnitVersionHelper.getTestCaseName(arg0)); | registerTestCase(JUnitVersionHelper.getTestCaseName(arg0)); | ||||
} | } | ||||
@@ -43,7 +43,6 @@ public class TearDownOnVmCrash implements JUnitResultFormatter { | |||||
* Records the suite's name to later determine the class to invoke | * Records the suite's name to later determine the class to invoke | ||||
* tearDown on. | * tearDown on. | ||||
*/ | */ | ||||
@Override | |||||
public void startTestSuite(final JUnitTest suite) { | public void startTestSuite(final JUnitTest suite) { | ||||
suiteName = suite.getName(); | suiteName = suite.getName(); | ||||
if (suiteName != null && | if (suiteName != null && | ||||
@@ -58,7 +57,6 @@ public class TearDownOnVmCrash implements JUnitResultFormatter { | |||||
* test we get when a Batch fails and the error is an actual | * test we get when a Batch fails and the error is an actual | ||||
* error generated by Ant. | * error generated by Ant. | ||||
*/ | */ | ||||
@Override | |||||
public void addError(final Test fakeTest, final Throwable t) { | public void addError(final Test fakeTest, final Throwable t) { | ||||
if (suiteName != null | if (suiteName != null | ||||
&& fakeTest instanceof JUnitTaskMirrorImpl.VmExitErrorTest) { | && fakeTest instanceof JUnitTaskMirrorImpl.VmExitErrorTest) { | ||||
@@ -69,25 +67,18 @@ public class TearDownOnVmCrash implements JUnitResultFormatter { | |||||
// no need to implement the rest | // no need to implement the rest | ||||
public void addFailure(Test test, Throwable t) {} | public void addFailure(Test test, Throwable t) {} | ||||
@Override | |||||
public void addFailure(Test test, AssertionFailedError t) {} | public void addFailure(Test test, AssertionFailedError t) {} | ||||
@Override | |||||
public void startTest(Test test) {} | public void startTest(Test test) {} | ||||
@Override | |||||
public void endTest(Test test) {} | public void endTest(Test test) {} | ||||
@Override | |||||
public void endTestSuite(JUnitTest suite) {} | public void endTestSuite(JUnitTest suite) {} | ||||
@Override | |||||
public void setOutput(OutputStream out) {} | public void setOutput(OutputStream out) {} | ||||
@Override | |||||
public void setSystemOutput(String out) {} | public void setSystemOutput(String out) {} | ||||
@Override | |||||
public void setSystemError(String err) {} | public void setSystemError(String err) {} | ||||
private void tearDown() { | private void tearDown() { | ||||
@@ -109,19 +109,16 @@ public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstan | |||||
} | } | ||||
/** {@inheritDoc}. */ | /** {@inheritDoc}. */ | ||||
@Override | |||||
public void setOutput(OutputStream out) { | public void setOutput(OutputStream out) { | ||||
this.out = out; | this.out = out; | ||||
} | } | ||||
/** {@inheritDoc}. */ | /** {@inheritDoc}. */ | ||||
@Override | |||||
public void setSystemOutput(String out) { | public void setSystemOutput(String out) { | ||||
formatOutput(SYSTEM_OUT, out); | formatOutput(SYSTEM_OUT, out); | ||||
} | } | ||||
/** {@inheritDoc}. */ | /** {@inheritDoc}. */ | ||||
@Override | |||||
public void setSystemError(String out) { | public void setSystemError(String out) { | ||||
formatOutput(SYSTEM_ERR, out); | formatOutput(SYSTEM_ERR, out); | ||||
} | } | ||||
@@ -130,7 +127,6 @@ public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstan | |||||
* The whole testsuite started. | * The whole testsuite started. | ||||
* @param suite the testsuite. | * @param suite the testsuite. | ||||
*/ | */ | ||||
@Override | |||||
public void startTestSuite(JUnitTest suite) { | public void startTestSuite(JUnitTest suite) { | ||||
doc = getDocumentBuilder().newDocument(); | doc = getDocumentBuilder().newDocument(); | ||||
rootElement = doc.createElement(TESTSUITE); | rootElement = doc.createElement(TESTSUITE); | ||||
@@ -182,7 +178,6 @@ public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstan | |||||
* @param suite the testsuite. | * @param suite the testsuite. | ||||
* @throws BuildException on error. | * @throws BuildException on error. | ||||
*/ | */ | ||||
@Override | |||||
public void endTestSuite(JUnitTest suite) throws BuildException { | public void endTestSuite(JUnitTest suite) throws BuildException { | ||||
rootElement.setAttribute(ATTR_TESTS, "" + suite.runCount()); | rootElement.setAttribute(ATTR_TESTS, "" + suite.runCount()); | ||||
rootElement.setAttribute(ATTR_FAILURES, "" + suite.failureCount()); | rootElement.setAttribute(ATTR_FAILURES, "" + suite.failureCount()); | ||||
@@ -219,7 +214,6 @@ public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstan | |||||
* <p>A new Test is started. | * <p>A new Test is started. | ||||
* @param t the test. | * @param t the test. | ||||
*/ | */ | ||||
@Override | |||||
public void startTest(Test t) { | public void startTest(Test t) { | ||||
testStarts.put(createDescription(t), System.currentTimeMillis()); | testStarts.put(createDescription(t), System.currentTimeMillis()); | ||||
} | } | ||||
@@ -234,7 +228,6 @@ public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstan | |||||
* <p>A Test is finished. | * <p>A Test is finished. | ||||
* @param test the test. | * @param test the test. | ||||
*/ | */ | ||||
@Override | |||||
public void endTest(Test test) { | public void endTest(Test test) { | ||||
String testDescription = createDescription(test); | String testDescription = createDescription(test); | ||||
@@ -283,7 +276,6 @@ public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstan | |||||
* @param test the test. | * @param test the test. | ||||
* @param t the assertion. | * @param t the assertion. | ||||
*/ | */ | ||||
@Override | |||||
public void addFailure(Test test, AssertionFailedError t) { | public void addFailure(Test test, AssertionFailedError t) { | ||||
addFailure(test, (Throwable) t); | addFailure(test, (Throwable) t); | ||||
} | } | ||||
@@ -295,7 +287,6 @@ public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstan | |||||
* @param test the test. | * @param test the test. | ||||
* @param t the error. | * @param t the error. | ||||
*/ | */ | ||||
@Override | |||||
public void addError(Test test, Throwable t) { | public void addError(Test test, Throwable t) { | ||||
formatError(ERROR, test, t); | formatError(ERROR, test, t); | ||||
} | } | ||||
@@ -333,7 +324,6 @@ public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstan | |||||
nested.appendChild(doc.createCDATASection(output)); | nested.appendChild(doc.createCDATASection(output)); | ||||
} | } | ||||
@Override | |||||
public void testIgnored(Test test) { | public void testIgnored(Test test) { | ||||
formatSkip(test, JUnitVersionHelper.getIgnoreMessage(test)); | formatSkip(test, JUnitVersionHelper.getIgnoreMessage(test)); | ||||
if (test != null) { | if (test != null) { | ||||
@@ -364,7 +354,6 @@ public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstan | |||||
} | } | ||||
@Override | |||||
public void testAssumptionFailure(Test test, Throwable failure) { | public void testAssumptionFailure(Test test, Throwable failure) { | ||||
formatSkip(test, failure.getMessage()); | formatSkip(test, failure.getMessage()); | ||||
skippedTests.put(createDescription(test), test); | skippedTests.put(createDescription(test), test); | ||||
@@ -46,7 +46,6 @@ public class CutDirsMapper implements FileNameMapper { | |||||
* Empty implementation. | * Empty implementation. | ||||
* @param ignore ignored. | * @param ignore ignored. | ||||
*/ | */ | ||||
@Override | |||||
public void setFrom(final String ignore) { | public void setFrom(final String ignore) { | ||||
} | } | ||||
@@ -54,12 +53,10 @@ public class CutDirsMapper implements FileNameMapper { | |||||
* Empty implementation. | * Empty implementation. | ||||
* @param ignore ignored. | * @param ignore ignored. | ||||
*/ | */ | ||||
@Override | |||||
public void setTo(final String ignore) { | public void setTo(final String ignore) { | ||||
} | } | ||||
/** {@inheritDoc}. */ | /** {@inheritDoc}. */ | ||||
@Override | |||||
public String[] mapFileName(final String sourceFileName) { | public String[] mapFileName(final String sourceFileName) { | ||||
if (dirs <= 0) { | if (dirs <= 0) { | ||||
throw new BuildException("dirs must be set to a positive number"); | throw new BuildException("dirs must be set to a positive number"); | ||||
@@ -72,14 +72,13 @@ public class Archives extends DataType | |||||
/** | /** | ||||
* Sums the sizes of nested archives. | * Sums the sizes of nested archives. | ||||
*/ | */ | ||||
@Override | |||||
public int size() { | public int size() { | ||||
if (isReference()) { | if (isReference()) { | ||||
return ((Archives) getCheckedRef()).size(); | return ((Archives) getCheckedRef()).size(); | ||||
} | } | ||||
dieOnCircularReference(); | dieOnCircularReference(); | ||||
int total = 0; | int total = 0; | ||||
for (Iterator<ArchiveFileSet> i = grabArchives(); i.hasNext();) { | |||||
for (final Iterator<ArchiveFileSet> i = grabArchives(); i.hasNext();) { | |||||
total += i.next().size(); | total += i.next().size(); | ||||
} | } | ||||
return total; | return total; | ||||
@@ -88,14 +87,13 @@ public class Archives extends DataType | |||||
/** | /** | ||||
* Merges the nested collections. | * Merges the nested collections. | ||||
*/ | */ | ||||
@Override | |||||
public Iterator<Resource> iterator() { | public Iterator<Resource> iterator() { | ||||
if (isReference()) { | if (isReference()) { | ||||
return ((Archives) getCheckedRef()).iterator(); | return ((Archives) getCheckedRef()).iterator(); | ||||
} | } | ||||
dieOnCircularReference(); | dieOnCircularReference(); | ||||
List<Resource> l = new LinkedList<Resource>(); | |||||
for (Iterator<ArchiveFileSet> i = grabArchives(); i.hasNext();) { | |||||
final List<Resource> l = new LinkedList<Resource>(); | |||||
for (final Iterator<ArchiveFileSet> i = grabArchives(); i.hasNext();) { | |||||
l.addAll(CollectionUtils | l.addAll(CollectionUtils | ||||
.asCollection(i.next().iterator())); | .asCollection(i.next().iterator())); | ||||
} | } | ||||
@@ -105,7 +103,6 @@ public class Archives extends DataType | |||||
/** | /** | ||||
* @return false | * @return false | ||||
*/ | */ | ||||
@Override | |||||
public boolean isFilesystemOnly() { | public boolean isFilesystemOnly() { | ||||
if (isReference()) { | if (isReference()) { | ||||
return ((Archives) getCheckedRef()).isFilesystemOnly(); | return ((Archives) getCheckedRef()).isFilesystemOnly(); | ||||
@@ -119,7 +116,7 @@ public class Archives extends DataType | |||||
* @param r the Reference to set. | * @param r the Reference to set. | ||||
*/ | */ | ||||
@Override | @Override | ||||
public void setRefid(Reference r) { | |||||
public void setRefid(final Reference r) { | |||||
if (zips.getResourceCollections().size() > 0 | if (zips.getResourceCollections().size() > 0 | ||||
|| tars.getResourceCollections().size() > 0) { | || tars.getResourceCollections().size() > 0) { | ||||
throw tooManyAttributes(); | throw tooManyAttributes(); | ||||
@@ -135,11 +132,11 @@ public class Archives extends DataType | |||||
@Override | @Override | ||||
public Object clone() { | public Object clone() { | ||||
try { | try { | ||||
Archives a = (Archives) super.clone(); | |||||
final Archives a = (Archives) super.clone(); | |||||
a.zips = (Union) zips.clone(); | a.zips = (Union) zips.clone(); | ||||
a.tars = (Union) tars.clone(); | a.tars = (Union) tars.clone(); | ||||
return a; | return a; | ||||
} catch (CloneNotSupportedException e) { | |||||
} catch (final CloneNotSupportedException e) { | |||||
throw new BuildException(e); | throw new BuildException(e); | ||||
} | } | ||||
} | } | ||||
@@ -151,11 +148,11 @@ public class Archives extends DataType | |||||
* and returns an iterator over the collected archives. | * and returns an iterator over the collected archives. | ||||
*/ | */ | ||||
protected Iterator<ArchiveFileSet> grabArchives() { | protected Iterator<ArchiveFileSet> grabArchives() { | ||||
List<ArchiveFileSet> l = new LinkedList<ArchiveFileSet>(); | |||||
for (Resource r : zips) { | |||||
final List<ArchiveFileSet> l = new LinkedList<ArchiveFileSet>(); | |||||
for (final Resource r : zips) { | |||||
l.add(configureArchive(new ZipFileSet(), r)); | l.add(configureArchive(new ZipFileSet(), r)); | ||||
} | } | ||||
for (Resource r : tars) { | |||||
for (final Resource r : tars) { | |||||
l.add(configureArchive(new TarFileSet(), r)); | l.add(configureArchive(new TarFileSet(), r)); | ||||
} | } | ||||
return l.iterator(); | return l.iterator(); | ||||
@@ -165,8 +162,8 @@ public class Archives extends DataType | |||||
* Configures the archivefileset based on this type's settings, | * Configures the archivefileset based on this type's settings, | ||||
* set the source. | * set the source. | ||||
*/ | */ | ||||
protected ArchiveFileSet configureArchive(ArchiveFileSet afs, | |||||
Resource src) { | |||||
protected ArchiveFileSet configureArchive(final ArchiveFileSet afs, | |||||
final Resource src) { | |||||
afs.setProject(getProject()); | afs.setProject(getProject()); | ||||
afs.setSrcResource(src); | afs.setSrcResource(src); | ||||
return afs; | return afs; | ||||
@@ -180,7 +177,7 @@ public class Archives extends DataType | |||||
* @throws BuildException on error. | * @throws BuildException on error. | ||||
*/ | */ | ||||
@Override | @Override | ||||
protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) | |||||
protected synchronized void dieOnCircularReference(final Stack<Object> stk, final Project p) | |||||
throws BuildException { | throws BuildException { | ||||
if (isChecked()) { | if (isChecked()) { | ||||
return; | return; | ||||
@@ -46,7 +46,7 @@ public abstract class ContentTransformingResource extends ResourceDecorator { | |||||
* Constructor with another resource to wrap. | * Constructor with another resource to wrap. | ||||
* @param other the resource to wrap. | * @param other the resource to wrap. | ||||
*/ | */ | ||||
protected ContentTransformingResource(ResourceCollection other) { | |||||
protected ContentTransformingResource(final ResourceCollection other) { | |||||
super(other); | super(other); | ||||
} | } | ||||
@@ -61,14 +61,14 @@ public abstract class ContentTransformingResource extends ResourceDecorator { | |||||
InputStream in = null; | InputStream in = null; | ||||
try { | try { | ||||
in = getInputStream(); | in = getInputStream(); | ||||
byte[] buf = new byte[BUFFER_SIZE]; | |||||
final byte[] buf = new byte[BUFFER_SIZE]; | |||||
int size = 0; | int size = 0; | ||||
int readNow; | int readNow; | ||||
while ((readNow = in.read(buf, 0, buf.length)) > 0) { | while ((readNow = in.read(buf, 0, buf.length)) > 0) { | ||||
size += readNow; | size += readNow; | ||||
} | } | ||||
return size; | return size; | ||||
} catch (IOException ex) { | |||||
} catch (final IOException ex) { | |||||
throw new BuildException("caught exception while reading " | throw new BuildException("caught exception while reading " | ||||
+ getName(), ex); | + getName(), ex); | ||||
} finally { | } finally { | ||||
@@ -117,14 +117,13 @@ public abstract class ContentTransformingResource extends ResourceDecorator { | |||||
* Suppress FileProvider, re-implement Appendable | * Suppress FileProvider, re-implement Appendable | ||||
*/ | */ | ||||
@Override | @Override | ||||
public <T> T as(Class<T> clazz) { | |||||
public <T> T as(final Class<T> clazz) { | |||||
if (Appendable.class.isAssignableFrom(clazz)) { | if (Appendable.class.isAssignableFrom(clazz)) { | ||||
if (isAppendSupported()) { | if (isAppendSupported()) { | ||||
final Appendable a = | final Appendable a = | ||||
getResource().as(Appendable.class); | getResource().as(Appendable.class); | ||||
if (a != null) { | if (a != null) { | ||||
return clazz.cast(new Appendable() { | return clazz.cast(new Appendable() { | ||||
@Override | |||||
public OutputStream getAppendOutputStream() | public OutputStream getAppendOutputStream() | ||||
throws IOException { | throws IOException { | ||||
OutputStream out = a.getAppendOutputStream(); | OutputStream out = a.getAppendOutputStream(); | ||||
@@ -56,7 +56,7 @@ public class LazyResourceCollectionWrapper extends | |||||
protected int getSize() { | protected int getSize() { | ||||
// to compute the size, just iterate: the iterator will take care of | // to compute the size, just iterate: the iterator will take care of | ||||
// caching | // caching | ||||
Iterator<Resource> it = createIterator(); | |||||
final Iterator<Resource> it = createIterator(); | |||||
int size = 0; | int size = 0; | ||||
while (it.hasNext()) { | while (it.hasNext()) { | ||||
it.next(); | it.next(); | ||||
@@ -72,7 +72,7 @@ public class LazyResourceCollectionWrapper extends | |||||
* @param r resource considered for filtration | * @param r resource considered for filtration | ||||
* @return whether the resource should be filtered or not | * @return whether the resource should be filtered or not | ||||
*/ | */ | ||||
protected boolean filterResource(Resource r) { | |||||
protected boolean filterResource(final Resource r) { | |||||
return false; | return false; | ||||
} | } | ||||
@@ -84,11 +84,10 @@ public class LazyResourceCollectionWrapper extends | |||||
protected final Iterator<Resource> it; | protected final Iterator<Resource> it; | ||||
public FilteringIterator(Iterator<Resource> it) { | |||||
public FilteringIterator(final Iterator<Resource> it) { | |||||
this.it = it; | this.it = it; | ||||
} | } | ||||
@Override | |||||
public boolean hasNext() { | public boolean hasNext() { | ||||
if (ended) { | if (ended) { | ||||
return false; | return false; | ||||
@@ -106,17 +105,15 @@ public class LazyResourceCollectionWrapper extends | |||||
return true; | return true; | ||||
} | } | ||||
@Override | |||||
public Resource next() { | public Resource next() { | ||||
if (!hasNext()) { | if (!hasNext()) { | ||||
throw new UnsupportedOperationException(); | throw new UnsupportedOperationException(); | ||||
} | } | ||||
Resource r = next; | |||||
final Resource r = next; | |||||
next = null; | next = null; | ||||
return r; | return r; | ||||
} | } | ||||
@Override | |||||
public void remove() { | public void remove() { | ||||
throw new UnsupportedOperationException(); | throw new UnsupportedOperationException(); | ||||
} | } | ||||
@@ -139,11 +136,10 @@ public class LazyResourceCollectionWrapper extends | |||||
* the iterator which will provide the resources to put in | * the iterator which will provide the resources to put in | ||||
* cache | * cache | ||||
*/ | */ | ||||
public CachedIterator(Iterator<Resource> it) { | |||||
public CachedIterator(final Iterator<Resource> it) { | |||||
this.it = it; | this.it = it; | ||||
} | } | ||||
@Override | |||||
public boolean hasNext() { | public boolean hasNext() { | ||||
synchronized (cachedResources) { | synchronized (cachedResources) { | ||||
// have we already cached the next entry ? | // have we already cached the next entry ? | ||||
@@ -155,13 +151,12 @@ public class LazyResourceCollectionWrapper extends | |||||
return false; | return false; | ||||
} | } | ||||
// put in cache the next resource | // put in cache the next resource | ||||
Resource r = it.next(); | |||||
final Resource r = it.next(); | |||||
cachedResources.add(r); | cachedResources.add(r); | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
@Override | |||||
public Resource next() { | public Resource next() { | ||||
// first check that we have some to deliver | // first check that we have some to deliver | ||||
if (!hasNext()) { | if (!hasNext()) { | ||||
@@ -174,7 +169,6 @@ public class LazyResourceCollectionWrapper extends | |||||
} | } | ||||
} | } | ||||
@Override | |||||
public void remove() { | public void remove() { | ||||
throw new UnsupportedOperationException(); | throw new UnsupportedOperationException(); | ||||
} | } | ||||
@@ -44,7 +44,7 @@ public class MultiRootFileSet extends AbstractFileSet | |||||
private Union union; | private Union union; | ||||
@Override | @Override | ||||
public void setDir(File dir) { | |||||
public void setDir(final File dir) { | |||||
throw new BuildException(getDataTypeName() | throw new BuildException(getDataTypeName() | ||||
+ " doesn't support the dir attribute"); | + " doesn't support the dir attribute"); | ||||
} | } | ||||
@@ -53,7 +53,7 @@ public class MultiRootFileSet extends AbstractFileSet | |||||
* Determines the types of resources to return. | * Determines the types of resources to return. | ||||
* @param type the types of resources to return | * @param type the types of resources to return | ||||
*/ | */ | ||||
public void setType(SetType type) { | |||||
public void setType(final SetType type) { | |||||
if (isReference()) { | if (isReference()) { | ||||
throw tooManyAttributes(); | throw tooManyAttributes(); | ||||
} | } | ||||
@@ -64,7 +64,7 @@ public class MultiRootFileSet extends AbstractFileSet | |||||
* Set whether to cache collections. | * Set whether to cache collections. | ||||
* @param b boolean cache flag. | * @param b boolean cache flag. | ||||
*/ | */ | ||||
public synchronized void setCache(boolean b) { | |||||
public synchronized void setCache(final boolean b) { | |||||
if (isReference()) { | if (isReference()) { | ||||
throw tooManyAttributes(); | throw tooManyAttributes(); | ||||
} | } | ||||
@@ -75,13 +75,13 @@ public class MultiRootFileSet extends AbstractFileSet | |||||
* Adds basedirs as a comman separated list. | * Adds basedirs as a comman separated list. | ||||
* @param b boolean cache flag. | * @param b boolean cache flag. | ||||
*/ | */ | ||||
public void setBaseDirs(String dirs) { | |||||
public void setBaseDirs(final String dirs) { | |||||
if (isReference()) { | if (isReference()) { | ||||
throw tooManyAttributes(); | throw tooManyAttributes(); | ||||
} | } | ||||
if (dirs != null && dirs.length() > 0) { | if (dirs != null && dirs.length() > 0) { | ||||
String[] ds = dirs.split(","); | |||||
for (String d : ds) { | |||||
final String[] ds = dirs.split(","); | |||||
for (final String d : ds) { | |||||
baseDirs.add(getProject().resolveFile(d)); | baseDirs.add(getProject().resolveFile(d)); | ||||
} | } | ||||
} | } | ||||
@@ -90,7 +90,7 @@ public class MultiRootFileSet extends AbstractFileSet | |||||
/** | /** | ||||
* Adds a basedir as nested element. | * Adds a basedir as nested element. | ||||
*/ | */ | ||||
public void addConfiguredBaseDir(FileResource r) { | |||||
public void addConfiguredBaseDir(final FileResource r) { | |||||
if (isReference()) { | if (isReference()) { | ||||
throw noChildrenAllowed(); | throw noChildrenAllowed(); | ||||
} | } | ||||
@@ -98,7 +98,7 @@ public class MultiRootFileSet extends AbstractFileSet | |||||
} | } | ||||
@Override | @Override | ||||
public void setRefid(Reference r) { | |||||
public void setRefid(final Reference r) { | |||||
if (!baseDirs.isEmpty()) { | if (!baseDirs.isEmpty()) { | ||||
throw tooManyAttributes(); | throw tooManyAttributes(); | ||||
} | } | ||||
@@ -115,7 +115,7 @@ public class MultiRootFileSet extends AbstractFileSet | |||||
if (isReference()) { | if (isReference()) { | ||||
return ((MultiRootFileSet) getRef(getProject())).clone(); | return ((MultiRootFileSet) getRef(getProject())).clone(); | ||||
} else { | } else { | ||||
MultiRootFileSet fs = (MultiRootFileSet) super.clone(); | |||||
final MultiRootFileSet fs = (MultiRootFileSet) super.clone(); | |||||
fs.baseDirs = new ArrayList<File>(baseDirs); | fs.baseDirs = new ArrayList<File>(baseDirs); | ||||
fs.union = null; | fs.union = null; | ||||
return fs; | return fs; | ||||
@@ -126,7 +126,6 @@ public class MultiRootFileSet extends AbstractFileSet | |||||
* Fulfill the ResourceCollection contract. | * Fulfill the ResourceCollection contract. | ||||
* @return an Iterator of Resources. | * @return an Iterator of Resources. | ||||
*/ | */ | ||||
@Override | |||||
public Iterator<Resource> iterator() { | public Iterator<Resource> iterator() { | ||||
if (isReference()) { | if (isReference()) { | ||||
return ((MultiRootFileSet) getRef(getProject())).iterator(); | return ((MultiRootFileSet) getRef(getProject())).iterator(); | ||||
@@ -138,7 +137,6 @@ public class MultiRootFileSet extends AbstractFileSet | |||||
* Fulfill the ResourceCollection contract. | * Fulfill the ResourceCollection contract. | ||||
* @return number of elements as int. | * @return number of elements as int. | ||||
*/ | */ | ||||
@Override | |||||
public int size() { | public int size() { | ||||
if (isReference()) { | if (isReference()) { | ||||
return ((MultiRootFileSet) getRef(getProject())).size(); | return ((MultiRootFileSet) getRef(getProject())).size(); | ||||
@@ -150,7 +148,6 @@ public class MultiRootFileSet extends AbstractFileSet | |||||
* Always returns true. | * Always returns true. | ||||
* @return true indicating that all elements will be FileResources. | * @return true indicating that all elements will be FileResources. | ||||
*/ | */ | ||||
@Override | |||||
public boolean isFilesystemOnly() { | public boolean isFilesystemOnly() { | ||||
return true; | return true; | ||||
} | } | ||||
@@ -172,7 +169,7 @@ public class MultiRootFileSet extends AbstractFileSet | |||||
if (cache && union != null) { | if (cache && union != null) { | ||||
return union; | return union; | ||||
} | } | ||||
Union u = new Union(); | |||||
final Union u = new Union(); | |||||
setup(u); | setup(u); | ||||
if (cache) { | if (cache) { | ||||
union = u; | union = u; | ||||
@@ -180,8 +177,8 @@ public class MultiRootFileSet extends AbstractFileSet | |||||
return u; | return u; | ||||
} | } | ||||
private void setup(Union u) { | |||||
for (File d : baseDirs) { | |||||
private void setup(final Union u) { | |||||
for (final File d : baseDirs) { | |||||
u.add(new Worker(this, type, d)); | u.add(new Worker(this, type, d)); | ||||
} | } | ||||
} | } | ||||
@@ -198,26 +195,24 @@ public class MultiRootFileSet extends AbstractFileSet | |||||
private final SetType type; | private final SetType type; | ||||
private Worker(MultiRootFileSet fs, SetType type, File dir) { | |||||
private Worker(final MultiRootFileSet fs, final SetType type, final File dir) { | |||||
super(fs); | super(fs); | ||||
this.type = type; | this.type = type; | ||||
setDir(dir); | setDir(dir); | ||||
} | } | ||||
@Override | |||||
public boolean isFilesystemOnly() { | public boolean isFilesystemOnly() { | ||||
return true; | return true; | ||||
} | } | ||||
@Override | |||||
public Iterator<Resource> iterator() { | public Iterator<Resource> iterator() { | ||||
DirectoryScanner ds = getDirectoryScanner(getProject()); | |||||
final DirectoryScanner ds = getDirectoryScanner(getProject()); | |||||
String[] names = type == SetType.file | String[] names = type == SetType.file | ||||
? ds.getIncludedFiles() | ? ds.getIncludedFiles() | ||||
: ds.getIncludedDirectories(); | : ds.getIncludedDirectories(); | ||||
if (type == SetType.both) { | if (type == SetType.both) { | ||||
String[] files = ds.getIncludedFiles(); | |||||
String[] merged = new String[names.length + files.length]; | |||||
final String[] files = ds.getIncludedFiles(); | |||||
final String[] merged = new String[names.length + files.length]; | |||||
System.arraycopy(names, 0, merged, 0, names.length); | System.arraycopy(names, 0, merged, 0, names.length); | ||||
System.arraycopy(files, 0, merged, names.length, files.length); | System.arraycopy(files, 0, merged, names.length, files.length); | ||||
names = merged; | names = merged; | ||||
@@ -226,9 +221,8 @@ public class MultiRootFileSet extends AbstractFileSet | |||||
names); | names); | ||||
} | } | ||||
@Override | |||||
public int size() { | public int size() { | ||||
DirectoryScanner ds = getDirectoryScanner(getProject()); | |||||
final DirectoryScanner ds = getDirectoryScanner(getProject()); | |||||
int count = type == SetType.file | int count = type == SetType.file | ||||
? ds.getIncludedFilesCount() | ? ds.getIncludedFilesCount() | ||||
: ds.getIncludedDirsCount(); | : ds.getIncludedDirsCount(); | ||||
@@ -99,7 +99,6 @@ public class Type implements ResourceSelector { | |||||
* @param r the Resource to check. | * @param r the Resource to check. | ||||
* @return whether the Resource was selected. | * @return whether the Resource was selected. | ||||
*/ | */ | ||||
@Override | |||||
public boolean isSelected(final Resource r) { | public boolean isSelected(final Resource r) { | ||||
if (type == null) { | if (type == null) { | ||||
throw new BuildException("The type attribute is required."); | throw new BuildException("The type attribute is required."); | ||||
@@ -145,11 +145,9 @@ public class ResourceUtils { | |||||
logFuture(logTo, source, granularity); | logFuture(logTo, source, granularity); | ||||
final ResourceSelectorProvider p = | final ResourceSelectorProvider p = | ||||
new ResourceSelectorProvider() { | new ResourceSelectorProvider() { | ||||
@Override | |||||
public ResourceSelector | public ResourceSelector | ||||
getTargetSelectorForSource(final Resource sr) { | getTargetSelectorForSource(final Resource sr) { | ||||
return new ResourceSelector() { | return new ResourceSelector() { | ||||
@Override | |||||
public boolean isSelected(final Resource target) { | public boolean isSelected(final Resource target) { | ||||
/* Extra I/O, probably wasted: | /* Extra I/O, probably wasted: | ||||
if (target.isDirectory()) { | if (target.isDirectory()) { | ||||
@@ -70,7 +70,7 @@ public class SymbolicLinkUtils { | |||||
* @return true if the file is a symbolic link. | * @return true if the file is a symbolic link. | ||||
* @throws IOException on error. | * @throws IOException on error. | ||||
*/ | */ | ||||
public boolean isSymbolicLink(File file) throws IOException { | |||||
public boolean isSymbolicLink(final File file) throws IOException { | |||||
return isSymbolicLink(file.getParentFile(), file.getName()); | return isSymbolicLink(file.getParentFile(), file.getName()); | ||||
} | } | ||||
@@ -86,7 +86,7 @@ public class SymbolicLinkUtils { | |||||
* @return true if the file is a symbolic link. | * @return true if the file is a symbolic link. | ||||
* @throws IOException on error. | * @throws IOException on error. | ||||
*/ | */ | ||||
public boolean isSymbolicLink(String name) throws IOException { | |||||
public boolean isSymbolicLink(final String name) throws IOException { | |||||
return isSymbolicLink(new File(name)); | return isSymbolicLink(new File(name)); | ||||
} | } | ||||
@@ -103,9 +103,9 @@ public class SymbolicLinkUtils { | |||||
* @return true if the file is a symbolic link. | * @return true if the file is a symbolic link. | ||||
* @throws IOException on error. | * @throws IOException on error. | ||||
*/ | */ | ||||
public boolean isSymbolicLink(File parent, String name) | |||||
public boolean isSymbolicLink(final File parent, final String name) | |||||
throws IOException { | throws IOException { | ||||
File toTest = parent != null | |||||
final File toTest = parent != null | |||||
? new File(parent.getCanonicalPath(), name) | ? new File(parent.getCanonicalPath(), name) | ||||
: new File(name); | : new File(name); | ||||
return !toTest.getAbsolutePath().equals(toTest.getCanonicalPath()); | return !toTest.getAbsolutePath().equals(toTest.getCanonicalPath()); | ||||
@@ -128,7 +128,7 @@ public class SymbolicLinkUtils { | |||||
* @return true if the file is a broken symbolic link. | * @return true if the file is a broken symbolic link. | ||||
* @throws IOException on error. | * @throws IOException on error. | ||||
*/ | */ | ||||
public boolean isDanglingSymbolicLink(String name) throws IOException { | |||||
public boolean isDanglingSymbolicLink(final String name) throws IOException { | |||||
return isDanglingSymbolicLink(new File(name)); | return isDanglingSymbolicLink(new File(name)); | ||||
} | } | ||||
@@ -149,7 +149,7 @@ public class SymbolicLinkUtils { | |||||
* @return true if the file is a broken symbolic link. | * @return true if the file is a broken symbolic link. | ||||
* @throws IOException on error. | * @throws IOException on error. | ||||
*/ | */ | ||||
public boolean isDanglingSymbolicLink(File file) throws IOException { | |||||
public boolean isDanglingSymbolicLink(final File file) throws IOException { | |||||
return isDanglingSymbolicLink(file.getParentFile(), file.getName()); | return isDanglingSymbolicLink(file.getParentFile(), file.getName()); | ||||
} | } | ||||
@@ -171,14 +171,13 @@ public class SymbolicLinkUtils { | |||||
* @return true if the file is a broken symbolic link. | * @return true if the file is a broken symbolic link. | ||||
* @throws IOException on error. | * @throws IOException on error. | ||||
*/ | */ | ||||
public boolean isDanglingSymbolicLink(File parent, String name) | |||||
public boolean isDanglingSymbolicLink(final File parent, final String name) | |||||
throws IOException { | throws IOException { | ||||
File f = new File(parent, name); | |||||
final File f = new File(parent, name); | |||||
if (!f.exists()) { | if (!f.exists()) { | ||||
final String localName = f.getName(); | final String localName = f.getName(); | ||||
String[] c = parent.list(new FilenameFilter() { | |||||
@Override | |||||
public boolean accept(File d, String n) { | |||||
final String[] c = parent.list(new FilenameFilter() { | |||||
public boolean accept(final File d, final String n) { | |||||
return localName.equals(n); | return localName.equals(n); | ||||
} | } | ||||
}); | }); | ||||
@@ -214,7 +213,7 @@ public class SymbolicLinkUtils { | |||||
* fail. | * fail. | ||||
* @throws BuildException if the execution of "rm" failed. | * @throws BuildException if the execution of "rm" failed. | ||||
*/ | */ | ||||
public void deleteSymbolicLink(File link, Task task) | |||||
public void deleteSymbolicLink(File link, final Task task) | |||||
throws IOException { | throws IOException { | ||||
if (isDanglingSymbolicLink(link)) { | if (isDanglingSymbolicLink(link)) { | ||||
if (!link.delete()) { | if (!link.delete()) { | ||||
@@ -234,7 +233,7 @@ public class SymbolicLinkUtils { | |||||
} | } | ||||
// find the resource of the existing link: | // find the resource of the existing link: | ||||
File target = link.getCanonicalFile(); | |||||
final File target = link.getCanonicalFile(); | |||||
// no reason to try the renaming algorithm if we aren't allowed to | // no reason to try the renaming algorithm if we aren't allowed to | ||||
// write to the target's parent directory. Let's hope that | // write to the target's parent directory. Let's hope that | ||||
@@ -243,7 +242,7 @@ public class SymbolicLinkUtils { | |||||
if (task == null || target.getParentFile().canWrite()) { | if (task == null || target.getParentFile().canWrite()) { | ||||
// rename the resource, thus breaking the link: | // rename the resource, thus breaking the link: | ||||
File temp = FILE_UTILS.createTempFile("symlink", ".tmp", | |||||
final File temp = FILE_UTILS.createTempFile("symlink", ".tmp", | |||||
target.getParentFile(), false, | target.getParentFile(), false, | ||||
false); | false); | ||||
@@ -259,7 +258,7 @@ public class SymbolicLinkUtils { | |||||
try { | try { | ||||
FILE_UTILS.rename(target, temp); | FILE_UTILS.rename(target, temp); | ||||
renamedTarget = true; | renamedTarget = true; | ||||
} catch (IOException e) { | |||||
} catch (final IOException e) { | |||||
throw new IOException("Couldn't rename resource when " | throw new IOException("Couldn't rename resource when " | ||||
+ "attempting to delete '" + link | + "attempting to delete '" + link | ||||
+ "'. Reason: " + e.getMessage()); | + "'. Reason: " + e.getMessage()); | ||||
@@ -276,7 +275,7 @@ public class SymbolicLinkUtils { | |||||
// return the resource to its original name: | // return the resource to its original name: | ||||
try { | try { | ||||
FILE_UTILS.rename(temp, target); | FILE_UTILS.rename(temp, target); | ||||
} catch (IOException e) { | |||||
} catch (final IOException e) { | |||||
throw new IOException("Couldn't return resource " | throw new IOException("Couldn't return resource " | ||||
+ temp | + temp | ||||
+ " to its original name: " | + " to its original name: " | ||||
@@ -46,13 +46,11 @@ public class TarUtils { | |||||
* Encapsulates the algorithms used up to Ant 1.8 as ZipEncoding. | * Encapsulates the algorithms used up to Ant 1.8 as ZipEncoding. | ||||
*/ | */ | ||||
static final ZipEncoding FALLBACK_ENCODING = new ZipEncoding() { | static final ZipEncoding FALLBACK_ENCODING = new ZipEncoding() { | ||||
@Override | |||||
public boolean canEncode(String name) { return true; } | |||||
public boolean canEncode(final String name) { return true; } | |||||
@Override | |||||
public ByteBuffer encode(String name) { | |||||
public ByteBuffer encode(final String name) { | |||||
final int length = name.length(); | final int length = name.length(); | ||||
byte[] buf = new byte[length]; | |||||
final byte[] buf = new byte[length]; | |||||
// copy until end of input or output is reached. | // copy until end of input or output is reached. | ||||
for (int i = 0; i < length; ++i) { | for (int i = 0; i < length; ++i) { | ||||
@@ -61,13 +59,12 @@ public class TarUtils { | |||||
return ByteBuffer.wrap(buf); | return ByteBuffer.wrap(buf); | ||||
} | } | ||||
@Override | |||||
public String decode(byte[] buffer) { | |||||
public String decode(final byte[] buffer) { | |||||
final int length = buffer.length; | final int length = buffer.length; | ||||
StringBuilder result = new StringBuilder(length); | |||||
final StringBuilder result = new StringBuilder(length); | |||||
for (int i = 0; i < length; ++i) { | for (int i = 0; i < length; ++i) { | ||||
byte b = buffer[i]; | |||||
final byte b = buffer[i]; | |||||
if (b == 0) { // Trailing null | if (b == 0) { // Trailing null | ||||
break; | break; | ||||
} | } | ||||
@@ -203,7 +200,7 @@ public class TarUtils { | |||||
final int offset, | final int offset, | ||||
final int length, | final int length, | ||||
final boolean negative) { | final boolean negative) { | ||||
byte[] remainder = new byte[length - 1]; | |||||
final byte[] remainder = new byte[length - 1]; | |||||
System.arraycopy(buffer, offset + 1, remainder, 0, length - 1); | System.arraycopy(buffer, offset + 1, remainder, 0, length - 1); | ||||
BigInteger val = new BigInteger(remainder); | BigInteger val = new BigInteger(remainder); | ||||
if (negative) { | if (negative) { | ||||
@@ -234,8 +231,8 @@ public class TarUtils { | |||||
} | } | ||||
// Helper method to generate the exception message | // Helper method to generate the exception message | ||||
private static String exceptionMessage(byte[] buffer, final int offset, | |||||
final int length, int current, final byte currentByte) { | |||||
private static String exceptionMessage(final byte[] buffer, final int offset, | |||||
final int length, final int current, final byte currentByte) { | |||||
// default charset is good enough for an exception message, | // default charset is good enough for an exception message, | ||||
// | // | ||||
// the alternative was to modify parseOctal and | // the alternative was to modify parseOctal and | ||||
@@ -260,13 +257,13 @@ public class TarUtils { | |||||
* @param length The maximum number of bytes to parse. | * @param length The maximum number of bytes to parse. | ||||
* @return The entry name. | * @return The entry name. | ||||
*/ | */ | ||||
public static String parseName(byte[] buffer, final int offset, final int length) { | |||||
public static String parseName(final byte[] buffer, final int offset, final int length) { | |||||
try { | try { | ||||
return parseName(buffer, offset, length, DEFAULT_ENCODING); | return parseName(buffer, offset, length, DEFAULT_ENCODING); | ||||
} catch (IOException ex) { | |||||
} catch (final IOException ex) { | |||||
try { | try { | ||||
return parseName(buffer, offset, length, FALLBACK_ENCODING); | return parseName(buffer, offset, length, FALLBACK_ENCODING); | ||||
} catch (IOException ex2) { | |||||
} catch (final IOException ex2) { | |||||
// impossible | // impossible | ||||
throw new RuntimeException(ex2); | throw new RuntimeException(ex2); | ||||
} | } | ||||
@@ -284,7 +281,7 @@ public class TarUtils { | |||||
* @param encoding name of the encoding to use for file names | * @param encoding name of the encoding to use for file names | ||||
* @return The entry name. | * @return The entry name. | ||||
*/ | */ | ||||
public static String parseName(byte[] buffer, final int offset, | |||||
public static String parseName(final byte[] buffer, final int offset, | |||||
final int length, | final int length, | ||||
final ZipEncoding encoding) | final ZipEncoding encoding) | ||||
throws IOException { | throws IOException { | ||||
@@ -296,7 +293,7 @@ public class TarUtils { | |||||
} | } | ||||
} | } | ||||
if (len > 0) { | if (len > 0) { | ||||
byte[] b = new byte[len]; | |||||
final byte[] b = new byte[len]; | |||||
System.arraycopy(buffer, offset, b, 0, len); | System.arraycopy(buffer, offset, b, 0, len); | ||||
return encoding.decode(b); | return encoding.decode(b); | ||||
} | } | ||||
@@ -318,14 +315,14 @@ public class TarUtils { | |||||
* @param length The maximum number of header bytes to copy. | * @param length The maximum number of header bytes to copy. | ||||
* @return The updated offset, i.e. offset + length | * @return The updated offset, i.e. offset + length | ||||
*/ | */ | ||||
public static int formatNameBytes(String name, byte[] buf, final int offset, final int length) { | |||||
public static int formatNameBytes(final String name, final byte[] buf, final int offset, final int length) { | |||||
try { | try { | ||||
return formatNameBytes(name, buf, offset, length, DEFAULT_ENCODING); | return formatNameBytes(name, buf, offset, length, DEFAULT_ENCODING); | ||||
} catch (IOException ex) { | |||||
} catch (final IOException ex) { | |||||
try { | try { | ||||
return formatNameBytes(name, buf, offset, length, | return formatNameBytes(name, buf, offset, length, | ||||
FALLBACK_ENCODING); | FALLBACK_ENCODING); | ||||
} catch (IOException ex2) { | |||||
} catch (final IOException ex2) { | |||||
// impossible | // impossible | ||||
throw new RuntimeException(ex2); | throw new RuntimeException(ex2); | ||||
} | } | ||||
@@ -348,7 +345,7 @@ public class TarUtils { | |||||
* @param encoding name of the encoding to use for file names | * @param encoding name of the encoding to use for file names | ||||
* @return The updated offset, i.e. offset + length | * @return The updated offset, i.e. offset + length | ||||
*/ | */ | ||||
public static int formatNameBytes(String name, byte[] buf, final int offset, | |||||
public static int formatNameBytes(final String name, final byte[] buf, final int offset, | |||||
final int length, | final int length, | ||||
final ZipEncoding encoding) | final ZipEncoding encoding) | ||||
throws IOException { | throws IOException { | ||||
@@ -377,7 +374,7 @@ public class TarUtils { | |||||
* @param length length of buffer to fill | * @param length length of buffer to fill | ||||
* @throws IllegalArgumentException if the value will not fit in the buffer | * @throws IllegalArgumentException if the value will not fit in the buffer | ||||
*/ | */ | ||||
public static void formatUnsignedOctalString(final long value, byte[] buffer, | |||||
public static void formatUnsignedOctalString(final long value, final byte[] buffer, | |||||
final int offset, final int length) { | final int offset, final int length) { | ||||
int remaining = length; | int remaining = length; | ||||
remaining--; | remaining--; | ||||
@@ -416,7 +413,7 @@ public class TarUtils { | |||||
* @return The updated offset, i.e offset+length | * @return The updated offset, i.e offset+length | ||||
* @throws IllegalArgumentException if the value (and trailer) will not fit in the buffer | * @throws IllegalArgumentException if the value (and trailer) will not fit in the buffer | ||||
*/ | */ | ||||
public static int formatOctalBytes(final long value, byte[] buf, final int offset, final int length) { | |||||
public static int formatOctalBytes(final long value, final byte[] buf, final int offset, final int length) { | |||||
int idx=length-2; // For space and trailing null | int idx=length-2; // For space and trailing null | ||||
formatUnsignedOctalString(value, buf, offset, idx); | formatUnsignedOctalString(value, buf, offset, idx); | ||||
@@ -441,9 +438,9 @@ public class TarUtils { | |||||
* @return The updated offset | * @return The updated offset | ||||
* @throws IllegalArgumentException if the value (and trailer) will not fit in the buffer | * @throws IllegalArgumentException if the value (and trailer) will not fit in the buffer | ||||
*/ | */ | ||||
public static int formatLongOctalBytes(final long value, byte[] buf, final int offset, final int length) { | |||||
public static int formatLongOctalBytes(final long value, final byte[] buf, final int offset, final int length) { | |||||
int idx=length-1; // For space | |||||
final int idx=length-1; // For space | |||||
formatUnsignedOctalString(value, buf, offset, idx); | formatUnsignedOctalString(value, buf, offset, idx); | ||||
buf[offset + idx] = (byte) ' '; // Trailing space | buf[offset + idx] = (byte) ' '; // Trailing space | ||||
@@ -468,7 +465,7 @@ public class TarUtils { | |||||
* will not fit in the buffer. | * will not fit in the buffer. | ||||
*/ | */ | ||||
public static int formatLongOctalOrBinaryBytes( | public static int formatLongOctalOrBinaryBytes( | ||||
final long value, byte[] buf, final int offset, final int length) { | |||||
final long value, final byte[] buf, final int offset, final int length) { | |||||
// Check whether we are dealing with UID/GID or SIZE field | // Check whether we are dealing with UID/GID or SIZE field | ||||
final long maxAsOctalChar = length == TarConstants.UIDLEN ? TarConstants.MAXID : TarConstants.MAXSIZE; | final long maxAsOctalChar = length == TarConstants.UIDLEN ? TarConstants.MAXID : TarConstants.MAXSIZE; | ||||
@@ -487,7 +484,7 @@ public class TarUtils { | |||||
return offset + length; | return offset + length; | ||||
} | } | ||||
private static void formatLongBinary(final long value, byte[] buf, | |||||
private static void formatLongBinary(final long value, final byte[] buf, | |||||
final int offset, final int length, | final int offset, final int length, | ||||
final boolean negative) { | final boolean negative) { | ||||
final int bits = (length - 1) * 8; | final int bits = (length - 1) * 8; | ||||
@@ -508,11 +505,11 @@ public class TarUtils { | |||||
} | } | ||||
} | } | ||||
private static void formatBigIntegerBinary(final long value, byte[] buf, | |||||
private static void formatBigIntegerBinary(final long value, final byte[] buf, | |||||
final int offset, | final int offset, | ||||
final int length, | final int length, | ||||
final boolean negative) { | final boolean negative) { | ||||
BigInteger val = BigInteger.valueOf(value); | |||||
final BigInteger val = BigInteger.valueOf(value); | |||||
final byte[] b = val.toByteArray(); | final byte[] b = val.toByteArray(); | ||||
final int len = b.length; | final int len = b.length; | ||||
final int off = offset + length - len; | final int off = offset + length - len; | ||||
@@ -537,7 +534,7 @@ public class TarUtils { | |||||
* @return The updated value of offset, i.e. offset+length | * @return The updated value of offset, i.e. offset+length | ||||
* @throws IllegalArgumentException if the value (and trailer) will not fit in the buffer | * @throws IllegalArgumentException if the value (and trailer) will not fit in the buffer | ||||
*/ | */ | ||||
public static int formatCheckSumOctalBytes(final long value, byte[] buf, final int offset, final int length) { | |||||
public static int formatCheckSumOctalBytes(final long value, final byte[] buf, final int offset, final int length) { | |||||
int idx=length-2; // for NUL and space | int idx=length-2; // for NUL and space | ||||
formatUnsignedOctalString(value, buf, offset, idx); | formatUnsignedOctalString(value, buf, offset, idx); | ||||
@@ -557,7 +554,7 @@ public class TarUtils { | |||||
public static long computeCheckSum(final byte[] buf) { | public static long computeCheckSum(final byte[] buf) { | ||||
long sum = 0; | long sum = 0; | ||||
for (byte element : buf) { | |||||
for (final byte element : buf) { | |||||
sum += BYTE_MASK & element; | sum += BYTE_MASK & element; | ||||
} | } | ||||
@@ -45,15 +45,15 @@ public abstract class AbstractUnicodeExtraField implements ZipExtraField { | |||||
* @param len The length of the encoded filename or commentin | * @param len The length of the encoded filename or commentin | ||||
* <code>bytes</code>. | * <code>bytes</code>. | ||||
*/ | */ | ||||
protected AbstractUnicodeExtraField(String text, byte[] bytes, int off, | |||||
int len) { | |||||
CRC32 crc32 = new CRC32(); | |||||
protected AbstractUnicodeExtraField(final String text, final byte[] bytes, final int off, | |||||
final int len) { | |||||
final CRC32 crc32 = new CRC32(); | |||||
crc32.update(bytes, off, len); | crc32.update(bytes, off, len); | ||||
nameCRC32 = crc32.getValue(); | nameCRC32 = crc32.getValue(); | ||||
try { | try { | ||||
unicodeName = text.getBytes("UTF-8"); | unicodeName = text.getBytes("UTF-8"); | ||||
} catch (UnsupportedEncodingException e) { | |||||
} catch (final UnsupportedEncodingException e) { | |||||
throw new RuntimeException("FATAL: UTF-8 encoding not supported.", | throw new RuntimeException("FATAL: UTF-8 encoding not supported.", | ||||
e); | e); | ||||
} | } | ||||
@@ -67,7 +67,7 @@ public abstract class AbstractUnicodeExtraField implements ZipExtraField { | |||||
* @param bytes The encoded of the filename or comment in the zip | * @param bytes The encoded of the filename or comment in the zip | ||||
* file. | * file. | ||||
*/ | */ | ||||
protected AbstractUnicodeExtraField(String text, byte[] bytes) { | |||||
protected AbstractUnicodeExtraField(final String text, final byte[] bytes) { | |||||
this(text, bytes, 0, bytes.length); | this(text, bytes, 0, bytes.length); | ||||
} | } | ||||
@@ -96,7 +96,7 @@ public abstract class AbstractUnicodeExtraField implements ZipExtraField { | |||||
* @param nameCRC32 The CRC32 checksum of the filename as encoded | * @param nameCRC32 The CRC32 checksum of the filename as encoded | ||||
* in the central directory of the zip file to set. | * in the central directory of the zip file to set. | ||||
*/ | */ | ||||
public void setNameCRC32(long nameCRC32) { | |||||
public void setNameCRC32(final long nameCRC32) { | |||||
this.nameCRC32 = nameCRC32; | this.nameCRC32 = nameCRC32; | ||||
data = null; | data = null; | ||||
} | } | ||||
@@ -116,7 +116,7 @@ public abstract class AbstractUnicodeExtraField implements ZipExtraField { | |||||
/** | /** | ||||
* @param unicodeName The utf-8 encoded name to set. | * @param unicodeName The utf-8 encoded name to set. | ||||
*/ | */ | ||||
public void setUnicodeName(byte[] unicodeName) { | |||||
public void setUnicodeName(final byte[] unicodeName) { | |||||
if (unicodeName != null) { | if (unicodeName != null) { | ||||
this.unicodeName = new byte[unicodeName.length]; | this.unicodeName = new byte[unicodeName.length]; | ||||
System.arraycopy(unicodeName, 0, this.unicodeName, 0, | System.arraycopy(unicodeName, 0, this.unicodeName, 0, | ||||
@@ -128,7 +128,6 @@ public abstract class AbstractUnicodeExtraField implements ZipExtraField { | |||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
@Override | |||||
public byte[] getCentralDirectoryData() { | public byte[] getCentralDirectoryData() { | ||||
if (data == null) { | if (data == null) { | ||||
this.assembleData(); | this.assembleData(); | ||||
@@ -142,7 +141,6 @@ public abstract class AbstractUnicodeExtraField implements ZipExtraField { | |||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
@Override | |||||
public ZipShort getCentralDirectoryLength() { | public ZipShort getCentralDirectoryLength() { | ||||
if (data == null) { | if (data == null) { | ||||
assembleData(); | assembleData(); | ||||
@@ -151,20 +149,17 @@ public abstract class AbstractUnicodeExtraField implements ZipExtraField { | |||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
@Override | |||||
public byte[] getLocalFileDataData() { | public byte[] getLocalFileDataData() { | ||||
return getCentralDirectoryData(); | return getCentralDirectoryData(); | ||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
@Override | |||||
public ZipShort getLocalFileDataLength() { | public ZipShort getLocalFileDataLength() { | ||||
return getCentralDirectoryLength(); | return getCentralDirectoryLength(); | ||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
@Override | |||||
public void parseFromLocalFileData(byte[] buffer, int offset, int length) | |||||
public void parseFromLocalFileData(final byte[] buffer, final int offset, final int length) | |||||
throws ZipException { | throws ZipException { | ||||
if (length < 5) { | if (length < 5) { | ||||
@@ -172,7 +167,7 @@ public abstract class AbstractUnicodeExtraField implements ZipExtraField { | |||||
+ " 5 bytes."); | + " 5 bytes."); | ||||
} | } | ||||
int version = buffer[offset]; | |||||
final int version = buffer[offset]; | |||||
if (version != 0x01) { | if (version != 0x01) { | ||||
throw new ZipException("Unsupported version [" + version | throw new ZipException("Unsupported version [" + version | ||||
@@ -56,7 +56,7 @@ class FallbackZipEncoding implements ZipEncoding { | |||||
* @param charset The name of the charset or {@code null} for | * @param charset The name of the charset or {@code null} for | ||||
* the platform's default character set. | * the platform's default character set. | ||||
*/ | */ | ||||
public FallbackZipEncoding(String charset) { | |||||
public FallbackZipEncoding(final String charset) { | |||||
this.charset = charset; | this.charset = charset; | ||||
} | } | ||||
@@ -64,8 +64,7 @@ class FallbackZipEncoding implements ZipEncoding { | |||||
* @see | * @see | ||||
* org.apache.tools.zip.ZipEncoding#canEncode(java.lang.String) | * org.apache.tools.zip.ZipEncoding#canEncode(java.lang.String) | ||||
*/ | */ | ||||
@Override | |||||
public boolean canEncode(String name) { | |||||
public boolean canEncode(final String name) { | |||||
return true; | return true; | ||||
} | } | ||||
@@ -73,8 +72,7 @@ class FallbackZipEncoding implements ZipEncoding { | |||||
* @see | * @see | ||||
* org.apache.tools.zip.ZipEncoding#encode(java.lang.String) | * org.apache.tools.zip.ZipEncoding#encode(java.lang.String) | ||||
*/ | */ | ||||
@Override | |||||
public ByteBuffer encode(String name) throws IOException { | |||||
public ByteBuffer encode(final String name) throws IOException { | |||||
if (this.charset == null) { // i.e. use default charset, see no-args constructor | if (this.charset == null) { // i.e. use default charset, see no-args constructor | ||||
return ByteBuffer.wrap(name.getBytes()); | return ByteBuffer.wrap(name.getBytes()); | ||||
} else { | } else { | ||||
@@ -86,8 +84,7 @@ class FallbackZipEncoding implements ZipEncoding { | |||||
* @see | * @see | ||||
* org.apache.tools.zip.ZipEncoding#decode(byte[]) | * org.apache.tools.zip.ZipEncoding#decode(byte[]) | ||||
*/ | */ | ||||
@Override | |||||
public String decode(byte[] data) throws IOException { | |||||
public String decode(final byte[] data) throws IOException { | |||||
if (this.charset == null) { // i.e. use default charset, see no-args constructor | if (this.charset == null) { // i.e. use default charset, see no-args constructor | ||||
return new String(data); | return new String(data); | ||||
} else { | } else { | ||||
@@ -46,7 +46,7 @@ class NioZipEncoding implements ZipEncoding { | |||||
* | * | ||||
* @param charset The NIO charset to wrap. | * @param charset The NIO charset to wrap. | ||||
*/ | */ | ||||
public NioZipEncoding(Charset charset) { | |||||
public NioZipEncoding(final Charset charset) { | |||||
this.charset = charset; | this.charset = charset; | ||||
} | } | ||||
@@ -54,9 +54,8 @@ class NioZipEncoding implements ZipEncoding { | |||||
* @see | * @see | ||||
* org.apache.tools.zip.ZipEncoding#canEncode(java.lang.String) | * org.apache.tools.zip.ZipEncoding#canEncode(java.lang.String) | ||||
*/ | */ | ||||
@Override | |||||
public boolean canEncode(String name) { | |||||
CharsetEncoder enc = this.charset.newEncoder(); | |||||
public boolean canEncode(final String name) { | |||||
final CharsetEncoder enc = this.charset.newEncoder(); | |||||
enc.onMalformedInput(CodingErrorAction.REPORT); | enc.onMalformedInput(CodingErrorAction.REPORT); | ||||
enc.onUnmappableCharacter(CodingErrorAction.REPORT); | enc.onUnmappableCharacter(CodingErrorAction.REPORT); | ||||
@@ -67,19 +66,18 @@ class NioZipEncoding implements ZipEncoding { | |||||
* @see | * @see | ||||
* org.apache.tools.zip.ZipEncoding#encode(java.lang.String) | * org.apache.tools.zip.ZipEncoding#encode(java.lang.String) | ||||
*/ | */ | ||||
@Override | |||||
public ByteBuffer encode(String name) { | |||||
CharsetEncoder enc = this.charset.newEncoder(); | |||||
public ByteBuffer encode(final String name) { | |||||
final CharsetEncoder enc = this.charset.newEncoder(); | |||||
enc.onMalformedInput(CodingErrorAction.REPORT); | enc.onMalformedInput(CodingErrorAction.REPORT); | ||||
enc.onUnmappableCharacter(CodingErrorAction.REPORT); | enc.onUnmappableCharacter(CodingErrorAction.REPORT); | ||||
CharBuffer cb = CharBuffer.wrap(name); | |||||
final CharBuffer cb = CharBuffer.wrap(name); | |||||
ByteBuffer out = ByteBuffer.allocate(name.length() | ByteBuffer out = ByteBuffer.allocate(name.length() | ||||
+ (name.length() + 1) / 2); | + (name.length() + 1) / 2); | ||||
while (cb.remaining() > 0) { | while (cb.remaining() > 0) { | ||||
CoderResult res = enc.encode(cb, out,true); | |||||
final CoderResult res = enc.encode(cb, out,true); | |||||
if (res.isUnmappable() || res.isMalformed()) { | if (res.isUnmappable() || res.isMalformed()) { | ||||
@@ -115,8 +113,7 @@ class NioZipEncoding implements ZipEncoding { | |||||
* @see | * @see | ||||
* org.apache.tools.zip.ZipEncoding#decode(byte[]) | * org.apache.tools.zip.ZipEncoding#decode(byte[]) | ||||
*/ | */ | ||||
@Override | |||||
public String decode(byte[] data) throws IOException { | |||||
public String decode(final byte[] data) throws IOException { | |||||
return this.charset.newDecoder() | return this.charset.newDecoder() | ||||
.onMalformedInput(CodingErrorAction.REPORT) | .onMalformedInput(CodingErrorAction.REPORT) | ||||
.onUnmappableCharacter(CodingErrorAction.REPORT) | .onUnmappableCharacter(CodingErrorAction.REPORT) | ||||
@@ -53,13 +53,12 @@ class Simple8BitZipEncoding implements ZipEncoding { | |||||
public final char unicode; | public final char unicode; | ||||
public final byte code; | public final byte code; | ||||
Simple8BitChar(byte code, char unicode) { | |||||
Simple8BitChar(final byte code, final char unicode) { | |||||
this.code = code; | this.code = code; | ||||
this.unicode = unicode; | this.unicode = unicode; | ||||
} | } | ||||
@Override | |||||
public int compareTo(Simple8BitChar a) { | |||||
public int compareTo(final Simple8BitChar a) { | |||||
return this.unicode - a.unicode; | return this.unicode - a.unicode; | ||||
} | } | ||||
@@ -70,9 +69,9 @@ class Simple8BitZipEncoding implements ZipEncoding { | |||||
} | } | ||||
@Override | @Override | ||||
public boolean equals(Object o) { | |||||
public boolean equals(final Object o) { | |||||
if (o instanceof Simple8BitChar) { | if (o instanceof Simple8BitChar) { | ||||
Simple8BitChar other = (Simple8BitChar) o; | |||||
final Simple8BitChar other = (Simple8BitChar) o; | |||||
return unicode == other.unicode && code == other.code; | return unicode == other.unicode && code == other.code; | ||||
} | } | ||||
return false; | return false; | ||||
@@ -101,9 +100,9 @@ class Simple8BitZipEncoding implements ZipEncoding { | |||||
* @param highChars The characters for byte values of 128 to 255 | * @param highChars The characters for byte values of 128 to 255 | ||||
* stored as an array of 128 chars. | * stored as an array of 128 chars. | ||||
*/ | */ | ||||
public Simple8BitZipEncoding(char[] highChars) { | |||||
public Simple8BitZipEncoding(final char[] highChars) { | |||||
this.highChars = highChars.clone(); | this.highChars = highChars.clone(); | ||||
List<Simple8BitChar> temp = | |||||
final List<Simple8BitChar> temp = | |||||
new ArrayList<Simple8BitChar>(this.highChars.length); | new ArrayList<Simple8BitChar>(this.highChars.length); | ||||
byte code = 127; | byte code = 127; | ||||
@@ -122,7 +121,7 @@ class Simple8BitZipEncoding implements ZipEncoding { | |||||
* @param b The byte to decode. | * @param b The byte to decode. | ||||
* @return The associated character value. | * @return The associated character value. | ||||
*/ | */ | ||||
public char decodeByte(byte b) { | |||||
public char decodeByte(final byte b) { | |||||
// code 0-127 | // code 0-127 | ||||
if (b >= 0) { | if (b >= 0) { | ||||
return (char) b; | return (char) b; | ||||
@@ -136,13 +135,13 @@ class Simple8BitZipEncoding implements ZipEncoding { | |||||
* @param c The character to encode. | * @param c The character to encode. | ||||
* @return Whether the given unicode character is covered by this encoding. | * @return Whether the given unicode character is covered by this encoding. | ||||
*/ | */ | ||||
public boolean canEncodeChar(char c) { | |||||
public boolean canEncodeChar(final char c) { | |||||
if (c >= 0 && c < 128) { | if (c >= 0 && c < 128) { | ||||
return true; | return true; | ||||
} | } | ||||
Simple8BitChar r = this.encodeHighChar(c); | |||||
final Simple8BitChar r = this.encodeHighChar(c); | |||||
return r != null; | return r != null; | ||||
} | } | ||||
@@ -155,14 +154,14 @@ class Simple8BitZipEncoding implements ZipEncoding { | |||||
* If {@code false} is returned, nothing is pushed to the | * If {@code false} is returned, nothing is pushed to the | ||||
* byte buffer. | * byte buffer. | ||||
*/ | */ | ||||
public boolean pushEncodedChar(ByteBuffer bb, char c) { | |||||
public boolean pushEncodedChar(final ByteBuffer bb, final char c) { | |||||
if (c >= 0 && c < 128) { | if (c >= 0 && c < 128) { | ||||
bb.put((byte) c); | bb.put((byte) c); | ||||
return true; | return true; | ||||
} | } | ||||
Simple8BitChar r = this.encodeHighChar(c); | |||||
final Simple8BitChar r = this.encodeHighChar(c); | |||||
if (r == null) { | if (r == null) { | ||||
return false; | return false; | ||||
} | } | ||||
@@ -176,7 +175,7 @@ class Simple8BitZipEncoding implements ZipEncoding { | |||||
* A {@code null} value is returned, if this character is not | * A {@code null} value is returned, if this character is not | ||||
* covered by this encoding. | * covered by this encoding. | ||||
*/ | */ | ||||
private Simple8BitChar encodeHighChar(char c) { | |||||
private Simple8BitChar encodeHighChar(final char c) { | |||||
// for performance an simplicity, yet another reincarnation of | // for performance an simplicity, yet another reincarnation of | ||||
// binary search... | // binary search... | ||||
int i0 = 0; | int i0 = 0; | ||||
@@ -184,9 +183,9 @@ class Simple8BitZipEncoding implements ZipEncoding { | |||||
while (i1 > i0) { | while (i1 > i0) { | ||||
int i = i0 + (i1 - i0) / 2; | |||||
final int i = i0 + (i1 - i0) / 2; | |||||
Simple8BitChar m = this.reverseMapping.get(i); | |||||
final Simple8BitChar m = this.reverseMapping.get(i); | |||||
if (m.unicode == c) { | if (m.unicode == c) { | ||||
return m; | return m; | ||||
@@ -203,7 +202,7 @@ class Simple8BitZipEncoding implements ZipEncoding { | |||||
return null; | return null; | ||||
} | } | ||||
Simple8BitChar r = this.reverseMapping.get(i0); | |||||
final Simple8BitChar r = this.reverseMapping.get(i0); | |||||
if (r.unicode != c) { | if (r.unicode != c) { | ||||
return null; | return null; | ||||
@@ -216,12 +215,11 @@ class Simple8BitZipEncoding implements ZipEncoding { | |||||
* @see | * @see | ||||
* org.apache.tools.zip.ZipEncoding#canEncode(java.lang.String) | * org.apache.tools.zip.ZipEncoding#canEncode(java.lang.String) | ||||
*/ | */ | ||||
@Override | |||||
public boolean canEncode(String name) { | |||||
public boolean canEncode(final String name) { | |||||
for (int i=0;i<name.length();++i) { | for (int i=0;i<name.length();++i) { | ||||
char c = name.charAt(i); | |||||
final char c = name.charAt(i); | |||||
if (!this.canEncodeChar(c)) { | if (!this.canEncodeChar(c)) { | ||||
return false; | return false; | ||||
@@ -235,14 +233,13 @@ class Simple8BitZipEncoding implements ZipEncoding { | |||||
* @see | * @see | ||||
* org.apache.tools.zip.ZipEncoding#encode(java.lang.String) | * org.apache.tools.zip.ZipEncoding#encode(java.lang.String) | ||||
*/ | */ | ||||
@Override | |||||
public ByteBuffer encode(String name) { | |||||
public ByteBuffer encode(final String name) { | |||||
ByteBuffer out = ByteBuffer.allocate(name.length() | ByteBuffer out = ByteBuffer.allocate(name.length() | ||||
+ 6 + (name.length() + 1) / 2); | + 6 + (name.length() + 1) / 2); | ||||
for (int i=0;i<name.length();++i) { | for (int i=0;i<name.length();++i) { | ||||
char c = name.charAt(i); | |||||
final char c = name.charAt(i); | |||||
if (out.remaining() < 6) { | if (out.remaining() < 6) { | ||||
out = ZipEncodingHelper.growBuffer(out,out.position() + 6); | out = ZipEncodingHelper.growBuffer(out,out.position() + 6); | ||||
@@ -263,9 +260,8 @@ class Simple8BitZipEncoding implements ZipEncoding { | |||||
* @see | * @see | ||||
* org.apache.tools.zip.ZipEncoding#decode(byte[]) | * org.apache.tools.zip.ZipEncoding#decode(byte[]) | ||||
*/ | */ | ||||
@Override | |||||
public String decode(byte[] data) throws IOException { | |||||
char [] ret = new char[data.length]; | |||||
public String decode(final byte[] data) throws IOException { | |||||
final char [] ret = new char[data.length]; | |||||
for (int i=0;i<data.length;++i) { | for (int i=0;i<data.length;++i) { | ||||
ret[i] = this.decodeByte(data[i]); | ret[i] = this.decodeByte(data[i]); | ||||
@@ -46,8 +46,8 @@ public class UnicodeCommentExtraField extends AbstractUnicodeExtraField { | |||||
* @param len The length of the encoded comment or comment in | * @param len The length of the encoded comment or comment in | ||||
* <code>bytes</code>. | * <code>bytes</code>. | ||||
*/ | */ | ||||
public UnicodeCommentExtraField(String text, byte[] bytes, int off, | |||||
int len) { | |||||
public UnicodeCommentExtraField(final String text, final byte[] bytes, final int off, | |||||
final int len) { | |||||
super(text, bytes, off, len); | super(text, bytes, off, len); | ||||
} | } | ||||
@@ -58,12 +58,11 @@ public class UnicodeCommentExtraField extends AbstractUnicodeExtraField { | |||||
* @param comment The file comment | * @param comment The file comment | ||||
* @param bytes the bytes actually written to the archive | * @param bytes the bytes actually written to the archive | ||||
*/ | */ | ||||
public UnicodeCommentExtraField(String comment, byte[] bytes) { | |||||
public UnicodeCommentExtraField(final String comment, final byte[] bytes) { | |||||
super(comment, bytes); | super(comment, bytes); | ||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
@Override | |||||
public ZipShort getHeaderId() { | public ZipShort getHeaderId() { | ||||
return UCOM_ID; | return UCOM_ID; | ||||
} | } | ||||
@@ -45,7 +45,7 @@ public class UnicodePathExtraField extends AbstractUnicodeExtraField { | |||||
* @param len The length of the encoded filename or comment in | * @param len The length of the encoded filename or comment in | ||||
* <code>bytes</code>. | * <code>bytes</code>. | ||||
*/ | */ | ||||
public UnicodePathExtraField(String text, byte[] bytes, int off, int len) { | |||||
public UnicodePathExtraField(final String text, final byte[] bytes, final int off, final int len) { | |||||
super(text, bytes, off, len); | super(text, bytes, off, len); | ||||
} | } | ||||
@@ -56,12 +56,11 @@ public class UnicodePathExtraField extends AbstractUnicodeExtraField { | |||||
* @param name The file name | * @param name The file name | ||||
* @param bytes the bytes actually written to the archive | * @param bytes the bytes actually written to the archive | ||||
*/ | */ | ||||
public UnicodePathExtraField(String name, byte[] bytes) { | |||||
public UnicodePathExtraField(final String name, final byte[] bytes) { | |||||
super(name, bytes); | super(name, bytes); | ||||
} | } | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
@Override | |||||
public ZipShort getHeaderId() { | public ZipShort getHeaderId() { | ||||
return UPATH_ID; | return UPATH_ID; | ||||
} | } | ||||
@@ -146,7 +146,7 @@ public class ZipFile { | |||||
* | * | ||||
* @throws IOException if an error occurs while reading the file. | * @throws IOException if an error occurs while reading the file. | ||||
*/ | */ | ||||
public ZipFile(File f) throws IOException { | |||||
public ZipFile(final File f) throws IOException { | |||||
this(f, null); | this(f, null); | ||||
} | } | ||||
@@ -158,7 +158,7 @@ public class ZipFile { | |||||
* | * | ||||
* @throws IOException if an error occurs while reading the file. | * @throws IOException if an error occurs while reading the file. | ||||
*/ | */ | ||||
public ZipFile(String name) throws IOException { | |||||
public ZipFile(final String name) throws IOException { | |||||
this(new File(name), null); | this(new File(name), null); | ||||
} | } | ||||
@@ -172,7 +172,7 @@ public class ZipFile { | |||||
* | * | ||||
* @throws IOException if an error occurs while reading the file. | * @throws IOException if an error occurs while reading the file. | ||||
*/ | */ | ||||
public ZipFile(String name, String encoding) throws IOException { | |||||
public ZipFile(final String name, final String encoding) throws IOException { | |||||
this(new File(name), encoding, true); | this(new File(name), encoding, true); | ||||
} | } | ||||
@@ -186,7 +186,7 @@ public class ZipFile { | |||||
* | * | ||||
* @throws IOException if an error occurs while reading the file. | * @throws IOException if an error occurs while reading the file. | ||||
*/ | */ | ||||
public ZipFile(File f, String encoding) throws IOException { | |||||
public ZipFile(final File f, final String encoding) throws IOException { | |||||
this(f, encoding, true); | this(f, encoding, true); | ||||
} | } | ||||
@@ -202,7 +202,7 @@ public class ZipFile { | |||||
* | * | ||||
* @throws IOException if an error occurs while reading the file. | * @throws IOException if an error occurs while reading the file. | ||||
*/ | */ | ||||
public ZipFile(File f, String encoding, boolean useUnicodeExtraFields) | |||||
public ZipFile(final File f, final String encoding, final boolean useUnicodeExtraFields) | |||||
throws IOException { | throws IOException { | ||||
this.archiveName = f.getAbsolutePath(); | this.archiveName = f.getAbsolutePath(); | ||||
this.encoding = encoding; | this.encoding = encoding; | ||||
@@ -211,7 +211,7 @@ public class ZipFile { | |||||
archive = new RandomAccessFile(f, "r"); | archive = new RandomAccessFile(f, "r"); | ||||
boolean success = false; | boolean success = false; | ||||
try { | try { | ||||
Map<ZipEntry, NameAndComment> entriesWithoutUTF8Flag = | |||||
final Map<ZipEntry, NameAndComment> entriesWithoutUTF8Flag = | |||||
populateFromCentralDirectory(); | populateFromCentralDirectory(); | ||||
resolveLocalFileHeaderData(entriesWithoutUTF8Flag); | resolveLocalFileHeaderData(entriesWithoutUTF8Flag); | ||||
success = true; | success = true; | ||||
@@ -220,7 +220,7 @@ public class ZipFile { | |||||
try { | try { | ||||
closed = true; | closed = true; | ||||
archive.close(); | archive.close(); | ||||
} catch (IOException e2) { | |||||
} catch (final IOException e2) { | |||||
// swallow, throw the original exception instead | // swallow, throw the original exception instead | ||||
} | } | ||||
} | } | ||||
@@ -254,11 +254,11 @@ public class ZipFile { | |||||
* on a null parameter | * on a null parameter | ||||
* @param zipfile file to close, can be null | * @param zipfile file to close, can be null | ||||
*/ | */ | ||||
public static void closeQuietly(ZipFile zipfile) { | |||||
public static void closeQuietly(final ZipFile zipfile) { | |||||
if (zipfile != null) { | if (zipfile != null) { | ||||
try { | try { | ||||
zipfile.close(); | zipfile.close(); | ||||
} catch (IOException e) { | |||||
} catch (final IOException e) { | |||||
//ignore | //ignore | ||||
} | } | ||||
} | } | ||||
@@ -287,7 +287,7 @@ public class ZipFile { | |||||
* @since Ant 1.9.0 | * @since Ant 1.9.0 | ||||
*/ | */ | ||||
public Enumeration<ZipEntry> getEntriesInPhysicalOrder() { | public Enumeration<ZipEntry> getEntriesInPhysicalOrder() { | ||||
ZipEntry[] allEntries = entries.toArray(new ZipEntry[0]); | |||||
final ZipEntry[] allEntries = entries.toArray(new ZipEntry[0]); | |||||
Arrays.sort(allEntries, OFFSET_COMPARATOR); | Arrays.sort(allEntries, OFFSET_COMPARATOR); | ||||
return Collections.enumeration(Arrays.asList(allEntries)); | return Collections.enumeration(Arrays.asList(allEntries)); | ||||
} | } | ||||
@@ -304,8 +304,8 @@ public class ZipFile { | |||||
* @return the ZipEntry corresponding to the given name - or | * @return the ZipEntry corresponding to the given name - or | ||||
* {@code null} if not present. | * {@code null} if not present. | ||||
*/ | */ | ||||
public ZipEntry getEntry(String name) { | |||||
LinkedList<ZipEntry> entriesOfThatName = nameMap.get(name); | |||||
public ZipEntry getEntry(final String name) { | |||||
final LinkedList<ZipEntry> entriesOfThatName = nameMap.get(name); | |||||
return entriesOfThatName != null ? entriesOfThatName.getFirst() : null; | return entriesOfThatName != null ? entriesOfThatName.getFirst() : null; | ||||
} | } | ||||
@@ -318,8 +318,8 @@ public class ZipFile { | |||||
* given name | * given name | ||||
* @since 1.9.2 | * @since 1.9.2 | ||||
*/ | */ | ||||
public Iterable<ZipEntry> getEntries(String name) { | |||||
List<ZipEntry> entriesOfThatName = nameMap.get(name); | |||||
public Iterable<ZipEntry> getEntries(final String name) { | |||||
final List<ZipEntry> entriesOfThatName = nameMap.get(name); | |||||
return entriesOfThatName != null ? entriesOfThatName | return entriesOfThatName != null ? entriesOfThatName | ||||
: Collections.<ZipEntry>emptyList(); | : Collections.<ZipEntry>emptyList(); | ||||
} | } | ||||
@@ -333,7 +333,7 @@ public class ZipFile { | |||||
* given name | * given name | ||||
* @since 1.9.2 | * @since 1.9.2 | ||||
*/ | */ | ||||
public Iterable<ZipEntry> getEntriesInPhysicalOrder(String name) { | |||||
public Iterable<ZipEntry> getEntriesInPhysicalOrder(final String name) { | |||||
ZipEntry[] entriesOfThatName = new ZipEntry[0]; | ZipEntry[] entriesOfThatName = new ZipEntry[0]; | ||||
if (nameMap.containsKey(name)) { | if (nameMap.containsKey(name)) { | ||||
entriesOfThatName = nameMap.get(name).toArray(entriesOfThatName); | entriesOfThatName = nameMap.get(name).toArray(entriesOfThatName); | ||||
@@ -348,7 +348,7 @@ public class ZipFile { | |||||
* <p>May return false if it is set up to use encryption or a | * <p>May return false if it is set up to use encryption or a | ||||
* compression method that hasn't been implemented yet.</p> | * compression method that hasn't been implemented yet.</p> | ||||
*/ | */ | ||||
public boolean canReadEntryData(ZipEntry ze) { | |||||
public boolean canReadEntryData(final ZipEntry ze) { | |||||
return ZipUtil.canHandleEntryData(ze); | return ZipUtil.canHandleEntryData(ze); | ||||
} | } | ||||
@@ -360,16 +360,16 @@ public class ZipFile { | |||||
* @throws IOException if unable to create an input stream from the zipentry | * @throws IOException if unable to create an input stream from the zipentry | ||||
* @throws ZipException if the zipentry uses an unsupported feature | * @throws ZipException if the zipentry uses an unsupported feature | ||||
*/ | */ | ||||
public InputStream getInputStream(ZipEntry ze) | |||||
public InputStream getInputStream(final ZipEntry ze) | |||||
throws IOException, ZipException { | throws IOException, ZipException { | ||||
if (!(ze instanceof Entry)) { | if (!(ze instanceof Entry)) { | ||||
return null; | return null; | ||||
} | } | ||||
// cast valididty is checked just above | // cast valididty is checked just above | ||||
OffsetEntry offsetEntry = ((Entry) ze).getOffsetEntry(); | |||||
final OffsetEntry offsetEntry = ((Entry) ze).getOffsetEntry(); | |||||
ZipUtil.checkRequestedFeatures(ze); | ZipUtil.checkRequestedFeatures(ze); | ||||
long start = offsetEntry.dataOffset; | |||||
BoundedInputStream bis = | |||||
final long start = offsetEntry.dataOffset; | |||||
final BoundedInputStream bis = | |||||
new BoundedInputStream(start, ze.getCompressedSize()); | new BoundedInputStream(start, ze.getCompressedSize()); | ||||
switch (ze.getMethod()) { | switch (ze.getMethod()) { | ||||
case ZipEntry.STORED: | case ZipEntry.STORED: | ||||
@@ -446,7 +446,7 @@ public class ZipFile { | |||||
*/ | */ | ||||
private Map<ZipEntry, NameAndComment> populateFromCentralDirectory() | private Map<ZipEntry, NameAndComment> populateFromCentralDirectory() | ||||
throws IOException { | throws IOException { | ||||
HashMap<ZipEntry, NameAndComment> noUTF8Flag = | |||||
final HashMap<ZipEntry, NameAndComment> noUTF8Flag = | |||||
new HashMap<ZipEntry, NameAndComment>(); | new HashMap<ZipEntry, NameAndComment>(); | ||||
positionAtCentralDirectory(); | positionAtCentralDirectory(); | ||||
@@ -477,14 +477,14 @@ public class ZipFile { | |||||
* added to this map. | * added to this map. | ||||
*/ | */ | ||||
private void | private void | ||||
readCentralDirectoryEntry(Map<ZipEntry, NameAndComment> noUTF8Flag) | |||||
readCentralDirectoryEntry(final Map<ZipEntry, NameAndComment> noUTF8Flag) | |||||
throws IOException { | throws IOException { | ||||
archive.readFully(CFH_BUF); | archive.readFully(CFH_BUF); | ||||
int off = 0; | int off = 0; | ||||
OffsetEntry offset = new OffsetEntry(); | |||||
Entry ze = new Entry(offset); | |||||
final OffsetEntry offset = new OffsetEntry(); | |||||
final Entry ze = new Entry(offset); | |||||
int versionMadeBy = ZipShort.getValue(CFH_BUF, off); | |||||
final int versionMadeBy = ZipShort.getValue(CFH_BUF, off); | |||||
off += SHORT; | off += SHORT; | ||||
ze.setPlatform((versionMadeBy >> BYTE_SHIFT) & NIBLET_MASK); | ze.setPlatform((versionMadeBy >> BYTE_SHIFT) & NIBLET_MASK); | ||||
@@ -501,7 +501,7 @@ public class ZipFile { | |||||
ze.setMethod(ZipShort.getValue(CFH_BUF, off)); | ze.setMethod(ZipShort.getValue(CFH_BUF, off)); | ||||
off += SHORT; | off += SHORT; | ||||
long time = ZipUtil.dosToJavaTime(ZipLong.getValue(CFH_BUF, off)); | |||||
final long time = ZipUtil.dosToJavaTime(ZipLong.getValue(CFH_BUF, off)); | |||||
ze.setTime(time); | ze.setTime(time); | ||||
off += WORD; | off += WORD; | ||||
@@ -514,16 +514,16 @@ public class ZipFile { | |||||
ze.setSize(ZipLong.getValue(CFH_BUF, off)); | ze.setSize(ZipLong.getValue(CFH_BUF, off)); | ||||
off += WORD; | off += WORD; | ||||
int fileNameLen = ZipShort.getValue(CFH_BUF, off); | |||||
final int fileNameLen = ZipShort.getValue(CFH_BUF, off); | |||||
off += SHORT; | off += SHORT; | ||||
int extraLen = ZipShort.getValue(CFH_BUF, off); | |||||
final int extraLen = ZipShort.getValue(CFH_BUF, off); | |||||
off += SHORT; | off += SHORT; | ||||
int commentLen = ZipShort.getValue(CFH_BUF, off); | |||||
final int commentLen = ZipShort.getValue(CFH_BUF, off); | |||||
off += SHORT; | off += SHORT; | ||||
int diskStart = ZipShort.getValue(CFH_BUF, off); | |||||
final int diskStart = ZipShort.getValue(CFH_BUF, off); | |||||
off += SHORT; | off += SHORT; | ||||
ze.setInternalAttributes(ZipShort.getValue(CFH_BUF, off)); | ze.setInternalAttributes(ZipShort.getValue(CFH_BUF, off)); | ||||
@@ -532,7 +532,7 @@ public class ZipFile { | |||||
ze.setExternalAttributes(ZipLong.getValue(CFH_BUF, off)); | ze.setExternalAttributes(ZipLong.getValue(CFH_BUF, off)); | ||||
off += WORD; | off += WORD; | ||||
byte[] fileName = new byte[fileNameLen]; | |||||
final byte[] fileName = new byte[fileNameLen]; | |||||
archive.readFully(fileName); | archive.readFully(fileName); | ||||
ze.setName(entryEncoding.decode(fileName), fileName); | ze.setName(entryEncoding.decode(fileName), fileName); | ||||
@@ -541,13 +541,13 @@ public class ZipFile { | |||||
// data offset will be filled later | // data offset will be filled later | ||||
entries.add(ze); | entries.add(ze); | ||||
byte[] cdExtraData = new byte[extraLen]; | |||||
final byte[] cdExtraData = new byte[extraLen]; | |||||
archive.readFully(cdExtraData); | archive.readFully(cdExtraData); | ||||
ze.setCentralDirectoryExtra(cdExtraData); | ze.setCentralDirectoryExtra(cdExtraData); | ||||
setSizesAndOffsetFromZip64Extra(ze, offset, diskStart); | setSizesAndOffsetFromZip64Extra(ze, offset, diskStart); | ||||
byte[] comment = new byte[commentLen]; | |||||
final byte[] comment = new byte[commentLen]; | |||||
archive.readFully(comment); | archive.readFully(comment); | ||||
ze.setComment(entryEncoding.decode(comment)); | ze.setComment(entryEncoding.decode(comment)); | ||||
@@ -568,17 +568,17 @@ public class ZipFile { | |||||
* even if they are never used - and here a field with only one | * even if they are never used - and here a field with only one | ||||
* size would be invalid.</p> | * size would be invalid.</p> | ||||
*/ | */ | ||||
private void setSizesAndOffsetFromZip64Extra(ZipEntry ze, | |||||
OffsetEntry offset, | |||||
int diskStart) | |||||
private void setSizesAndOffsetFromZip64Extra(final ZipEntry ze, | |||||
final OffsetEntry offset, | |||||
final int diskStart) | |||||
throws IOException { | throws IOException { | ||||
Zip64ExtendedInformationExtraField z64 = | |||||
final Zip64ExtendedInformationExtraField z64 = | |||||
(Zip64ExtendedInformationExtraField) | (Zip64ExtendedInformationExtraField) | ||||
ze.getExtraField(Zip64ExtendedInformationExtraField.HEADER_ID); | ze.getExtraField(Zip64ExtendedInformationExtraField.HEADER_ID); | ||||
if (z64 != null) { | if (z64 != null) { | ||||
boolean hasUncompressedSize = ze.getSize() == ZIP64_MAGIC; | |||||
boolean hasCompressedSize = ze.getCompressedSize() == ZIP64_MAGIC; | |||||
boolean hasRelativeHeaderOffset = | |||||
final boolean hasUncompressedSize = ze.getSize() == ZIP64_MAGIC; | |||||
final boolean hasCompressedSize = ze.getCompressedSize() == ZIP64_MAGIC; | |||||
final boolean hasRelativeHeaderOffset = | |||||
offset.headerOffset == ZIP64_MAGIC; | offset.headerOffset == ZIP64_MAGIC; | ||||
z64.reparseCentralDirectoryData(hasUncompressedSize, | z64.reparseCentralDirectoryData(hasUncompressedSize, | ||||
hasCompressedSize, | hasCompressedSize, | ||||
@@ -706,7 +706,7 @@ public class ZipFile { | |||||
throws IOException { | throws IOException { | ||||
positionAtEndOfCentralDirectoryRecord(); | positionAtEndOfCentralDirectoryRecord(); | ||||
boolean found = false; | boolean found = false; | ||||
boolean searchedForZip64EOCD = | |||||
final boolean searchedForZip64EOCD = | |||||
archive.getFilePointer() > ZIP64_EOCDL_LENGTH; | archive.getFilePointer() > ZIP64_EOCDL_LENGTH; | ||||
if (searchedForZip64EOCD) { | if (searchedForZip64EOCD) { | ||||
archive.seek(archive.getFilePointer() - ZIP64_EOCDL_LENGTH); | archive.seek(archive.getFilePointer() - ZIP64_EOCDL_LENGTH); | ||||
@@ -765,7 +765,7 @@ public class ZipFile { | |||||
*/ | */ | ||||
private void positionAtEndOfCentralDirectoryRecord() | private void positionAtEndOfCentralDirectoryRecord() | ||||
throws IOException { | throws IOException { | ||||
boolean found = tryToLocateSignature(MIN_EOCD_SIZE, MAX_EOCD_SIZE, | |||||
final boolean found = tryToLocateSignature(MIN_EOCD_SIZE, MAX_EOCD_SIZE, | |||||
ZipOutputStream.EOCD_SIG); | ZipOutputStream.EOCD_SIG); | ||||
if (!found) { | if (!found) { | ||||
throw new ZipException("archive is not a ZIP archive"); | throw new ZipException("archive is not a ZIP archive"); | ||||
@@ -777,9 +777,9 @@ public class ZipFile { | |||||
* for the given signature, positions the RandomaccessFile right | * for the given signature, positions the RandomaccessFile right | ||||
* at the signature if it has been found. | * at the signature if it has been found. | ||||
*/ | */ | ||||
private boolean tryToLocateSignature(long minDistanceFromEnd, | |||||
long maxDistanceFromEnd, | |||||
byte[] sig) throws IOException { | |||||
private boolean tryToLocateSignature(final long minDistanceFromEnd, | |||||
final long maxDistanceFromEnd, | |||||
final byte[] sig) throws IOException { | |||||
boolean found = false; | boolean found = false; | ||||
long off = archive.length() - minDistanceFromEnd; | long off = archive.length() - minDistanceFromEnd; | ||||
final long stopSearching = | final long stopSearching = | ||||
@@ -819,7 +819,7 @@ public class ZipFile { | |||||
private void skipBytes(final int count) throws IOException { | private void skipBytes(final int count) throws IOException { | ||||
int totalSkipped = 0; | int totalSkipped = 0; | ||||
while (totalSkipped < count) { | while (totalSkipped < count) { | ||||
int skippedNow = archive.skipBytes(count - totalSkipped); | |||||
final int skippedNow = archive.skipBytes(count - totalSkipped); | |||||
if (skippedNow <= 0) { | if (skippedNow <= 0) { | ||||
throw new EOFException(); | throw new EOFException(); | ||||
} | } | ||||
@@ -849,42 +849,42 @@ public class ZipFile { | |||||
* <p>Also records the offsets for the data to read from the | * <p>Also records the offsets for the data to read from the | ||||
* entries.</p> | * entries.</p> | ||||
*/ | */ | ||||
private void resolveLocalFileHeaderData(Map<ZipEntry, NameAndComment> | |||||
private void resolveLocalFileHeaderData(final Map<ZipEntry, NameAndComment> | |||||
entriesWithoutUTF8Flag) | entriesWithoutUTF8Flag) | ||||
throws IOException { | throws IOException { | ||||
for (Iterator<ZipEntry> it = entries.iterator(); it.hasNext();) { | |||||
for (final Iterator<ZipEntry> it = entries.iterator(); it.hasNext();) { | |||||
// entries is filled in populateFromCentralDirectory and | // entries is filled in populateFromCentralDirectory and | ||||
// never modified | // never modified | ||||
Entry ze = (Entry) it.next(); | |||||
OffsetEntry offsetEntry = ze.getOffsetEntry(); | |||||
long offset = offsetEntry.headerOffset; | |||||
final Entry ze = (Entry) it.next(); | |||||
final OffsetEntry offsetEntry = ze.getOffsetEntry(); | |||||
final long offset = offsetEntry.headerOffset; | |||||
archive.seek(offset + LFH_OFFSET_FOR_FILENAME_LENGTH); | archive.seek(offset + LFH_OFFSET_FOR_FILENAME_LENGTH); | ||||
archive.readFully(SHORT_BUF); | archive.readFully(SHORT_BUF); | ||||
int fileNameLen = ZipShort.getValue(SHORT_BUF); | |||||
final int fileNameLen = ZipShort.getValue(SHORT_BUF); | |||||
archive.readFully(SHORT_BUF); | archive.readFully(SHORT_BUF); | ||||
int extraFieldLen = ZipShort.getValue(SHORT_BUF); | |||||
final int extraFieldLen = ZipShort.getValue(SHORT_BUF); | |||||
int lenToSkip = fileNameLen; | int lenToSkip = fileNameLen; | ||||
while (lenToSkip > 0) { | while (lenToSkip > 0) { | ||||
int skipped = archive.skipBytes(lenToSkip); | |||||
final int skipped = archive.skipBytes(lenToSkip); | |||||
if (skipped <= 0) { | if (skipped <= 0) { | ||||
throw new IOException("failed to skip file name in" | throw new IOException("failed to skip file name in" | ||||
+ " local file header"); | + " local file header"); | ||||
} | } | ||||
lenToSkip -= skipped; | lenToSkip -= skipped; | ||||
} | } | ||||
byte[] localExtraData = new byte[extraFieldLen]; | |||||
final byte[] localExtraData = new byte[extraFieldLen]; | |||||
archive.readFully(localExtraData); | archive.readFully(localExtraData); | ||||
ze.setExtra(localExtraData); | ze.setExtra(localExtraData); | ||||
offsetEntry.dataOffset = offset + LFH_OFFSET_FOR_FILENAME_LENGTH | offsetEntry.dataOffset = offset + LFH_OFFSET_FOR_FILENAME_LENGTH | ||||
+ SHORT + SHORT + fileNameLen + extraFieldLen; | + SHORT + SHORT + fileNameLen + extraFieldLen; | ||||
if (entriesWithoutUTF8Flag.containsKey(ze)) { | if (entriesWithoutUTF8Flag.containsKey(ze)) { | ||||
NameAndComment nc = entriesWithoutUTF8Flag.get(ze); | |||||
final NameAndComment nc = entriesWithoutUTF8Flag.get(ze); | |||||
ZipUtil.setNameAndCommentFromExtraFields(ze, nc.name, | ZipUtil.setNameAndCommentFromExtraFields(ze, nc.name, | ||||
nc.comment); | nc.comment); | ||||
} | } | ||||
String name = ze.getName(); | |||||
final String name = ze.getName(); | |||||
LinkedList<ZipEntry> entriesOfThatName = nameMap.get(name); | LinkedList<ZipEntry> entriesOfThatName = nameMap.get(name); | ||||
if (entriesOfThatName == null) { | if (entriesOfThatName == null) { | ||||
entriesOfThatName = new LinkedList<ZipEntry>(); | entriesOfThatName = new LinkedList<ZipEntry>(); | ||||
@@ -914,7 +914,7 @@ public class ZipFile { | |||||
private long loc; | private long loc; | ||||
private boolean addDummyByte = false; | private boolean addDummyByte = false; | ||||
BoundedInputStream(long start, long remaining) { | |||||
BoundedInputStream(final long start, final long remaining) { | |||||
this.remaining = remaining; | this.remaining = remaining; | ||||
loc = start; | loc = start; | ||||
} | } | ||||
@@ -935,7 +935,7 @@ public class ZipFile { | |||||
} | } | ||||
@Override | @Override | ||||
public int read(byte[] b, int off, int len) throws IOException { | |||||
public int read(final byte[] b, final int off, int len) throws IOException { | |||||
if (remaining <= 0) { | if (remaining <= 0) { | ||||
if (addDummyByte) { | if (addDummyByte) { | ||||
addDummyByte = false; | addDummyByte = false; | ||||
@@ -976,7 +976,7 @@ public class ZipFile { | |||||
private static final class NameAndComment { | private static final class NameAndComment { | ||||
private final byte[] name; | private final byte[] name; | ||||
private final byte[] comment; | private final byte[] comment; | ||||
private NameAndComment(byte[] name, byte[] comment) { | |||||
private NameAndComment(final byte[] name, final byte[] comment) { | |||||
this.name = name; | this.name = name; | ||||
this.comment = comment; | this.comment = comment; | ||||
} | } | ||||
@@ -992,21 +992,20 @@ public class ZipFile { | |||||
*/ | */ | ||||
private final Comparator<ZipEntry> OFFSET_COMPARATOR = | private final Comparator<ZipEntry> OFFSET_COMPARATOR = | ||||
new Comparator<ZipEntry>() { | new Comparator<ZipEntry>() { | ||||
@Override | |||||
public int compare(ZipEntry e1, ZipEntry e2) { | |||||
public int compare(final ZipEntry e1, final ZipEntry e2) { | |||||
if (e1 == e2) { | if (e1 == e2) { | ||||
return 0; | return 0; | ||||
} | } | ||||
Entry ent1 = e1 instanceof Entry ? (Entry) e1 : null; | |||||
Entry ent2 = e2 instanceof Entry ? (Entry) e2 : null; | |||||
final Entry ent1 = e1 instanceof Entry ? (Entry) e1 : null; | |||||
final Entry ent2 = e2 instanceof Entry ? (Entry) e2 : null; | |||||
if (ent1 == null) { | if (ent1 == null) { | ||||
return 1; | return 1; | ||||
} | } | ||||
if (ent2 == null) { | if (ent2 == null) { | ||||
return -1; | return -1; | ||||
} | } | ||||
long val = (ent1.getOffsetEntry().headerOffset | |||||
final long val = (ent1.getOffsetEntry().headerOffset | |||||
- ent2.getOffsetEntry().headerOffset); | - ent2.getOffsetEntry().headerOffset); | ||||
return val == 0 ? 0 : val < 0 ? -1 : +1; | return val == 0 ? 0 : val < 0 ? -1 : +1; | ||||
} | } | ||||
@@ -1019,7 +1018,7 @@ public class ZipFile { | |||||
private final OffsetEntry offsetEntry; | private final OffsetEntry offsetEntry; | ||||
Entry(OffsetEntry offset) { | |||||
Entry(final OffsetEntry offset) { | |||||
this.offsetEntry = offset; | this.offsetEntry = offset; | ||||
} | } | ||||
@@ -1034,10 +1033,10 @@ public class ZipFile { | |||||
} | } | ||||
@Override | @Override | ||||
public boolean equals(Object other) { | |||||
public boolean equals(final Object other) { | |||||
if (super.equals(other)) { | if (super.equals(other)) { | ||||
// super.equals would return false if other were not an Entry | // super.equals would return false if other were not an Entry | ||||
Entry otherEntry = (Entry) other; | |||||
final Entry otherEntry = (Entry) other; | |||||
return offsetEntry.headerOffset | return offsetEntry.headerOffset | ||||
== otherEntry.offsetEntry.headerOffset | == otherEntry.offsetEntry.headerOffset | ||||
&& offsetEntry.dataOffset | && offsetEntry.dataOffset | ||||