You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by jh...@apache.org on 2014/07/04 09:17:55 UTC
[13/17] checkstyle
http://git-wip-us.apache.org/repos/asf/ant/blob/1b76f1b6/src/main/org/apache/tools/ant/taskdefs/AntStructure.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/AntStructure.java b/src/main/org/apache/tools/ant/taskdefs/AntStructure.java
index 7155f42..f5677d8 100644
--- a/src/main/org/apache/tools/ant/taskdefs/AntStructure.java
+++ b/src/main/org/apache/tools/ant/taskdefs/AntStructure.java
@@ -57,7 +57,7 @@ public class AntStructure extends Task {
* The output file.
* @param output the output file
*/
- public void setOutput(File output) {
+ public void setOutput(final File output) {
this.output = output;
}
@@ -66,7 +66,7 @@ public class AntStructure extends Task {
* @param p the printer to use.
* @since Ant 1.7
*/
- public void add(StructurePrinter p) {
+ public void add(final StructurePrinter p) {
printer = p;
}
@@ -75,7 +75,8 @@ public class AntStructure extends Task {
*
* @exception BuildException if the DTD cannot be written.
*/
- public void execute() throws BuildException {
+ @Override
+ public void execute() throws BuildException {
if (output == null) {
throw new BuildException("output attribute is required", getLocation());
@@ -85,7 +86,7 @@ public class AntStructure extends Task {
try {
try {
out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(output), "UTF8"));
- } catch (UnsupportedEncodingException ue) {
+ } catch (final UnsupportedEncodingException ue) {
/*
* Plain impossible with UTF8, see
* http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html
@@ -101,14 +102,14 @@ public class AntStructure extends Task {
printer.printTargetDecl(out);
- for (String typeName : getProject().getCopyOfDataTypeDefinitions()
+ for (final String typeName : getProject().getCopyOfDataTypeDefinitions()
.keySet()) {
printer.printElementDecl(
out, getProject(), typeName,
getProject().getDataTypeDefinitions().get(typeName));
}
- for (String tName : getProject().getCopyOfTaskDefinitions().keySet()) {
+ for (final String tName : getProject().getCopyOfTaskDefinitions().keySet()) {
printer.printElementDecl(out, getProject(), tName,
getProject().getTaskDefinitions().get(tName));
}
@@ -119,7 +120,7 @@ public class AntStructure extends Task {
throw new IOException("Encountered an error writing Ant"
+ " structure");
}
- } catch (IOException ioe) {
+ } catch (final IOException ioe) {
throw new BuildException("Error writing "
+ output.getAbsolutePath(), ioe, getLocation());
} finally {
@@ -136,7 +137,7 @@ public class AntStructure extends Task {
* are called exactly once, {@link #printElementDecl} once for
* each declared task and type.</p>
*/
- public static interface StructurePrinter {
+ public interface StructurePrinter {
/**
* Prints the header of the generated output.
*
@@ -179,14 +180,16 @@ public class AntStructure extends Task {
private static final String TASKS = "%tasks;";
private static final String TYPES = "%types;";
- private Hashtable<String, String> visited = new Hashtable<String, String>();
+ private final Hashtable<String, String> visited = new Hashtable<String, String>();
- public void printTail(PrintWriter out) {
+ @Override
+ public void printTail(final PrintWriter out) {
visited.clear();
}
- public void printHead(PrintWriter out, Project p, Hashtable<String, Class<?>> tasks,
- Hashtable<String, Class<?>> types) {
+ @Override
+ public void printHead(final PrintWriter out, final Project p, final Hashtable<String, Class<?>> tasks,
+ final Hashtable<String, Class<?>> types) {
printHead(out, tasks.keys(), types.keys());
}
@@ -197,14 +200,14 @@ public class AntStructure extends Task {
* <p>Basically this prints the XML declaration, defines some
* entities and the project element.</p>
*/
- private void printHead(PrintWriter out, Enumeration<String> tasks,
- Enumeration<String> types) {
+ private void printHead(final PrintWriter out, final Enumeration<String> tasks,
+ final Enumeration<String> types) {
out.println("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
out.println("<!ENTITY % boolean \"(true|false|on|off|yes|no)\">");
out.print("<!ENTITY % tasks \"");
boolean first = true;
while (tasks.hasMoreElements()) {
- String tName = tasks.nextElement();
+ final String tName = tasks.nextElement();
if (!first) {
out.print(" | ");
} else {
@@ -216,7 +219,7 @@ public class AntStructure extends Task {
out.print("<!ENTITY % types \"");
first = true;
while (types.hasMoreElements()) {
- String typeName = types.nextElement();
+ final String typeName = types.nextElement();
if (!first) {
out.print(" | ");
} else {
@@ -243,7 +246,8 @@ public class AntStructure extends Task {
/**
* Prints the definition for the target element.
*/
- public void printTargetDecl(PrintWriter out) {
+ @Override
+ public void printTargetDecl(final PrintWriter out) {
out.print("<!ELEMENT target (");
out.print(TASKS);
out.print(" | ");
@@ -259,7 +263,7 @@ public class AntStructure extends Task {
/**
* Prints the definition for the target element.
*/
- private void printTargetAttrs(PrintWriter out, String tag) {
+ private void printTargetAttrs(final PrintWriter out, final String tag) {
out.print("<!ATTLIST ");
out.println(tag);
out.println(" id ID #IMPLIED");
@@ -276,8 +280,9 @@ public class AntStructure extends Task {
/**
* Print the definition for a given element.
*/
- public void printElementDecl(PrintWriter out, Project p,
- String name, Class<?> element) {
+ @Override
+ public void printElementDecl(final PrintWriter out, final Project p,
+ final String name, final Class<?> element) {
if (visited.containsKey(name)) {
return;
@@ -287,7 +292,7 @@ public class AntStructure extends Task {
IntrospectionHelper ih = null;
try {
ih = IntrospectionHelper.getHelper(p, element);
- } catch (Throwable t) {
+ } catch (final Throwable t) {
/*
* TODO - failed to load the class properly.
*
@@ -309,7 +314,7 @@ public class AntStructure extends Task {
return;
}
- Vector<String> v = new Vector<String>();
+ final Vector<String> v = new Vector<String>();
if (ih.supportsCharacters()) {
v.addElement("#PCDATA");
}
@@ -348,14 +353,14 @@ public class AntStructure extends Task {
e = ih.getAttributes();
while (e.hasMoreElements()) {
- String attrName = (String) e.nextElement();
+ final String attrName = e.nextElement();
if ("id".equals(attrName)) {
continue;
}
sb.append(LINE_SEP).append(" ")
.append(attrName).append(" ");
- Class<?> type = ih.getAttributeType(attrName);
+ final Class<?> type = ih.getAttributeType(attrName);
if (type.equals(java.lang.Boolean.class)
|| type.equals(java.lang.Boolean.TYPE)) {
sb.append(BOOLEAN).append(" ");
@@ -363,9 +368,9 @@ public class AntStructure extends Task {
sb.append("IDREF ");
} else if (EnumeratedAttribute.class.isAssignableFrom(type)) {
try {
- EnumeratedAttribute ea =
+ final EnumeratedAttribute ea =
(EnumeratedAttribute) type.newInstance();
- String[] values = ea.getValues();
+ final String[] values = ea.getValues();
if (values == null
|| values.length == 0
|| !areNmtokens(values)) {
@@ -380,15 +385,15 @@ public class AntStructure extends Task {
}
sb.append(") ");
}
- } catch (InstantiationException ie) {
+ } catch (final InstantiationException ie) {
sb.append("CDATA ");
- } catch (IllegalAccessException ie) {
+ } catch (final IllegalAccessException ie) {
sb.append("CDATA ");
}
} else if (type.getSuperclass() != null
&& type.getSuperclass().getName().equals("java.lang.Enum")) {
try {
- Object[] values = (Object[]) type.getMethod("values", (Class[]) null)
+ final Object[] values = (Object[]) type.getMethod("values", (Class[]) null)
.invoke(null, (Object[]) null);
if (values.length == 0) {
sb.append("CDATA ");
@@ -403,7 +408,7 @@ public class AntStructure extends Task {
}
sb.append(") ");
}
- } catch (Exception x) {
+ } catch (final Exception x) {
sb.append("CDATA ");
}
} else {
@@ -416,7 +421,7 @@ public class AntStructure extends Task {
final int count = v.size();
for (int i = 0; i < count; i++) {
- String nestedName = (String) v.elementAt(i);
+ final String nestedName = v.elementAt(i);
if (!"#PCDATA".equals(nestedName)
&& !TASKS.equals(nestedName)
&& !TYPES.equals(nestedName)) {
@@ -430,10 +435,10 @@ public class AntStructure extends Task {
* @param s the string to test
* @return true if the string matches the XML-NMTOKEN
*/
- public static final boolean isNmtoken(String s) {
+ public static final boolean isNmtoken(final String s) {
final int length = s.length();
for (int i = 0; i < length; i++) {
- char c = s.charAt(i);
+ final char c = s.charAt(i);
// TODO - we are committing CombiningChar and Extender here
if (!Character.isLetterOrDigit(c)
&& c != '.' && c != '-' && c != '_' && c != ':') {
@@ -451,7 +456,7 @@ public class AntStructure extends Task {
* @param s the array of string to test
* @return true if all the strings in the array math XML-NMTOKEN
*/
- public static final boolean areNmtokens(String[] s) {
+ public static final boolean areNmtokens(final String[] s) {
for (int i = 0; i < s.length; i++) {
if (!isNmtoken(s[i])) {
return false;
@@ -466,7 +471,7 @@ public class AntStructure extends Task {
* @param s the string to test
* @return true if the string matches the XML-NMTOKEN
*/
- protected boolean isNmtoken(String s) {
+ protected boolean isNmtoken(final String s) {
return DTDPrinter.isNmtoken(s);
}
@@ -478,7 +483,7 @@ public class AntStructure extends Task {
* @param s the array of string to test
* @return true if all the strings in the array math XML-NMTOKEN
*/
- protected boolean areNmtokens(String[] s) {
+ protected boolean areNmtokens(final String[] s) {
return DTDPrinter.areNmtokens(s);
}
}
http://git-wip-us.apache.org/repos/asf/ant/blob/1b76f1b6/src/main/org/apache/tools/ant/taskdefs/BindTargets.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/BindTargets.java b/src/main/org/apache/tools/ant/taskdefs/BindTargets.java
index 203a98d..7103422 100644
--- a/src/main/org/apache/tools/ant/taskdefs/BindTargets.java
+++ b/src/main/org/apache/tools/ant/taskdefs/BindTargets.java
@@ -33,37 +33,38 @@ public class BindTargets extends Task {
private String extensionPoint;
- private List<String> targets = new ArrayList<String>();
+ private final List<String> targets = new ArrayList<String>();
private OnMissingExtensionPoint onMissingExtensionPoint;
- public void setExtensionPoint(String extensionPoint) {
+ public void setExtensionPoint(final String extensionPoint) {
this.extensionPoint = extensionPoint;
}
- public void setOnMissingExtensionPoint(String onMissingExtensionPoint) {
+ public void setOnMissingExtensionPoint(final String onMissingExtensionPoint) {
try {
this.onMissingExtensionPoint = OnMissingExtensionPoint.valueOf(onMissingExtensionPoint);
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
throw new BuildException("Invalid onMissingExtensionPoint: " + onMissingExtensionPoint);
}
}
- public void setOnMissingExtensionPoint(OnMissingExtensionPoint onMissingExtensionPoint) {
+ public void setOnMissingExtensionPoint(final OnMissingExtensionPoint onMissingExtensionPoint) {
this.onMissingExtensionPoint = onMissingExtensionPoint;
}
- public void setTargets(String target) {
- String[] inputs = target.split(",");
+ public void setTargets(final String target) {
+ final String[] inputs = target.split(",");
for (int i = 0; i < inputs.length; i++) {
- String input = inputs[i].trim();
+ final String input = inputs[i].trim();
if (input.length() > 0) {
targets.add(input);
}
}
}
- public void execute() throws BuildException {
+ @Override
+ public void execute() throws BuildException {
if (extensionPoint == null) {
throw new BuildException("extensionPoint required", getLocation());
}
@@ -77,13 +78,13 @@ public class BindTargets extends Task {
if (onMissingExtensionPoint == null) {
onMissingExtensionPoint = OnMissingExtensionPoint.FAIL;
}
- ProjectHelper helper = (ProjectHelper) getProject().getReference(
+ final ProjectHelper helper = (ProjectHelper) getProject().getReference(
ProjectHelper.PROJECTHELPER_REFERENCE);
- for (Iterator<String> itTarget = targets.iterator(); itTarget.hasNext();) {
+ for (final Iterator<String> itTarget = targets.iterator(); itTarget.hasNext();) {
helper.getExtensionStack().add(
- new String[] { extensionPoint, itTarget.next(),
- onMissingExtensionPoint.name() });
+ new String[] {extensionPoint, itTarget.next(),
+ onMissingExtensionPoint.name()});
}
}
http://git-wip-us.apache.org/repos/asf/ant/blob/1b76f1b6/src/main/org/apache/tools/ant/taskdefs/Componentdef.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/Componentdef.java b/src/main/org/apache/tools/ant/taskdefs/Componentdef.java
index 36a0c0f..1c5590c 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Componentdef.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Componentdef.java
@@ -23,7 +23,7 @@ package org.apache.tools.ant.taskdefs;
* <p>Used in the current project two attributes are needed, the name that identifies
* this component uniquely, and the full name of the class (including the packages) that
* implements this component.</p>
- *
+ *
* @since Ant 1.8
* @ant.task category="internal"
*/
http://git-wip-us.apache.org/repos/asf/ant/blob/1b76f1b6/src/main/org/apache/tools/ant/taskdefs/Copy.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/Copy.java b/src/main/org/apache/tools/ant/taskdefs/Copy.java
index e6f9cbd..7fdfaf2 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Copy.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Copy.java
@@ -95,8 +95,8 @@ public class Copy extends Task {
protected Mapper mapperElement = null;
protected FileUtils fileUtils;
//CheckStyle:VisibilityModifier ON
- private Vector<FilterChain> filterChains = new Vector<FilterChain>();
- private Vector<FilterSet> filterSets = new Vector<FilterSet>();
+ private final Vector<FilterChain> filterChains = new Vector<FilterChain>();
+ private final Vector<FilterSet> filterSets = new Vector<FilterSet>();
private String inputEncoding = null;
private String outputEncoding = null;
private long granularity = 0;
@@ -127,7 +127,7 @@ public class Copy extends Task {
* Set a single source file to copy.
* @param file the file to copy.
*/
- public void setFile(File file) {
+ public void setFile(final File file) {
this.file = file;
}
@@ -135,7 +135,7 @@ public class Copy extends Task {
* Set the destination file.
* @param destFile the file to copy to.
*/
- public void setTofile(File destFile) {
+ public void setTofile(final File destFile) {
this.destFile = destFile;
}
@@ -143,7 +143,7 @@ public class Copy extends Task {
* Set the destination directory.
* @param destDir the destination directory.
*/
- public void setTodir(File destDir) {
+ public void setTodir(final File destDir) {
this.destDir = destDir;
}
@@ -152,7 +152,7 @@ public class Copy extends Task {
* @return a filter chain object.
*/
public FilterChain createFilterChain() {
- FilterChain filterChain = new FilterChain();
+ final FilterChain filterChain = new FilterChain();
filterChains.addElement(filterChain);
return filterChain;
}
@@ -162,7 +162,7 @@ public class Copy extends Task {
* @return a filter set object.
*/
public FilterSet createFilterSet() {
- FilterSet filterSet = new FilterSet();
+ final FilterSet filterSet = new FilterSet();
filterSets.addElement(filterSet);
return filterSet;
}
@@ -175,7 +175,8 @@ public class Copy extends Task {
* replaced with setPreserveLastModified(boolean) to
* consistently let the Introspection mechanism work.
*/
- public void setPreserveLastModified(String preserve) {
+ @Deprecated
+ public void setPreserveLastModified(final String preserve) {
setPreserveLastModified(Project.toBoolean(preserve));
}
@@ -183,7 +184,7 @@ public class Copy extends Task {
* Give the copied files the same last modified time as the original files.
* @param preserve if true preserve the modified time; default is false.
*/
- public void setPreserveLastModified(boolean preserve) {
+ public void setPreserveLastModified(final boolean preserve) {
preserveLastModified = preserve;
}
@@ -220,7 +221,7 @@ public class Copy extends Task {
* Set filtering mode.
* @param filtering if true enable filtering; default is false.
*/
- public void setFiltering(boolean filtering) {
+ public void setFiltering(final boolean filtering) {
this.filtering = filtering;
}
@@ -230,7 +231,7 @@ public class Copy extends Task {
* even if the destination file(s) are younger than
* the corresponding source file. Default is false.
*/
- public void setOverwrite(boolean overwrite) {
+ public void setOverwrite(final boolean overwrite) {
this.forceOverwrite = overwrite;
}
@@ -241,7 +242,7 @@ public class Copy extends Task {
*
* @since Ant 1.8.2
*/
- public void setForce(boolean f) {
+ public void setForce(final boolean f) {
force = f;
}
@@ -263,7 +264,7 @@ public class Copy extends Task {
* @param flatten if true flatten the destination directory. Default
* is false.
*/
- public void setFlatten(boolean flatten) {
+ public void setFlatten(final boolean flatten) {
this.flatten = flatten;
}
@@ -272,7 +273,7 @@ public class Copy extends Task {
* @param verbose whether to output the names of copied files.
* Default is false.
*/
- public void setVerbose(boolean verbose) {
+ public void setVerbose(final boolean verbose) {
this.verbosity = verbose ? Project.MSG_INFO : Project.MSG_VERBOSE;
}
@@ -280,7 +281,7 @@ public class Copy extends Task {
* Set whether to copy empty directories.
* @param includeEmpty if true copy empty directories. Default is true.
*/
- public void setIncludeEmptyDirs(boolean includeEmpty) {
+ public void setIncludeEmptyDirs(final boolean includeEmpty) {
this.includeEmpty = includeEmpty;
}
@@ -292,7 +293,7 @@ public class Copy extends Task {
* whether or not to display error messages when a file or
* directory does not exist. Default is false.
*/
- public void setQuiet(boolean quiet) {
+ public void setQuiet(final boolean quiet) {
this.quiet = quiet;
}
@@ -307,7 +308,7 @@ public class Copy extends Task {
* compatibility with earlier releases.
* @since Ant 1.6
*/
- public void setEnableMultipleMappings(boolean enableMultipleMappings) {
+ public void setEnableMultipleMappings(final boolean enableMultipleMappings) {
this.enableMultipleMappings = enableMultipleMappings;
}
@@ -324,7 +325,7 @@ public class Copy extends Task {
* to the output but keep going. Default is true.
* @param failonerror true or false.
*/
- public void setFailOnError(boolean failonerror) {
+ public void setFailOnError(final boolean failonerror) {
this.failonerror = failonerror;
}
@@ -332,7 +333,7 @@ public class Copy extends Task {
* Add a set of files to copy.
* @param set a set of files to copy.
*/
- public void addFileset(FileSet set) {
+ public void addFileset(final FileSet set) {
add(set);
}
@@ -341,7 +342,7 @@ public class Copy extends Task {
* @param res a resource collection to copy.
* @since Ant 1.7
*/
- public void add(ResourceCollection res) {
+ public void add(final ResourceCollection res) {
rcs.add(res);
}
@@ -364,7 +365,7 @@ public class Copy extends Task {
* @param fileNameMapper the mapper to add.
* @since Ant 1.6.3
*/
- public void add(FileNameMapper fileNameMapper) {
+ public void add(final FileNameMapper fileNameMapper) {
createMapper().add(fileNameMapper);
}
@@ -373,7 +374,7 @@ public class Copy extends Task {
* @param encoding the character encoding.
* @since 1.32, Ant 1.5
*/
- public void setEncoding(String encoding) {
+ public void setEncoding(final String encoding) {
this.inputEncoding = encoding;
if (outputEncoding == null) {
outputEncoding = encoding;
@@ -395,7 +396,7 @@ public class Copy extends Task {
* @param encoding the output character encoding.
* @since Ant 1.6
*/
- public void setOutputEncoding(String encoding) {
+ public void setOutputEncoding(final String encoding) {
this.outputEncoding = encoding;
}
@@ -419,7 +420,7 @@ public class Copy extends Task {
* date.
* @since Ant 1.6.2
*/
- public void setGranularity(long granularity) {
+ public void setGranularity(final long granularity) {
this.granularity = granularity;
}
@@ -427,21 +428,22 @@ public class Copy extends Task {
* Perform the copy operation.
* @exception BuildException if an error occurs.
*/
- public void execute() throws BuildException {
- File savedFile = file; // may be altered in validateAttributes
- File savedDestFile = destFile;
- File savedDestDir = destDir;
+ @Override
+ public void execute() throws BuildException {
+ final File savedFile = file; // may be altered in validateAttributes
+ final File savedDestFile = destFile;
+ final File savedDestDir = destDir;
ResourceCollection savedRc = null;
if (file == null && destFile != null && rcs.size() == 1) {
// will be removed in validateAttributes
- savedRc = (ResourceCollection) rcs.elementAt(0);
+ savedRc = rcs.elementAt(0);
}
try {
// make sure we don't have an illegal set of options
try {
validateAttributes();
- } catch (BuildException e) {
+ } catch (final BuildException e) {
if (failonerror
|| !getMessage(e)
.equals(MSG_WHEN_COPYING_EMPTY_RC_TO_FILE)) {
@@ -472,21 +474,21 @@ public class Copy extends Task {
separate lists and then each list is handled in one go.
*/
- HashMap<File, List<String>> filesByBasedir = new HashMap<File, List<String>>();
- HashMap<File, List<String>> dirsByBasedir = new HashMap<File, List<String>>();
- HashSet<File> baseDirs = new HashSet<File>();
- ArrayList<Resource> nonFileResources = new ArrayList<Resource>();
+ final HashMap<File, List<String>> filesByBasedir = new HashMap<File, List<String>>();
+ final HashMap<File, List<String>> dirsByBasedir = new HashMap<File, List<String>>();
+ final HashSet<File> baseDirs = new HashSet<File>();
+ final ArrayList<Resource> nonFileResources = new ArrayList<Resource>();
final int size = rcs.size();
for (int i = 0; i < size; i++) {
- ResourceCollection rc = rcs.elementAt(i);
+ final ResourceCollection rc = rcs.elementAt(i);
// Step (1) - beware of the ZipFileSet
if (rc instanceof FileSet && rc.isFilesystemOnly()) {
- FileSet fs = (FileSet) rc;
+ final FileSet fs = (FileSet) rc;
DirectoryScanner ds = null;
try {
ds = fs.getDirectoryScanner(getProject());
- } catch (BuildException e) {
+ } catch (final BuildException e) {
if (failonerror
|| !getMessage(e).endsWith(DirectoryScanner
.DOES_NOT_EXIST_POSTFIX)) {
@@ -498,10 +500,10 @@ public class Copy extends Task {
continue;
}
}
- File fromDir = fs.getDir(getProject());
+ final File fromDir = fs.getDir(getProject());
- String[] srcFiles = ds.getIncludedFiles();
- String[] srcDirs = ds.getIncludedDirectories();
+ final String[] srcFiles = ds.getIncludedFiles();
+ final String[] srcDirs = ds.getIncludedDirectories();
if (!flatten && mapperElement == null
&& ds.isEverythingIncluded() && !fs.hasPatterns()) {
completeDirMap.put(fromDir, destDir);
@@ -516,9 +518,9 @@ public class Copy extends Task {
"Only FileSystem resources are supported.");
}
- for (Resource r : rc) {
+ for (final Resource r : rc) {
if (!r.isExists()) {
- String message = "Warning: Could not find resource "
+ final String message = "Warning: Could not find resource "
+ r.toLongString() + " to copy.";
if (!failonerror) {
if (!quiet) {
@@ -532,9 +534,9 @@ public class Copy extends Task {
File baseDir = NULL_FILE_PLACEHOLDER;
String name = r.getName();
- FileProvider fp = r.as(FileProvider.class);
+ final FileProvider fp = r.as(FileProvider.class);
if (fp != null) {
- FileResource fr = ResourceUtils.asFileResource(fp);
+ final FileResource fr = ResourceUtils.asFileResource(fp);
baseDir = getKeyFile(fr.getBaseDir());
if (fr.getBaseDir() == null) {
name = fr.getFile().getAbsolutePath();
@@ -562,7 +564,7 @@ public class Copy extends Task {
// do all the copy operations now...
try {
doFileOperations();
- } catch (BuildException e) {
+ } catch (final BuildException e) {
if (!failonerror) {
if (!quiet) {
log("Warning: " + getMessage(e), Project.MSG_ERR);
@@ -573,17 +575,17 @@ public class Copy extends Task {
}
if (nonFileResources.size() > 0 || singleResource != null) {
- Resource[] nonFiles =
- (Resource[]) nonFileResources.toArray(new Resource[nonFileResources.size()]);
+ final Resource[] nonFiles =
+ nonFileResources.toArray(new Resource[nonFileResources.size()]);
// restrict to out-of-date resources
- Map<Resource, String[]> map = scan(nonFiles, destDir);
+ final Map<Resource, String[]> map = scan(nonFiles, destDir);
if (singleResource != null) {
map.put(singleResource,
- new String[] { destFile.getAbsolutePath() });
+ new String[] {destFile.getAbsolutePath()});
}
try {
doResourceOperations(map);
- } catch (BuildException e) {
+ } catch (final BuildException e) {
if (!failonerror) {
if (!quiet) {
log("Warning: " + getMessage(e), Project.MSG_ERR);
@@ -630,7 +632,7 @@ public class Copy extends Task {
+ " is up to date.", Project.MSG_VERBOSE);
}
} else {
- String message = "Warning: Could not find file "
+ final String message = "Warning: Could not find file "
+ file.getAbsolutePath() + " to copy.";
if (!failonerror) {
if (!quiet) {
@@ -644,11 +646,11 @@ public class Copy extends Task {
}
private void iterateOverBaseDirs(
- HashSet<File> baseDirs, HashMap<File, List<String>> dirsByBasedir, HashMap<File, List<String>> filesByBasedir) {
+ final HashSet<File> baseDirs, final HashMap<File, List<String>> dirsByBasedir, final HashMap<File, List<String>> filesByBasedir) {
- for (File f : baseDirs) {
- List<String> files = filesByBasedir.get(f);
- List<String> dirs = dirsByBasedir.get(f);
+ for (final File f : baseDirs) {
+ final List<String> files = filesByBasedir.get(f);
+ final List<String> dirs = dirsByBasedir.get(f);
String[] srcFiles = new String[0];
if (files != null) {
@@ -689,7 +691,7 @@ public class Copy extends Task {
throw new BuildException(
"Cannot concatenate multiple files into a single file.");
} else {
- ResourceCollection rc = (ResourceCollection) rcs.elementAt(0);
+ final ResourceCollection rc = rcs.elementAt(0);
if (!rc.isFilesystemOnly() && !supportsNonFileResources()) {
throw new BuildException("Only FileSystem resources are"
+ " supported.");
@@ -697,8 +699,8 @@ public class Copy extends Task {
if (rc.size() == 0) {
throw new BuildException(MSG_WHEN_COPYING_EMPTY_RC_TO_FILE);
} else if (rc.size() == 1) {
- Resource res = rc.iterator().next();
- FileProvider r = res.as(FileProvider.class);
+ final Resource res = rc.iterator().next();
+ final FileProvider r = res.as(FileProvider.class);
if (file == null) {
if (r != null) {
file = r.getFile();
@@ -730,9 +732,9 @@ public class Copy extends Task {
* @param files A list of files to copy.
* @param dirs A list of directories to copy.
*/
- protected void scan(File fromDir, File toDir, String[] files,
- String[] dirs) {
- FileNameMapper mapper = getMapper();
+ protected void scan(final File fromDir, final File toDir, final String[] files,
+ final String[] dirs) {
+ final FileNameMapper mapper = getMapper();
buildMap(fromDir, toDir, files, mapper, fileCopyMap);
if (includeEmpty) {
@@ -752,7 +754,7 @@ public class Copy extends Task {
*
* @since Ant 1.7
*/
- protected Map<Resource, String[]> scan(Resource[] fromResources, File toDir) {
+ protected Map<Resource, String[]> scan(final Resource[] fromResources, final File toDir) {
return buildMap(fromResources, toDir, getMapper());
}
@@ -765,11 +767,11 @@ public class Copy extends Task {
* @param mapper a <code>FileNameMapper</code> value.
* @param map a map of source file to array of destination files.
*/
- protected void buildMap(File fromDir, File toDir, String[] names,
- FileNameMapper mapper, Hashtable<String, String[]> map) {
+ protected void buildMap(final File fromDir, final File toDir, final String[] names,
+ final FileNameMapper mapper, final Hashtable<String, String[]> map) {
String[] toCopy = null;
if (forceOverwrite) {
- Vector<String> v = new Vector<String>();
+ final Vector<String> v = new Vector<String>();
for (int i = 0; i < names.length; i++) {
if (mapper.mapFileName(names[i]) != null) {
v.addElement(names[i]);
@@ -778,12 +780,12 @@ public class Copy extends Task {
toCopy = new String[v.size()];
v.copyInto(toCopy);
} else {
- SourceFileScanner ds = new SourceFileScanner(this);
+ final SourceFileScanner ds = new SourceFileScanner(this);
toCopy = ds.restrict(names, fromDir, toDir, mapper, granularity);
}
for (int i = 0; i < toCopy.length; i++) {
- File src = new File(fromDir, toCopy[i]);
- String[] mappedFiles = mapper.mapFileName(toCopy[i]);
+ final File src = new File(fromDir, toCopy[i]);
+ final String[] mappedFiles = mapper.mapFileName(toCopy[i]);
if (!enableMultipleMappings) {
map.put(src.getAbsolutePath(),
@@ -807,12 +809,12 @@ public class Copy extends Task {
* @return a map of source resource to array of destination files.
* @since Ant 1.7
*/
- protected Map<Resource, String[]> buildMap(Resource[] fromResources, final File toDir,
- FileNameMapper mapper) {
- HashMap<Resource, String[]> map = new HashMap<Resource, String[]>();
+ protected Map<Resource, String[]> buildMap(final Resource[] fromResources, final File toDir,
+ final FileNameMapper mapper) {
+ final HashMap<Resource, String[]> map = new HashMap<Resource, String[]>();
Resource[] toCopy = null;
if (forceOverwrite) {
- Vector<Resource> v = new Vector<Resource>();
+ final Vector<Resource> v = new Vector<Resource>();
for (int i = 0; i < fromResources.length; i++) {
if (mapper.mapFileName(fromResources[i].getName()) != null) {
v.addElement(fromResources[i]);
@@ -825,14 +827,15 @@ public class Copy extends Task {
ResourceUtils.selectOutOfDateSources(this, fromResources,
mapper,
new ResourceFactory() {
- public Resource getResource(String name) {
+ @Override
+ public Resource getResource(final String name) {
return new FileResource(toDir, name);
}
},
granularity);
}
for (int i = 0; i < toCopy.length; i++) {
- String[] mappedFiles = mapper.mapFileName(toCopy[i].getName());
+ final String[] mappedFiles = mapper.mapFileName(toCopy[i].getName());
for (int j = 0; j < mappedFiles.length; j++) {
if (mappedFiles[j] == null) {
throw new BuildException("Can't copy a resource without a"
@@ -865,12 +868,12 @@ public class Copy extends Task {
+ " file" + (fileCopyMap.size() == 1 ? "" : "s")
+ " to " + destDir.getAbsolutePath());
- for (Map.Entry<String, String[]> e : fileCopyMap.entrySet()) {
- String fromFile = e.getKey();
- String[] toFiles = e.getValue();
+ for (final Map.Entry<String, String[]> e : fileCopyMap.entrySet()) {
+ final String fromFile = e.getKey();
+ final String[] toFiles = e.getValue();
for (int i = 0; i < toFiles.length; i++) {
- String toFile = toFiles[i];
+ final String toFile = toFiles[i];
if (fromFile.equals(toFile)) {
log("Skipping self-copy of " + fromFile, verbosity);
@@ -879,13 +882,13 @@ public class Copy extends Task {
try {
log("Copying " + fromFile + " to " + toFile, verbosity);
- FilterSetCollection executionFilters =
+ final FilterSetCollection executionFilters =
new FilterSetCollection();
if (filtering) {
executionFilters
.addFilterSet(getProject().getGlobalFilterSet());
}
- for (FilterSet filterSet : filterSets) {
+ for (final FilterSet filterSet : filterSets) {
executionFilters.addFilterSet(filterSet);
}
fileUtils.copyFile(new File(fromFile), new File(toFile),
@@ -895,10 +898,10 @@ public class Copy extends Task {
/* append: */ false, inputEncoding,
outputEncoding, getProject(),
getForce());
- } catch (IOException ioe) {
+ } catch (final IOException ioe) {
String msg = "Failed to copy " + fromFile + " to " + toFile
+ " due to " + getDueTo(ioe);
- File targetFile = new File(toFile);
+ final File targetFile = new File(toFile);
if (!(ioe instanceof
ResourceUtils.ReadOnlyTargetFileException)
&& targetFile.exists() && !targetFile.delete()) {
@@ -914,9 +917,9 @@ public class Copy extends Task {
}
if (includeEmpty) {
int createCount = 0;
- for (String[] dirs : dirCopyMap.values()) {
+ for (final String[] dirs : dirCopyMap.values()) {
for (int i = 0; i < dirs.length; i++) {
- File d = new File(dirs[i]);
+ final File d = new File(dirs[i]);
if (!d.exists()) {
if (!(d.mkdirs() || d.isDirectory())) {
log("Unable to create directory "
@@ -945,25 +948,25 @@ public class Copy extends Task {
* @param map a map of source resource to array of destination files.
* @since Ant 1.7
*/
- protected void doResourceOperations(Map<Resource, String[]> map) {
+ protected void doResourceOperations(final Map<Resource, String[]> map) {
if (map.size() > 0) {
log("Copying " + map.size()
+ " resource" + (map.size() == 1 ? "" : "s")
+ " to " + destDir.getAbsolutePath());
- for (Map.Entry<Resource, String[]> e : map.entrySet()) {
- Resource fromResource = e.getKey();
- for (String toFile : e.getValue()) {
+ for (final Map.Entry<Resource, String[]> e : map.entrySet()) {
+ final Resource fromResource = e.getKey();
+ for (final String toFile : e.getValue()) {
try {
log("Copying " + fromResource + " to " + toFile,
verbosity);
- FilterSetCollection executionFilters = new FilterSetCollection();
+ final FilterSetCollection executionFilters = new FilterSetCollection();
if (filtering) {
executionFilters
.addFilterSet(getProject().getGlobalFilterSet());
}
- for (FilterSet filterSet : filterSets) {
+ for (final FilterSet filterSet : filterSets) {
executionFilters.addFilterSet(filterSet);
}
ResourceUtils.copyResource(fromResource,
@@ -978,11 +981,11 @@ public class Copy extends Task {
outputEncoding,
getProject(),
getForce());
- } catch (IOException ioe) {
+ } catch (final IOException ioe) {
String msg = "Failed to copy " + fromResource
+ " to " + toFile
+ " due to " + getDueTo(ioe);
- File targetFile = new File(toFile);
+ final File targetFile = new File(toFile);
if (!(ioe instanceof
ResourceUtils.ReadOnlyTargetFileException)
&& targetFile.exists() && !targetFile.delete()) {
@@ -1020,7 +1023,7 @@ public class Copy extends Task {
* Adds the given strings to a list contained in the given map.
* The file is the key into the map.
*/
- private static void add(File baseDir, String[] names, Map<File, List<String>> m) {
+ private static void add(File baseDir, final String[] names, final Map<File, List<String>> m) {
if (names != null) {
baseDir = getKeyFile(baseDir);
List<String> l = m.get(baseDir);
@@ -1036,7 +1039,7 @@ public class Copy extends Task {
* Adds the given string to a list contained in the given map.
* The file is the key into the map.
*/
- private static void add(File baseDir, String name, Map<File, List<String>> m) {
+ private static void add(final File baseDir, final String name, final Map<File, List<String>> m) {
if (name != null) {
add(baseDir, new String[] {name}, m);
}
@@ -1045,7 +1048,7 @@ public class Copy extends Task {
/**
* Either returns its argument or a plaeholder if the argument is null.
*/
- private static File getKeyFile(File f) {
+ private static File getKeyFile(final File f) {
return f == null ? NULL_FILE_PLACEHOLDER : f;
}
@@ -1071,7 +1074,7 @@ public class Copy extends Task {
* @return ex.getMessage() if ex.getMessage() is not null
* otherwise return ex.toString()
*/
- private String getMessage(Exception ex) {
+ private String getMessage(final Exception ex) {
return ex.getMessage() == null ? ex.toString() : ex.getMessage();
}
@@ -1082,9 +1085,9 @@ public class Copy extends Task {
* output the message
* if the exception is MalformedInput add a little note.
*/
- private String getDueTo(Exception ex) {
- boolean baseIOException = ex.getClass() == IOException.class;
- StringBuffer message = new StringBuffer();
+ private String getDueTo(final Exception ex) {
+ final boolean baseIOException = ex.getClass() == IOException.class;
+ final StringBuffer message = new StringBuffer();
if (!baseIOException || ex.getMessage() == null) {
message.append(ex.getClass().getName());
}
http://git-wip-us.apache.org/repos/asf/ant/blob/1b76f1b6/src/main/org/apache/tools/ant/taskdefs/EchoXML.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/EchoXML.java b/src/main/org/apache/tools/ant/taskdefs/EchoXML.java
index 3aac33a..16855bf 100644
--- a/src/main/org/apache/tools/ant/taskdefs/EchoXML.java
+++ b/src/main/org/apache/tools/ant/taskdefs/EchoXML.java
@@ -65,7 +65,7 @@ public class EchoXML extends XMLFragment {
public void setNamespacePolicy(NamespacePolicy n) {
namespacePolicy = n;
}
-
+
/**
* Set whether to append the output file.
* @param b boolean append flag.
@@ -115,7 +115,8 @@ public class EchoXML extends XMLFragment {
setValue(s);
}
/** {@inheritDoc}. */
- public String[] getValues() {
+ @Override
+ public String[] getValues() {
return new String[] {IGNORE, ELEMENTS, ALL};
}
http://git-wip-us.apache.org/repos/asf/ant/blob/1b76f1b6/src/main/org/apache/tools/ant/taskdefs/Get.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/Get.java b/src/main/org/apache/tools/ant/taskdefs/Get.java
index b3e4061..de07921 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Get.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Get.java
@@ -84,7 +84,7 @@ public class Get extends Task {
private boolean skipExisting = false;
private boolean httpUseCaches = true; // on by default
private Mapper mapperElement = null;
- private String userAgent =
+ private String userAgent =
System.getProperty(MagicNames.HTTP_AGENT_PROPERTY,
DEFAULT_AGENT_PREFIX + "/"
+ Main.getShortAntVersion());
@@ -94,7 +94,8 @@ public class Get extends Task {
*
* @exception BuildException Thrown in unrecoverable error.
*/
- public void execute() throws BuildException {
+ @Override
+ public void execute() throws BuildException {
checkAttributes();
for (Resource r : sources) {
@@ -166,7 +167,8 @@ public class Get extends Task {
* is false.
* @deprecated only gets the first configured resource
*/
- public boolean doGet(int logLevel, DownloadProgress progress)
+ @Deprecated
+ public boolean doGet(int logLevel, DownloadProgress progress)
throws IOException {
checkAttributes();
for (Resource r : sources) {
@@ -430,7 +432,7 @@ public class Get extends Task {
public void setSkipExisting(boolean s) {
this.skipExisting = s;
}
-
+
/**
* HTTP connections only - set the user-agent to be used
* when communicating with remote server. if null, then
@@ -456,7 +458,7 @@ public class Get extends Task {
public void setHttpUseCaches(boolean httpUseCache) {
this.httpUseCaches = httpUseCache;
}
-
+
/**
* Define the mapper to map source to destination files.
* @return a mapper to be configured.
@@ -518,7 +520,8 @@ public class Get extends Task {
/**
* begin a download
*/
- public void beginDownload() {
+ @Override
+ public void beginDownload() {
}
@@ -526,13 +529,15 @@ public class Get extends Task {
* tick handler
*
*/
- public void onTick() {
+ @Override
+ public void onTick() {
}
/**
* end a download
*/
- public void endDownload() {
+ @Override
+ public void endDownload() {
}
}
@@ -557,7 +562,8 @@ public class Get extends Task {
/**
* begin a download
*/
- public void beginDownload() {
+ @Override
+ public void beginDownload() {
dots = 0;
}
@@ -565,7 +571,8 @@ public class Get extends Task {
* tick handler
*
*/
- public void onTick() {
+ @Override
+ public void onTick() {
out.print(".");
if (dots++ > DOTS_PER_LINE) {
out.flush();
@@ -576,7 +583,8 @@ public class Get extends Task {
/**
* end a download
*/
- public void endDownload() {
+ @Override
+ public void endDownload() {
out.println();
out.flush();
}
@@ -599,7 +607,7 @@ public class Get extends Task {
private URLConnection connection;
private int redirections = 0;
private String userAgent = null;
-
+
GetThread(URL source, File dest,
boolean h, long t, DownloadProgress p, int l, String userAgent) {
this.source = source;
@@ -611,7 +619,8 @@ public class Get extends Task {
this.userAgent = userAgent;
}
- public void run() {
+ @Override
+ public void run() {
try {
success = get();
} catch (IOException ioex) {
@@ -684,7 +693,7 @@ public class Get extends Task {
}
// Set the user agent
connection.addRequestProperty("User-Agent", this.userAgent);
-
+
// prepare Java 1.1 style credentials
if (uname != null || pword != null) {
String up = uname + ":" + pword;
@@ -762,7 +771,7 @@ public class Get extends Task {
}
private boolean isMoved(int responseCode) {
- return responseCode == HttpURLConnection.HTTP_MOVED_PERM ||
+ return responseCode == HttpURLConnection.HTTP_MOVED_PERM ||
responseCode == HttpURLConnection.HTTP_MOVED_TEMP ||
responseCode == HttpURLConnection.HTTP_SEE_OTHER ||
responseCode == HTTP_MOVED_TEMP;
http://git-wip-us.apache.org/repos/asf/ant/blob/1b76f1b6/src/main/org/apache/tools/ant/taskdefs/Input.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/Input.java b/src/main/org/apache/tools/ant/taskdefs/Input.java
index 2250fe7..a1a0a22 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Input.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Input.java
@@ -56,7 +56,7 @@ public class Input extends Task {
* this allows the use of a custom inputhandler.
* @param refid the String refid.
*/
- public void setRefid(String refid) {
+ public void setRefid(final String refid) {
this.refid = refid;
}
/**
@@ -70,7 +70,7 @@ public class Input extends Task {
* Set the InputHandler classname.
* @param classname the String classname.
*/
- public void setClassname(String classname) {
+ public void setClassname(final String classname) {
this.classname = classname;
}
/**
@@ -84,7 +84,7 @@ public class Input extends Task {
* Set the handler type.
* @param type a HandlerType.
*/
- public void setType(HandlerType type) {
+ public void setType(final HandlerType type) {
this.type = type;
}
/**
@@ -101,7 +101,7 @@ public class Input extends Task {
if (refid != null) {
try {
return (InputHandler) (getProject().getReference(refid));
- } catch (ClassCastException e) {
+ } catch (final ClassCastException e) {
throw new BuildException(
refid + " does not denote an InputHandler", e);
}
@@ -120,16 +120,17 @@ public class Input extends Task {
* "default", "propertyfile", "greedy", "secure" (since Ant 1.8).
*/
public static class HandlerType extends EnumeratedAttribute {
- private static final String[] VALUES = { "default", "propertyfile", "greedy", "secure" };
+ private static final String[] VALUES = {"default", "propertyfile", "greedy", "secure"};
private static final InputHandler[] HANDLERS
- = { new DefaultInputHandler(),
+ = {new DefaultInputHandler(),
new PropertyFileInputHandler(),
new GreedyInputHandler(),
- new SecureInputHandler() };
+ new SecureInputHandler()};
/** {@inheritDoc} */
- public String[] getValues() {
+ @Override
+ public String[] getValues() {
return VALUES;
}
private InputHandler getInputHandler() {
@@ -152,7 +153,7 @@ public class Input extends Task {
*
* @param validargs A comma separated String defining valid input args.
*/
- public void setValidargs (String validargs) {
+ public void setValidargs (final String validargs) {
this.validargs = validargs;
}
@@ -163,7 +164,7 @@ public class Input extends Task {
*
* @param addproperty Name for the property to be created from input
*/
- public void setAddproperty (String addproperty) {
+ public void setAddproperty (final String addproperty) {
this.addproperty = addproperty;
}
@@ -171,7 +172,7 @@ public class Input extends Task {
* Sets the Message which gets displayed to the user during the build run.
* @param message The message to be displayed.
*/
- public void setMessage (String message) {
+ public void setMessage (final String message) {
this.message = message;
messageAttribute = true;
}
@@ -183,7 +184,7 @@ public class Input extends Task {
* @param defaultvalue Default value for the property if no input
* is received
*/
- public void setDefaultvalue (String defaultvalue) {
+ public void setDefaultvalue (final String defaultvalue) {
this.defaultvalue = defaultvalue;
}
@@ -191,7 +192,7 @@ public class Input extends Task {
* Set a multiline message.
* @param msg The message to be displayed.
*/
- public void addText(String msg) {
+ public void addText(final String msg) {
if (messageAttribute && "".equals(msg.trim())) {
return;
}
@@ -208,7 +209,8 @@ public class Input extends Task {
* Actual method executed by ant.
* @throws BuildException on error
*/
- public void execute () throws BuildException {
+ @Override
+ public void execute () throws BuildException {
if (addproperty != null
&& getProject().getProperty(addproperty) != null) {
log("skipping " + getTaskName() + " as property " + addproperty
@@ -218,14 +220,14 @@ public class Input extends Task {
InputRequest request = null;
if (validargs != null) {
- Vector<String> accept = StringUtils.split(validargs, ',');
+ final Vector<String> accept = StringUtils.split(validargs, ',');
request = new MultipleChoiceInputRequest(message, accept);
} else {
request = new InputRequest(message);
}
request.setDefaultValue(defaultvalue);
- InputHandler h = handler == null
+ final InputHandler h = handler == null
? getProject().getInputHandler()
: handler.getInputHandler();
http://git-wip-us.apache.org/repos/asf/ant/blob/1b76f1b6/src/main/org/apache/tools/ant/taskdefs/JDBCTask.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/JDBCTask.java b/src/main/org/apache/tools/ant/taskdefs/JDBCTask.java
index d65ddb4..2ca6e22 100644
--- a/src/main/org/apache/tools/ant/taskdefs/JDBCTask.java
+++ b/src/main/org/apache/tools/ant/taskdefs/JDBCTask.java
@@ -349,7 +349,7 @@ public abstract class JDBCTask extends Task {
info.put("password", getPassword());
for (Iterator<Property> props = connectionProperties.iterator();
- props.hasNext(); ) {
+ props.hasNext();) {
Property p = props.next();
String name = p.getName();
String value = p.getValue();
@@ -407,7 +407,7 @@ public abstract class JDBCTask extends Task {
// in most cases.
synchronized (LOADER_MAP) {
if (caching) {
- loader = (AntClassLoader) LOADER_MAP.get(driver);
+ loader = LOADER_MAP.get(driver);
}
if (loader == null) {
log("Loading " + driver
http://git-wip-us.apache.org/repos/asf/ant/blob/1b76f1b6/src/main/org/apache/tools/ant/taskdefs/Javac.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/Javac.java b/src/main/org/apache/tools/ant/taskdefs/Javac.java
index 75880ca..a564f76 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Javac.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Javac.java
@@ -180,7 +180,7 @@ public class Javac extends MatchingTask {
*
* @param v Value to assign to debugLevel.
*/
- public void setDebugLevel(String v) {
+ public void setDebugLevel(final String v) {
this.debugLevel = v;
}
@@ -207,7 +207,7 @@ public class Javac extends MatchingTask {
*
* @param v Value to assign to source.
*/
- public void setSource(String v) {
+ public void setSource(final String v) {
this.source = v;
}
@@ -237,7 +237,7 @@ public class Javac extends MatchingTask {
* Set the source directories to find the source Java files.
* @param srcDir the source directories as a path
*/
- public void setSrcdir(Path srcDir) {
+ public void setSrcdir(final Path srcDir) {
if (src == null) {
src = srcDir;
} else {
@@ -258,7 +258,7 @@ public class Javac extends MatchingTask {
* files should be compiled.
* @param destDir the destination director
*/
- public void setDestdir(File destDir) {
+ public void setDestdir(final File destDir) {
this.destDir = destDir;
}
@@ -275,7 +275,7 @@ public class Javac extends MatchingTask {
* Set the sourcepath to be used for this compilation.
* @param sourcepath the source path
*/
- public void setSourcepath(Path sourcepath) {
+ public void setSourcepath(final Path sourcepath) {
if (compileSourcepath == null) {
compileSourcepath = sourcepath;
} else {
@@ -306,7 +306,7 @@ public class Javac extends MatchingTask {
* Adds a reference to a source path defined elsewhere.
* @param r a reference to a source path
*/
- public void setSourcepathRef(Reference r) {
+ public void setSourcepathRef(final Reference r) {
createSourcepath().setRefid(r);
}
@@ -315,7 +315,7 @@ public class Javac extends MatchingTask {
*
* @param classpath an Ant Path object containing the compilation classpath.
*/
- public void setClasspath(Path classpath) {
+ public void setClasspath(final Path classpath) {
if (compileClasspath == null) {
compileClasspath = classpath;
} else {
@@ -346,7 +346,7 @@ public class Javac extends MatchingTask {
* Adds a reference to a classpath defined elsewhere.
* @param r a reference to a classpath
*/
- public void setClasspathRef(Reference r) {
+ public void setClasspathRef(final Reference r) {
createClasspath().setRefid(r);
}
@@ -356,7 +356,7 @@ public class Javac extends MatchingTask {
* @param bootclasspath a path to use as a boot class path (may be more
* than one)
*/
- public void setBootclasspath(Path bootclasspath) {
+ public void setBootclasspath(final Path bootclasspath) {
if (this.bootclasspath == null) {
this.bootclasspath = bootclasspath;
} else {
@@ -388,7 +388,7 @@ public class Javac extends MatchingTask {
* Adds a reference to a classpath defined elsewhere.
* @param r a reference to a classpath
*/
- public void setBootClasspathRef(Reference r) {
+ public void setBootClasspathRef(final Reference r) {
createBootclasspath().setRefid(r);
}
@@ -397,7 +397,7 @@ public class Javac extends MatchingTask {
* compilation.
* @param extdirs a path
*/
- public void setExtdirs(Path extdirs) {
+ public void setExtdirs(final Path extdirs) {
if (this.extdirs == null) {
this.extdirs = extdirs;
} else {
@@ -429,7 +429,7 @@ public class Javac extends MatchingTask {
* If true, list the source files being handed off to the compiler.
* @param list if true list the source files
*/
- public void setListfiles(boolean list) {
+ public void setListfiles(final boolean list) {
listFiles = list;
}
@@ -446,7 +446,7 @@ public class Javac extends MatchingTask {
* even if there are compilation errors; defaults to true.
* @param fail if true halt the build on failure
*/
- public void setFailonerror(boolean fail) {
+ public void setFailonerror(final boolean fail) {
failOnError = fail;
}
@@ -454,7 +454,7 @@ public class Javac extends MatchingTask {
* @ant.attribute ignore="true"
* @param proceed inverse of failoferror
*/
- public void setProceed(boolean proceed) {
+ public void setProceed(final boolean proceed) {
failOnError = !proceed;
}
@@ -471,7 +471,7 @@ public class Javac extends MatchingTask {
* compiled with deprecation information; defaults to off.
* @param deprecation if true turn on deprecation information
*/
- public void setDeprecation(boolean deprecation) {
+ public void setDeprecation(final boolean deprecation) {
this.deprecation = deprecation;
}
@@ -490,7 +490,7 @@ public class Javac extends MatchingTask {
* (Examples: 83886080, 81920k, or 80m)
* @param memoryInitialSize string to pass to VM
*/
- public void setMemoryInitialSize(String memoryInitialSize) {
+ public void setMemoryInitialSize(final String memoryInitialSize) {
this.memoryInitialSize = memoryInitialSize;
}
@@ -509,7 +509,7 @@ public class Javac extends MatchingTask {
* (Examples: 83886080, 81920k, or 80m)
* @param memoryMaximumSize string to pass to VM
*/
- public void setMemoryMaximumSize(String memoryMaximumSize) {
+ public void setMemoryMaximumSize(final String memoryMaximumSize) {
this.memoryMaximumSize = memoryMaximumSize;
}
@@ -525,7 +525,7 @@ public class Javac extends MatchingTask {
* Set the Java source file encoding name.
* @param encoding the source file encoding
*/
- public void setEncoding(String encoding) {
+ public void setEncoding(final String encoding) {
this.encoding = encoding;
}
@@ -542,7 +542,7 @@ public class Javac extends MatchingTask {
* with debug information; defaults to off.
* @param debug if true compile with debug information
*/
- public void setDebug(boolean debug) {
+ public void setDebug(final boolean debug) {
this.debug = debug;
}
@@ -558,7 +558,7 @@ public class Javac extends MatchingTask {
* If true, compiles with optimization enabled.
* @param optimize if true compile with optimization enabled
*/
- public void setOptimize(boolean optimize) {
+ public void setOptimize(final boolean optimize) {
this.optimize = optimize;
}
@@ -575,7 +575,7 @@ public class Javac extends MatchingTask {
* that support this (jikes and classic).
* @param depend if true enable dependency-tracking
*/
- public void setDepend(boolean depend) {
+ public void setDepend(final boolean depend) {
this.depend = depend;
}
@@ -591,7 +591,7 @@ public class Javac extends MatchingTask {
* If true, asks the compiler for verbose output.
* @param verbose if true, asks the compiler for verbose output
*/
- public void setVerbose(boolean verbose) {
+ public void setVerbose(final boolean verbose) {
this.verbose = verbose;
}
@@ -609,7 +609,7 @@ public class Javac extends MatchingTask {
* "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "5", "6", "7" and "8".
* @param target the target VM
*/
- public void setTarget(String target) {
+ public void setTarget(final String target) {
this.targetAttribute = target;
}
@@ -627,7 +627,7 @@ public class Javac extends MatchingTask {
* If true, includes Ant's own classpath in the classpath.
* @param include if true, includes Ant's own classpath in the classpath
*/
- public void setIncludeantruntime(boolean include) {
+ public void setIncludeantruntime(final boolean include) {
includeAntRuntime = Boolean.valueOf(include);
}
@@ -643,7 +643,7 @@ public class Javac extends MatchingTask {
* If true, includes the Java runtime libraries in the classpath.
* @param include if true, includes the Java runtime libraries in the classpath
*/
- public void setIncludejavaruntime(boolean include) {
+ public void setIncludejavaruntime(final boolean include) {
includeJavaRuntime = include;
}
@@ -661,7 +661,7 @@ public class Javac extends MatchingTask {
*
* @param f "true|false|on|off|yes|no"
*/
- public void setFork(boolean f) {
+ public void setFork(final boolean f) {
fork = f;
}
@@ -672,7 +672,7 @@ public class Javac extends MatchingTask {
* as the compiler.</p>
* @param forkExec the name of the executable
*/
- public void setExecutable(String forkExec) {
+ public void setExecutable(final String forkExec) {
forkedExecutable = forkExec;
}
@@ -719,7 +719,7 @@ public class Javac extends MatchingTask {
* If true, enables the -nowarn option.
* @param flag if true, enable the -nowarn option
*/
- public void setNowarn(boolean flag) {
+ public void setNowarn(final boolean flag) {
this.nowarn = flag;
}
@@ -736,7 +736,7 @@ public class Javac extends MatchingTask {
* @return a ImplementationSpecificArgument to be configured
*/
public ImplementationSpecificArgument createCompilerArg() {
- ImplementationSpecificArgument arg =
+ final ImplementationSpecificArgument arg =
new ImplementationSpecificArgument();
facade.addImplementationArgument(arg);
return arg;
@@ -747,15 +747,15 @@ public class Javac extends MatchingTask {
* @return array of command line arguments, guaranteed to be non-null.
*/
public String[] getCurrentCompilerArgs() {
- String chosen = facade.getExplicitChoice();
+ final String chosen = facade.getExplicitChoice();
try {
// make sure facade knows about magic properties and fork setting
- String appliedCompiler = getCompiler();
+ final String appliedCompiler = getCompiler();
facade.setImplementation(appliedCompiler);
String[] result = facade.getArgs();
- String altCompilerName = getAltCompilerName(facade.getImplementation());
+ final String altCompilerName = getAltCompilerName(facade.getImplementation());
if (result.length == 0 && altCompilerName != null) {
facade.setImplementation(altCompilerName);
@@ -769,7 +769,7 @@ public class Javac extends MatchingTask {
}
}
- private String getAltCompilerName(String anImplementation) {
+ private String getAltCompilerName(final String anImplementation) {
if (JAVAC19.equalsIgnoreCase(anImplementation)
|| JAVAC18.equalsIgnoreCase(anImplementation)
|| JAVAC17.equalsIgnoreCase(anImplementation)
@@ -784,7 +784,7 @@ public class Javac extends MatchingTask {
return CLASSIC;
}
if (MODERN.equalsIgnoreCase(anImplementation)) {
- String nextSelected = assumedJavaVersion();
+ final String nextSelected = assumedJavaVersion();
if (JAVAC19.equalsIgnoreCase(nextSelected)
|| JAVAC18.equalsIgnoreCase(nextSelected)
|| JAVAC17.equalsIgnoreCase(nextSelected)
@@ -810,7 +810,7 @@ public class Javac extends MatchingTask {
* @since Ant 1.6
* @param tmpDir the temporary directory
*/
- public void setTempdir(File tmpDir) {
+ public void setTempdir(final File tmpDir) {
this.tmpDir = tmpDir;
}
@@ -831,7 +831,7 @@ public class Javac extends MatchingTask {
* @param updatedProperty the property name to use.
* @since Ant 1.7.1.
*/
- public void setUpdatedProperty(String updatedProperty) {
+ public void setUpdatedProperty(final String updatedProperty) {
this.updatedProperty = updatedProperty;
}
@@ -842,7 +842,7 @@ public class Javac extends MatchingTask {
* @param errorProperty the property name to use.
* @since Ant 1.7.1.
*/
- public void setErrorProperty(String errorProperty) {
+ public void setErrorProperty(final String errorProperty) {
this.errorProperty = errorProperty;
}
@@ -853,7 +853,7 @@ public class Javac extends MatchingTask {
* The default value is "true".
* @param includeDestClasses the value to use.
*/
- public void setIncludeDestClasses(boolean includeDestClasses) {
+ public void setIncludeDestClasses(final boolean includeDestClasses) {
this.includeDestClasses = includeDestClasses;
}
@@ -888,7 +888,7 @@ public class Javac extends MatchingTask {
* Set the compiler adapter explicitly.
* @since Ant 1.8.0
*/
- public void add(CompilerAdapter adapter) {
+ public void add(final CompilerAdapter adapter) {
if (nestedAdapter != null) {
throw new BuildException("Can't have more than one compiler"
+ " adapter");
@@ -903,7 +903,7 @@ public class Javac extends MatchingTask {
*
* @since Ant 1.8.3
*/
- public void setCreateMissingPackageInfoClass(boolean b) {
+ public void setCreateMissingPackageInfoClass(final boolean b) {
createMissingPackageInfoClass = b;
}
@@ -911,23 +911,24 @@ public class Javac extends MatchingTask {
* Executes the task.
* @exception BuildException if an error occurs
*/
- public void execute() throws BuildException {
+ @Override
+ public void execute() throws BuildException {
checkParameters();
resetFileLists();
// scan source directories and dest directory to build up
// compile lists
- String[] list = src.list();
+ final String[] list = src.list();
for (int i = 0; i < list.length; i++) {
- File srcDir = getProject().resolveFile(list[i]);
+ final File srcDir = getProject().resolveFile(list[i]);
if (!srcDir.exists()) {
throw new BuildException("srcdir \""
+ srcDir.getPath()
+ "\" does not exist!", getLocation());
}
- DirectoryScanner ds = this.getDirectoryScanner(srcDir);
- String[] files = ds.getIncludedFiles();
+ final DirectoryScanner ds = this.getDirectoryScanner(srcDir);
+ final String[] files = ds.getIncludedFiles();
scanDir(srcDir, destDir != null ? destDir : srcDir, files);
}
@@ -956,19 +957,19 @@ public class Javac extends MatchingTask {
* @param destDir The destination directory
* @param files An array of filenames
*/
- protected void scanDir(File srcDir, File destDir, String[] files) {
- GlobPatternMapper m = new GlobPatternMapper();
- String[] extensions = findSupportedFileExtensions();
+ protected void scanDir(final File srcDir, final File destDir, final String[] files) {
+ final GlobPatternMapper m = new GlobPatternMapper();
+ final String[] extensions = findSupportedFileExtensions();
for (int i = 0; i < extensions.length; i++) {
m.setFrom(extensions[i]);
m.setTo("*.class");
- SourceFileScanner sfs = new SourceFileScanner(this);
- File[] newFiles = sfs.restrictAsFiles(files, srcDir, destDir, m);
+ final SourceFileScanner sfs = new SourceFileScanner(this);
+ final File[] newFiles = sfs.restrictAsFiles(files, srcDir, destDir, m);
if (newFiles.length > 0) {
lookForPackageInfos(srcDir, newFiles);
- File[] newCompileList
+ final File[] newCompileList
= new File[compileList.length + newFiles.length];
System.arraycopy(compileList, 0, newCompileList, 0,
compileList.length);
@@ -980,8 +981,8 @@ public class Javac extends MatchingTask {
}
private String[] findSupportedFileExtensions() {
- String compilerImpl = getCompiler();
- CompilerAdapter adapter =
+ final String compilerImpl = getCompiler();
+ final CompilerAdapter adapter =
nestedAdapter != null ? nestedAdapter :
CompilerAdapterFactory.getCompiler(compilerImpl, this,
createCompilerClasspath());
@@ -992,7 +993,7 @@ public class Javac extends MatchingTask {
}
if (extensions == null) {
- extensions = new String[] { "java" };
+ extensions = new String[] {"java"};
}
// now process the extensions to ensure that they are the
@@ -1021,7 +1022,7 @@ public class Javac extends MatchingTask {
* "javac1.1", "javac1.2", "javac1.3", "javac1.4", "javac1.5",
* "javac1.6", "javac1.7", "javac1.8" or "javac1.9".
*/
- protected boolean isJdkCompiler(String compilerImpl) {
+ protected boolean isJdkCompiler(final String compilerImpl) {
return MODERN.equals(compilerImpl)
|| CLASSIC.equals(compilerImpl)
|| JAVAC19.equals(compilerImpl)
@@ -1047,7 +1048,7 @@ public class Javac extends MatchingTask {
* @param compiler the name of the compiler
* @since Ant 1.5
*/
- public void setCompiler(String compiler) {
+ public void setCompiler(final String compiler) {
facade.setImplementation(compiler);
}
@@ -1133,7 +1134,7 @@ public class Javac extends MatchingTask {
* @since Ant 1.5
*/
protected void compile() {
- String compilerImpl = getCompiler();
+ final String compilerImpl = getCompiler();
if (compileList.length > 0) {
log("Compiling " + compileList.length + " source file"
@@ -1142,12 +1143,12 @@ public class Javac extends MatchingTask {
if (listFiles) {
for (int i = 0; i < compileList.length; i++) {
- String filename = compileList[i].getAbsolutePath();
+ final String filename = compileList[i].getAbsolutePath();
log(filename);
}
}
- CompilerAdapter adapter =
+ final CompilerAdapter adapter =
nestedAdapter != null ? nestedAdapter :
CompilerAdapterFactory.getCompiler(compilerImpl, this,
createCompilerClasspath());
@@ -1164,7 +1165,7 @@ public class Javac extends MatchingTask {
? destDir
: getProject()
.resolveFile(src.list()[0]));
- } catch (IOException x) {
+ } catch (final IOException x) {
// Should this be made a nonfatal warning?
throw new BuildException(x, getLocation());
}
@@ -1196,25 +1197,25 @@ public class Javac extends MatchingTask {
/**
* @param impl the name of the compiler
*/
- public void setCompiler(String impl) {
+ public void setCompiler(final String impl) {
super.setImplementation(impl);
}
}
- private void lookForPackageInfos(File srcDir, File[] newFiles) {
+ private void lookForPackageInfos(final File srcDir, final File[] newFiles) {
for (int i = 0; i < newFiles.length; i++) {
- File f = newFiles[i];
+ final File f = newFiles[i];
if (!f.getName().equals("package-info.java")) {
continue;
}
- String path = FILE_UTILS.removeLeadingPath(srcDir, f).
+ final String path = FILE_UTILS.removeLeadingPath(srcDir, f).
replace(File.separatorChar, '/');
- String suffix = "/package-info.java";
+ final String suffix = "/package-info.java";
if (!path.endsWith(suffix)) {
log("anomalous package-info.java path: " + path, Project.MSG_WARN);
continue;
}
- String pkg = path.substring(0, path.length() - suffix.length());
+ final String pkg = path.substring(0, path.length() - suffix.length());
packageInfos.put(pkg, new Long(f.lastModified()));
}
}
@@ -1224,22 +1225,22 @@ public class Javac extends MatchingTask {
* Otherwise this task's up-to-date tracking mechanisms do not work.
* @see <a href="https://issues.apache.org/bugzilla/show_bug.cgi?id=43114">Bug #43114</a>
*/
- private void generateMissingPackageInfoClasses(File dest) throws IOException {
- for (Entry<String, Long> entry : packageInfos.entrySet()) {
- String pkg = entry.getKey();
- Long sourceLastMod = entry.getValue();
- File pkgBinDir = new File(dest, pkg.replace('/', File.separatorChar));
+ private void generateMissingPackageInfoClasses(final File dest) throws IOException {
+ for (final Entry<String, Long> entry : packageInfos.entrySet()) {
+ final String pkg = entry.getKey();
+ final Long sourceLastMod = entry.getValue();
+ final File pkgBinDir = new File(dest, pkg.replace('/', File.separatorChar));
pkgBinDir.mkdirs();
- File pkgInfoClass = new File(pkgBinDir, "package-info.class");
+ final File pkgInfoClass = new File(pkgBinDir, "package-info.class");
if (pkgInfoClass.isFile() && pkgInfoClass.lastModified() >= sourceLastMod.longValue()) {
continue;
}
log("Creating empty " + pkgInfoClass);
- OutputStream os = new FileOutputStream(pkgInfoClass);
+ final OutputStream os = new FileOutputStream(pkgInfoClass);
try {
os.write(PACKAGE_INFO_CLASS_HEADER);
- byte[] name = pkg.getBytes("UTF-8");
- int length = name.length + /* "/package-info" */ 13;
+ final byte[] name = pkg.getBytes("UTF-8");
+ final int length = name.length + /* "/package-info" */ 13;
os.write((byte) length / 256);
os.write((byte) length % 256);
os.write(name);
http://git-wip-us.apache.org/repos/asf/ant/blob/1b76f1b6/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
index 6ff1aac..5ce62ef 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
@@ -278,7 +278,8 @@ public class Javadoc extends Task {
* Return a string rep for this object.
* @return the package name.
*/
- public String toString() {
+ @Override
+ public String toString() {
return getName();
}
}
@@ -362,7 +363,8 @@ public class Javadoc extends Task {
/**
* @return the allowed values for the access type.
*/
- public String[] getValues() {
+ @Override
+ public String[] getValues() {
// Protected first so if any GUI tool offers a default
// based on enum #0, it will be right.
return new String[] {"protected", "public", "package", "private"};
@@ -862,7 +864,8 @@ public class Javadoc extends Task {
* @deprecated since 1.5.x.
* Use the {@link #setExtdirs(Path)} version.
*/
- public void setExtdirs(String path) {
+ @Deprecated
+ public void setExtdirs(String path) {
cmd.createArgument().setValue("-extdirs");
cmd.createArgument().setValue(path);
}
@@ -1698,7 +1701,8 @@ public class Javadoc extends Task {
* Execute the task.
* @throws BuildException on error
*/
- public void execute() throws BuildException {
+ @Override
+ public void execute() throws BuildException {
checkTaskName();
Vector<String> packagesToDoc = new Vector<String>();
@@ -2428,7 +2432,8 @@ public class Javadoc extends Task {
// are there any java files in this directory?
File pd = new File(baseDir, dirs[i]);
String[] files = pd.list(new FilenameFilter () {
- public boolean accept(File dir1, String name) {
+ @Override
+ public boolean accept(File dir1, String name) {
return name.endsWith(".java")
|| (includeNoSourcePackages
&& name.equals("package.html"));
@@ -2570,7 +2575,8 @@ public class Javadoc extends Task {
//
private String queuedLine = null;
private boolean sawWarnings = false;
- protected void processLine(String line, int messageLevel) {
+ @Override
+ protected void processLine(String line, int messageLevel) {
if (line.contains("warning")) {
sawWarnings = true;
}
@@ -2600,7 +2606,7 @@ public class Javadoc extends Task {
queuedLine = null;
}
}
-
+
public boolean sawWarnings() {
return sawWarnings;
}
http://git-wip-us.apache.org/repos/asf/ant/blob/1b76f1b6/src/main/org/apache/tools/ant/taskdefs/MakeUrl.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/MakeUrl.java b/src/main/org/apache/tools/ant/taskdefs/MakeUrl.java
index 2f4eec0..8aa3b07 100644
--- a/src/main/org/apache/tools/ant/taskdefs/MakeUrl.java
+++ b/src/main/org/apache/tools/ant/taskdefs/MakeUrl.java
@@ -34,7 +34,7 @@ import org.apache.tools.ant.util.FileUtils;
/**
* <p>This task takes file and turns them into a URL, which it then assigns
* to a property. Use when for setting up RMI codebases.</p>
- *
+ *
* <p>nested filesets are supported; if present, these are turned into the
* url with the given separator between them (default = " ").</p>
*
@@ -151,7 +151,7 @@ public class MakeUrl extends Task {
StringBuilder urls = new StringBuilder();
ListIterator<FileSet> list = filesets.listIterator();
while (list.hasNext()) {
- FileSet set = (FileSet) list.next();
+ FileSet set = list.next();
DirectoryScanner scanner = set.getDirectoryScanner(getProject());
String[] files = scanner.getIncludedFiles();
for (int i = 0; i < files.length; i++) {
@@ -200,7 +200,7 @@ public class MakeUrl extends Task {
StringBuilder urls = new StringBuilder();
ListIterator<Path> list = paths.listIterator();
while (list.hasNext()) {
- Path path = (Path) list.next();
+ Path path = list.next();
String[] elements = path.list();
for (int i = 0; i < elements.length; i++) {
File f = new File(elements[i]);
@@ -234,7 +234,8 @@ public class MakeUrl extends Task {
* @throws org.apache.tools.ant.BuildException
* if something goes wrong with the build
*/
- public void execute() throws BuildException {
+ @Override
+ public void execute() throws BuildException {
validate();
//now exit here if the property is already set
if (getProject().getProperty(property) != null) {