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:56 UTC
[14/17] checkstyle
http://git-wip-us.apache.org/repos/asf/ant/blob/1b76f1b6/src/main/org/apache/tools/ant/Project.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/Project.java b/src/main/org/apache/tools/ant/Project.java
index 52a4da9..02b23c9 100644
--- a/src/main/org/apache/tools/ant/Project.java
+++ b/src/main/org/apache/tools/ant/Project.java
@@ -91,35 +91,40 @@ public class Project implements ResourceFactory {
* @deprecated since 1.5.x.
* Use {@link JavaEnvUtils#JAVA_1_0} instead.
*/
- public static final String JAVA_1_0 = JavaEnvUtils.JAVA_1_0;
+ @Deprecated
+ public static final String JAVA_1_0 = JavaEnvUtils.JAVA_1_0;
/**
* Version constant for Java 1.1 .
*
* @deprecated since 1.5.x.
* Use {@link JavaEnvUtils#JAVA_1_1} instead.
*/
- public static final String JAVA_1_1 = JavaEnvUtils.JAVA_1_1;
+ @Deprecated
+ public static final String JAVA_1_1 = JavaEnvUtils.JAVA_1_1;
/**
* Version constant for Java 1.2 .
*
* @deprecated since 1.5.x.
* Use {@link JavaEnvUtils#JAVA_1_2} instead.
*/
- public static final String JAVA_1_2 = JavaEnvUtils.JAVA_1_2;
+ @Deprecated
+ public static final String JAVA_1_2 = JavaEnvUtils.JAVA_1_2;
/**
* Version constant for Java 1.3 .
*
* @deprecated since 1.5.x.
* Use {@link JavaEnvUtils#JAVA_1_3} instead.
*/
- public static final String JAVA_1_3 = JavaEnvUtils.JAVA_1_3;
+ @Deprecated
+ public static final String JAVA_1_3 = JavaEnvUtils.JAVA_1_3;
/**
* Version constant for Java 1.4 .
*
* @deprecated since 1.5.x.
* Use {@link JavaEnvUtils#JAVA_1_4} instead.
*/
- public static final String JAVA_1_4 = JavaEnvUtils.JAVA_1_4;
+ @Deprecated
+ public static final String JAVA_1_4 = JavaEnvUtils.JAVA_1_4;
/** Default filter start token. */
public static final String TOKEN_START = FilterSet.DEFAULT_TOKEN_START;
@@ -136,18 +141,18 @@ public class Project implements ResourceFactory {
/** Map of references within the project (paths etc) (String to Object). */
- private Hashtable<String, Object> references = new AntRefTable();
+ private final Hashtable<String, Object> references = new AntRefTable();
/** Map of id references - used for indicating broken build files */
- private HashMap<String, Object> idReferences = new HashMap<String, Object>();
+ private final HashMap<String, Object> idReferences = new HashMap<String, Object>();
/** Name of the project's default target. */
private String defaultTarget;
/** Map from target names to targets (String to Target). */
- private Hashtable<String, Target> targets = new Hashtable<String, Target>();
+ private final Hashtable<String, Target> targets = new Hashtable<String, Target>();
/** Set of global filters. */
- private FilterSet globalFilterSet = new FilterSet();
+ private final FilterSet globalFilterSet = new FilterSet();
{
// Initialize the globalFileSet's project
globalFilterSet.setProject(this);
@@ -158,7 +163,7 @@ public class Project implements ResourceFactory {
* contains one FilterSet, but the wrapper is needed in order to
* make it easier to use the FileUtils interface.
*/
- private FilterSetCollection globalFilters
+ private final FilterSetCollection globalFilters
= new FilterSetCollection(globalFilterSet);
/** Project base directory. */
@@ -173,7 +178,8 @@ public class Project implements ResourceFactory {
/** for each thread, record whether it is currently executing
messageLogged */
private final ThreadLocal<Boolean> isLoggingMessage = new ThreadLocal<Boolean>() {
- protected Boolean initialValue() {
+ @Override
+ protected Boolean initialValue() {
return Boolean.FALSE;
}
};
@@ -212,7 +218,7 @@ public class Project implements ResourceFactory {
*
* @param handler the InputHandler instance to use for gathering input.
*/
- public void setInputHandler(InputHandler handler) {
+ public void setInputHandler(final InputHandler handler) {
inputHandler = handler;
}
@@ -225,7 +231,7 @@ public class Project implements ResourceFactory {
* is requested.
* @since Ant 1.6
*/
- public void setDefaultInputStream(InputStream defaultInputStream) {
+ public void setDefaultInputStream(final InputStream defaultInputStream) {
this.defaultInputStream = defaultInputStream;
}
@@ -266,8 +272,8 @@ public class Project implements ResourceFactory {
public Project createSubProject() {
Project subProject = null;
try {
- subProject = (Project) (getClass().newInstance());
- } catch (Exception e) {
+ subProject = (getClass().newInstance());
+ } catch (final Exception e) {
subProject = new Project();
}
initSubProject(subProject);
@@ -278,7 +284,7 @@ public class Project implements ResourceFactory {
* Initialize a subproject.
* @param subProject the subproject to initialize.
*/
- public void initSubProject(Project subProject) {
+ public void initSubProject(final Project subProject) {
ComponentHelper.getComponentHelper(subProject)
.initSubProject(ComponentHelper.getComponentHelper(this));
subProject.setDefaultInputStream(getDefaultInputStream());
@@ -319,7 +325,7 @@ public class Project implements ResourceFactory {
* to the result
*/
private void setAntLib() {
- File antlib = org.apache.tools.ant.launch.Locator.getClassSource(
+ final File antlib = org.apache.tools.ant.launch.Locator.getClassSource(
Project.class);
if (antlib != null) {
setPropertyInternal(MagicNames.ANT_LIB, antlib.getAbsolutePath());
@@ -333,7 +339,7 @@ public class Project implements ResourceFactory {
*
* @return an appropriate classloader.
*/
- public AntClassLoader createClassLoader(Path path) {
+ public AntClassLoader createClassLoader(final Path path) {
return AntClassLoader
.newAntClassLoader(getClass().getClassLoader(), this, path, true);
}
@@ -348,7 +354,7 @@ public class Project implements ResourceFactory {
* @return an appropriate classloader.
*/
public AntClassLoader createClassLoader(
- ClassLoader parent, Path path) {
+ final ClassLoader parent, final Path path) {
return AntClassLoader.newAntClassLoader(parent, this, path, true);
}
@@ -359,7 +365,7 @@ public class Project implements ResourceFactory {
* @param coreLoader The classloader to use for the project.
* May be <code>null</code>.
*/
- public void setCoreLoader(ClassLoader coreLoader) {
+ public void setCoreLoader(final ClassLoader coreLoader) {
this.coreLoader = coreLoader;
}
@@ -382,7 +388,7 @@ public class Project implements ResourceFactory {
* @param listener The listener to add to the list.
* Must not be <code>null</code>.
*/
- public void addBuildListener(BuildListener listener) {
+ public void addBuildListener(final BuildListener listener) {
synchronized (listenersLock) {
// If the listeners already has this listener, do nothing
for (int i = 0; i < listeners.length; i++) {
@@ -391,7 +397,7 @@ public class Project implements ResourceFactory {
}
}
// copy on write semantics
- BuildListener[] newListeners =
+ final BuildListener[] newListeners =
new BuildListener[listeners.length + 1];
System.arraycopy(listeners, 0, newListeners, 0, listeners.length);
newListeners[listeners.length] = listener;
@@ -406,12 +412,12 @@ public class Project implements ResourceFactory {
* @param listener The listener to remove from the list.
* Should not be <code>null</code>.
*/
- public void removeBuildListener(BuildListener listener) {
+ public void removeBuildListener(final BuildListener listener) {
synchronized (listenersLock) {
// copy on write semantics
for (int i = 0; i < listeners.length; i++) {
if (listeners[i] == listener) {
- BuildListener[] newListeners =
+ final BuildListener[] newListeners =
new BuildListener[listeners.length - 1];
System.arraycopy(listeners, 0, newListeners, 0, i);
System.arraycopy(listeners, i + 1, newListeners, i,
@@ -430,7 +436,7 @@ public class Project implements ResourceFactory {
*/
public Vector<BuildListener> getBuildListeners() {
synchronized (listenersLock) {
- Vector<BuildListener> r = new Vector<BuildListener>(listeners.length);
+ final Vector<BuildListener> r = new Vector<BuildListener>(listeners.length);
for (int i = 0; i < listeners.length; i++) {
r.add(listeners[i]);
}
@@ -444,7 +450,7 @@ public class Project implements ResourceFactory {
* @param message The text to log. Should not be <code>null</code>.
*/
- public void log(String message) {
+ public void log(final String message) {
log(message, MSG_INFO);
}
@@ -453,7 +459,7 @@ public class Project implements ResourceFactory {
* @param message The text to log. Should not be <code>null</code>.
* @param msgLevel The log priority level to use.
*/
- public void log(String message, int msgLevel) {
+ public void log(final String message, final int msgLevel) {
log(message, null, msgLevel);
}
@@ -464,7 +470,7 @@ public class Project implements ResourceFactory {
* @param msgLevel The log priority level to use.
* @since 1.7
*/
- public void log(String message, Throwable throwable, int msgLevel) {
+ public void log(final String message, final Throwable throwable, final int msgLevel) {
fireMessageLogged(this, message, throwable, msgLevel);
}
@@ -474,7 +480,7 @@ public class Project implements ResourceFactory {
* @param message The text to log. Should not be <code>null</code>.
* @param msgLevel The log priority level to use.
*/
- public void log(Task task, String message, int msgLevel) {
+ public void log(final Task task, final String message, final int msgLevel) {
fireMessageLogged(task, message, null, msgLevel);
}
@@ -486,7 +492,7 @@ public class Project implements ResourceFactory {
* @param msgLevel The log priority level to use.
* @since 1.7
*/
- public void log(Task task, String message, Throwable throwable, int msgLevel) {
+ public void log(final Task task, final String message, final Throwable throwable, final int msgLevel) {
fireMessageLogged(task, message, throwable, msgLevel);
}
@@ -497,7 +503,7 @@ public class Project implements ResourceFactory {
* @param message The text to log. Should not be <code>null</code>.
* @param msgLevel The log priority level to use.
*/
- public void log(Target target, String message, int msgLevel) {
+ public void log(final Target target, final String message, final int msgLevel) {
log(target, message, null, msgLevel);
}
@@ -510,8 +516,8 @@ public class Project implements ResourceFactory {
* @param msgLevel The log priority level to use.
* @since 1.7
*/
- public void log(Target target, String message, Throwable throwable,
- int msgLevel) {
+ public void log(final Target target, final String message, final Throwable throwable,
+ final int msgLevel) {
fireMessageLogged(target, message, throwable, msgLevel);
}
@@ -532,7 +538,7 @@ public class Project implements ResourceFactory {
* @param value The new value of the property.
* Must not be <code>null</code>.
*/
- public void setProperty(String name, String value) {
+ public void setProperty(final String name, final String value) {
PropertyHelper.getPropertyHelper(this).setProperty(name, value, true);
}
@@ -547,7 +553,7 @@ public class Project implements ResourceFactory {
* Must not be <code>null</code>.
* @since 1.5
*/
- public void setNewProperty(String name, String value) {
+ public void setNewProperty(final String name, final String value) {
PropertyHelper.getPropertyHelper(this).setNewProperty(name, value);
}
@@ -560,7 +566,7 @@ public class Project implements ResourceFactory {
* Must not be <code>null</code>.
* @see #setProperty(String,String)
*/
- public void setUserProperty(String name, String value) {
+ public void setUserProperty(final String name, final String value) {
PropertyHelper.getPropertyHelper(this).setUserProperty(name, value);
}
@@ -576,7 +582,7 @@ public class Project implements ResourceFactory {
* Must not be <code>null</code>.
* @see #setProperty(String,String)
*/
- public void setInheritedProperty(String name, String value) {
+ public void setInheritedProperty(final String name, final String value) {
PropertyHelper.getPropertyHelper(this).setInheritedProperty(name, value);
}
@@ -588,7 +594,7 @@ public class Project implements ResourceFactory {
* Must not be <code>null</code>.
* @param value The property value. Must not be <code>null</code>.
*/
- private void setPropertyInternal(String name, String value) {
+ private void setPropertyInternal(final String name, final String value) {
PropertyHelper.getPropertyHelper(this).setProperty(name, value, false);
}
@@ -601,8 +607,8 @@ public class Project implements ResourceFactory {
* @return the property value, or <code>null</code> for no match
* or if a <code>null</code> name is provided.
*/
- public String getProperty(String propertyName) {
- Object value = PropertyHelper.getPropertyHelper(this).getProperty(propertyName);
+ public String getProperty(final String propertyName) {
+ final Object value = PropertyHelper.getPropertyHelper(this).getProperty(propertyName);
return value == null ? null : String.valueOf(value);
}
@@ -620,7 +626,7 @@ public class Project implements ResourceFactory {
* @exception BuildException if the given value has an unclosed
* property name, e.g. <code>${xxx</code>.
*/
- public String replaceProperties(String value) throws BuildException {
+ public String replaceProperties(final String value) throws BuildException {
return PropertyHelper.getPropertyHelper(this).replaceProperties(null, value, null);
}
@@ -633,7 +639,7 @@ public class Project implements ResourceFactory {
* @return the property value, or <code>null</code> for no match
* or if a <code>null</code> name is provided.
*/
- public String getUserProperty(String propertyName) {
+ public String getUserProperty(final String propertyName) {
return (String) PropertyHelper.getPropertyHelper(this).getUserProperty(propertyName);
}
@@ -675,7 +681,7 @@ public class Project implements ResourceFactory {
*
* @since Ant 1.5
*/
- public void copyUserProperties(Project other) {
+ public void copyUserProperties(final Project other) {
PropertyHelper.getPropertyHelper(this).copyUserProperties(other);
}
@@ -691,7 +697,7 @@ public class Project implements ResourceFactory {
*
* @since Ant 1.5
*/
- public void copyInheritedProperties(Project other) {
+ public void copyInheritedProperties(final Project other) {
PropertyHelper.getPropertyHelper(this).copyInheritedProperties(other);
}
@@ -706,7 +712,8 @@ public class Project implements ResourceFactory {
* Use setDefault.
* @see #setDefault(String)
*/
- public void setDefaultTarget(String defaultTarget) {
+ @Deprecated
+ public void setDefaultTarget(final String defaultTarget) {
setDefault(defaultTarget);
}
@@ -726,7 +733,7 @@ public class Project implements ResourceFactory {
* May be <code>null</code>, indicating that there is
* no default target.
*/
- public void setDefault(String defaultTarget) {
+ public void setDefault(final String defaultTarget) {
if (defaultTarget != null) {
setUserProperty(MagicNames.PROJECT_DEFAULT_TARGET, defaultTarget);
}
@@ -740,7 +747,7 @@ public class Project implements ResourceFactory {
* @param name The name of the project.
* Must not be <code>null</code>.
*/
- public void setName(String name) {
+ public void setName(final String name) {
setUserProperty(MagicNames.PROJECT_NAME, name);
this.name = name;
}
@@ -760,7 +767,7 @@ public class Project implements ResourceFactory {
* @param description The description of the project.
* May be <code>null</code>.
*/
- public void setDescription(String description) {
+ public void setDescription(final String description) {
this.description = description;
}
@@ -790,7 +797,8 @@ public class Project implements ResourceFactory {
* @see #getGlobalFilterSet()
* @see FilterSet#addFilter(String,String)
*/
- public void addFilter(String token, String value) {
+ @Deprecated
+ public void addFilter(final String token, final String value) {
if (token == null) {
return;
}
@@ -809,7 +817,8 @@ public class Project implements ResourceFactory {
* @see #getGlobalFilterSet()
* @see FilterSet#getFilterHash()
*/
- public Hashtable<String, String> getFilters() {
+ @Deprecated
+ public Hashtable<String, String> getFilters() {
// we need to build the hashtable dynamically
return globalFilterSet.getFilterHash();
}
@@ -823,7 +832,7 @@ public class Project implements ResourceFactory {
*
* @exception BuildException if the directory if invalid.
*/
- public void setBasedir(String baseD) throws BuildException {
+ public void setBasedir(final String baseD) throws BuildException {
setBaseDir(new File(baseD));
}
@@ -848,7 +857,7 @@ public class Project implements ResourceFactory {
}
this.baseDir = baseDir;
setPropertyInternal(MagicNames.PROJECT_BASEDIR, this.baseDir.getPath());
- String msg = "Project base dir set to: " + this.baseDir;
+ final String msg = "Project base dir set to: " + this.baseDir;
log(msg, MSG_VERBOSE);
}
@@ -862,7 +871,7 @@ public class Project implements ResourceFactory {
if (baseDir == null) {
try {
setBasedir(".");
- } catch (BuildException ex) {
+ } catch (final BuildException ex) {
ex.printStackTrace();
}
}
@@ -878,7 +887,7 @@ public class Project implements ResourceFactory {
* @param keepGoingMode "keep-going" mode
* @since Ant 1.6
*/
- public void setKeepGoingMode(boolean keepGoingMode) {
+ public void setKeepGoingMode(final boolean keepGoingMode) {
this.keepGoingMode = keepGoingMode;
}
@@ -900,7 +909,8 @@ public class Project implements ResourceFactory {
* @deprecated since 1.5.x.
* Use org.apache.tools.ant.util.JavaEnvUtils instead.
*/
- public static String getJavaVersion() {
+ @Deprecated
+ public static String getJavaVersion() {
return JavaEnvUtils.getJavaVersion();
}
@@ -915,7 +925,7 @@ public class Project implements ResourceFactory {
* @see org.apache.tools.ant.util.JavaEnvUtils#getJavaVersion
*/
public void setJavaVersionProperty() throws BuildException {
- String javaVersion = JavaEnvUtils.getJavaVersion();
+ final String javaVersion = JavaEnvUtils.getJavaVersion();
setPropertyInternal(MagicNames.ANT_JAVA_VERSION, javaVersion);
// sanity check
@@ -933,11 +943,11 @@ public class Project implements ResourceFactory {
* user properties to the project properties.
*/
public void setSystemProperties() {
- Properties systemP = System.getProperties();
- Enumeration<?> e = systemP.propertyNames();
+ final Properties systemP = System.getProperties();
+ final Enumeration<?> e = systemP.propertyNames();
while (e.hasMoreElements()) {
- String propertyName = (String) e.nextElement();
- String value = systemP.getProperty(propertyName);
+ final String propertyName = (String) e.nextElement();
+ final String value = systemP.getProperty(propertyName);
if (value != null) {
this.setPropertyInternal(propertyName, value);
}
@@ -964,7 +974,7 @@ public class Project implements ResourceFactory {
*
* @see #checkTaskClass(Class)
*/
- public void addTaskDefinition(String taskName, Class<?> taskClass)
+ public void addTaskDefinition(final String taskName, final Class<?> taskClass)
throws BuildException {
ComponentHelper.getComponentHelper(this).addTaskDefinition(taskName,
taskClass);
@@ -999,13 +1009,13 @@ public class Project implements ResourceFactory {
taskClass.getConstructor();
// don't have to check for public, since
// getConstructor finds public constructors only.
- } catch (NoSuchMethodException e) {
+ } catch (final NoSuchMethodException e) {
final String message = "No public no-arg constructor in "
+ taskClass;
log(message, Project.MSG_ERR);
throw new BuildException(message);
- } catch (LinkageError e) {
- String message = "Could not load " + taskClass + ": " + e;
+ } catch (final LinkageError e) {
+ final String message = "Could not load " + taskClass + ": " + e;
log(message, Project.MSG_ERR);
throw new BuildException(message, e);
}
@@ -1051,7 +1061,7 @@ public class Project implements ResourceFactory {
* @param typeClass The full name of the class implementing the datatype.
* Must not be <code>null</code>.
*/
- public void addDataTypeDefinition(String typeName, Class<?> typeClass) {
+ public void addDataTypeDefinition(final String typeName, final Class<?> typeClass) {
ComponentHelper.getComponentHelper(this).addDataTypeDefinition(typeName,
typeClass);
}
@@ -1090,7 +1100,7 @@ public class Project implements ResourceFactory {
*
* @see Project#addOrReplaceTarget(Target)
*/
- public void addTarget(Target target) throws BuildException {
+ public void addTarget(final Target target) throws BuildException {
addTarget(target.getName(), target);
}
@@ -1106,7 +1116,7 @@ public class Project implements ResourceFactory {
*
* @see Project#addOrReplaceTarget(String, Target)
*/
- public void addTarget(String targetName, Target target)
+ public void addTarget(final String targetName, final Target target)
throws BuildException {
if (targets.get(targetName) != null) {
throw new BuildException("Duplicate target: `" + targetName + "'");
@@ -1121,7 +1131,7 @@ public class Project implements ResourceFactory {
* @param target The target to be added or replaced in the project.
* Must not be <code>null</code>.
*/
- public void addOrReplaceTarget(Target target) {
+ public void addOrReplaceTarget(final Target target) {
addOrReplaceTarget(target.getName(), target);
}
@@ -1134,8 +1144,8 @@ public class Project implements ResourceFactory {
* @param target The target to be added or replaced in the project.
* Must not be <code>null</code>.
*/
- public void addOrReplaceTarget(String targetName, Target target) {
- String msg = " +Target: " + targetName;
+ public void addOrReplaceTarget(final String targetName, final Target target) {
+ final String msg = " +Target: " + targetName;
log(msg, MSG_DEBUG);
target.setProject(this);
targets.put(targetName, target);
@@ -1173,7 +1183,7 @@ public class Project implements ResourceFactory {
* @exception BuildException if the task name is recognised but task
* creation fails.
*/
- public Task createTask(String taskType) throws BuildException {
+ public Task createTask(final String taskType) throws BuildException {
return ComponentHelper.getComponentHelper(this).createTask(taskType);
}
@@ -1189,7 +1199,7 @@ public class Project implements ResourceFactory {
* @exception BuildException if the data type name is recognised but
* instance creation fails.
*/
- public Object createDataType(String typeName) throws BuildException {
+ public Object createDataType(final String typeName) throws BuildException {
return ComponentHelper.getComponentHelper(this).createDataType(typeName);
}
@@ -1197,7 +1207,7 @@ public class Project implements ResourceFactory {
* Set the Executor instance for this Project.
* @param e the Executor to use.
*/
- public void setExecutor(Executor e) {
+ public void setExecutor(final Executor e) {
addReference(MagicNames.ANT_EXECUTOR_REFERENCE, e);
}
@@ -1215,14 +1225,14 @@ public class Project implements ResourceFactory {
log("Attempting to create object of type " + classname, MSG_DEBUG);
try {
o = Class.forName(classname, true, coreLoader).newInstance();
- } catch (ClassNotFoundException seaEnEfEx) {
+ } catch (final ClassNotFoundException seaEnEfEx) {
//try the current classloader
try {
o = Class.forName(classname).newInstance();
- } catch (Exception ex) {
+ } catch (final Exception ex) {
log(ex.toString(), MSG_ERR);
}
- } catch (Exception ex) {
+ } catch (final Exception ex) {
log(ex.toString(), MSG_ERR);
}
if (o == null) {
@@ -1243,7 +1253,7 @@ public class Project implements ResourceFactory {
*
* @exception BuildException if the build failed.
*/
- public void executeTargets(Vector<String> names) throws BuildException {
+ public void executeTargets(final Vector<String> names) throws BuildException {
setUserProperty(MagicNames.PROJECT_INVOKED_TARGETS,
CollectionUtils.flattenToString(names));
getExecutor().executeTargets(this, names.toArray(new String[names.size()]));
@@ -1258,8 +1268,8 @@ public class Project implements ResourceFactory {
* @param isWarning Whether the text represents an warning (<code>true</code>)
* or information (<code>false</code>).
*/
- public void demuxOutput(String output, boolean isWarning) {
- Task task = getThreadTask(Thread.currentThread());
+ public void demuxOutput(final String output, final boolean isWarning) {
+ final Task task = getThreadTask(Thread.currentThread());
if (task == null) {
log(output, isWarning ? MSG_WARN : MSG_INFO);
} else {
@@ -1284,7 +1294,7 @@ public class Project implements ResourceFactory {
* @exception IOException if the data cannot be read.
* @since Ant 1.6
*/
- public int defaultInput(byte[] buffer, int offset, int length)
+ public int defaultInput(final byte[] buffer, final int offset, final int length)
throws IOException {
if (defaultInputStream != null) {
System.out.flush();
@@ -1306,9 +1316,9 @@ public class Project implements ResourceFactory {
* @exception IOException if the data cannot be read.
* @since Ant 1.6
*/
- public int demuxInput(byte[] buffer, int offset, int length)
+ public int demuxInput(final byte[] buffer, final int offset, final int length)
throws IOException {
- Task task = getThreadTask(Thread.currentThread());
+ final Task task = getThreadTask(Thread.currentThread());
if (task == null) {
return defaultInput(buffer, offset, length);
} else {
@@ -1327,8 +1337,8 @@ public class Project implements ResourceFactory {
* @param isError Whether the text represents an error (<code>true</code>)
* or information (<code>false</code>).
*/
- public void demuxFlush(String output, boolean isError) {
- Task task = getThreadTask(Thread.currentThread());
+ public void demuxFlush(final String output, final boolean isError) {
+ final Task task = getThreadTask(Thread.currentThread());
if (task == null) {
fireMessageLogged(this, output, isError ? MSG_ERR : MSG_INFO);
} else {
@@ -1348,13 +1358,13 @@ public class Project implements ResourceFactory {
*
* @exception BuildException if the build failed.
*/
- public void executeTarget(String targetName) throws BuildException {
+ public void executeTarget(final String targetName) throws BuildException {
// sanity check ourselves, if we've been asked to build nothing
// then we should complain
if (targetName == null) {
- String msg = "No target specified";
+ final String msg = "No target specified";
throw new BuildException(msg);
}
@@ -1370,15 +1380,15 @@ public class Project implements ResourceFactory {
* @param sortedTargets the aforementioned <code>Vector</code>.
* @throws BuildException on error.
*/
- public void executeSortedTargets(Vector<Target> sortedTargets)
+ public void executeSortedTargets(final Vector<Target> sortedTargets)
throws BuildException {
- Set<String> succeededTargets = new HashSet<String>();
+ final Set<String> succeededTargets = new HashSet<String>();
BuildException buildException = null; // first build exception
- for (Target curtarget : sortedTargets) {
+ for (final Target curtarget : sortedTargets) {
boolean canExecute = true;
- for (Enumeration<String> depIter = curtarget.getDependencies();
+ for (final Enumeration<String> depIter = curtarget.getDependencies();
depIter.hasMoreElements();) {
- String dependencyName = depIter.nextElement();
+ final String dependencyName = depIter.nextElement();
if (!succeededTargets.contains(dependencyName)) {
canExecute = false;
log(curtarget,
@@ -1393,12 +1403,12 @@ public class Project implements ResourceFactory {
try {
curtarget.performTasks();
succeededTargets.add(curtarget.getName());
- } catch (RuntimeException ex) {
+ } catch (final RuntimeException ex) {
if (!(keepGoingMode)) {
throw ex; // throw further
}
thrownException = ex;
- } catch (Throwable ex) {
+ } catch (final Throwable ex) {
if (!(keepGoingMode)) {
throw new BuildException(ex);
}
@@ -1450,7 +1460,8 @@ public class Project implements ResourceFactory {
*
* @deprecated since 1.4.x
*/
- public File resolveFile(String fileName, File rootDir) {
+ @Deprecated
+ public File resolveFile(final String fileName, final File rootDir) {
return FILE_UTILS.resolveFile(rootDir, fileName);
}
@@ -1466,7 +1477,7 @@ public class Project implements ResourceFactory {
* @return the resolved File.
*
*/
- public File resolveFile(String fileName) {
+ public File resolveFile(final String fileName) {
return FILE_UTILS.resolveFile(baseDir, fileName);
}
@@ -1489,7 +1500,8 @@ public class Project implements ResourceFactory {
*
* @see PathTokenizer
*/
- public static String translatePath(String toProcess) {
+ @Deprecated
+ public static String translatePath(final String toProcess) {
return FileUtils.translatePath(toProcess);
}
@@ -1506,7 +1518,8 @@ public class Project implements ResourceFactory {
*
* @deprecated since 1.4.x
*/
- public void copyFile(String sourceFile, String destFile)
+ @Deprecated
+ public void copyFile(final String sourceFile, final String destFile)
throws IOException {
FILE_UTILS.copyFile(sourceFile, destFile);
}
@@ -1526,7 +1539,8 @@ public class Project implements ResourceFactory {
*
* @deprecated since 1.4.x
*/
- public void copyFile(String sourceFile, String destFile, boolean filtering)
+ @Deprecated
+ public void copyFile(final String sourceFile, final String destFile, final boolean filtering)
throws IOException {
FILE_UTILS.copyFile(sourceFile, destFile,
filtering ? globalFilters : null);
@@ -1550,8 +1564,9 @@ public class Project implements ResourceFactory {
*
* @deprecated since 1.4.x
*/
- public void copyFile(String sourceFile, String destFile, boolean filtering,
- boolean overwrite) throws IOException {
+ @Deprecated
+ public void copyFile(final String sourceFile, final String destFile, final boolean filtering,
+ final boolean overwrite) throws IOException {
FILE_UTILS.copyFile(sourceFile, destFile,
filtering ? globalFilters : null, overwrite);
}
@@ -1579,8 +1594,9 @@ public class Project implements ResourceFactory {
*
* @deprecated since 1.4.x
*/
- public void copyFile(String sourceFile, String destFile, boolean filtering,
- boolean overwrite, boolean preserveLastModified)
+ @Deprecated
+ public void copyFile(final String sourceFile, final String destFile, final boolean filtering,
+ final boolean overwrite, final boolean preserveLastModified)
throws IOException {
FILE_UTILS.copyFile(sourceFile, destFile,
filtering ? globalFilters : null, overwrite, preserveLastModified);
@@ -1599,7 +1615,8 @@ public class Project implements ResourceFactory {
*
* @deprecated since 1.4.x
*/
- public void copyFile(File sourceFile, File destFile) throws IOException {
+ @Deprecated
+ public void copyFile(final File sourceFile, final File destFile) throws IOException {
FILE_UTILS.copyFile(sourceFile, destFile);
}
@@ -1618,7 +1635,8 @@ public class Project implements ResourceFactory {
*
* @deprecated since 1.4.x
*/
- public void copyFile(File sourceFile, File destFile, boolean filtering)
+ @Deprecated
+ public void copyFile(final File sourceFile, final File destFile, final boolean filtering)
throws IOException {
FILE_UTILS.copyFile(sourceFile, destFile,
filtering ? globalFilters : null);
@@ -1642,8 +1660,9 @@ public class Project implements ResourceFactory {
*
* @deprecated since 1.4.x
*/
- public void copyFile(File sourceFile, File destFile, boolean filtering,
- boolean overwrite) throws IOException {
+ @Deprecated
+ public void copyFile(final File sourceFile, final File destFile, final boolean filtering,
+ final boolean overwrite) throws IOException {
FILE_UTILS.copyFile(sourceFile, destFile,
filtering ? globalFilters : null, overwrite);
}
@@ -1671,8 +1690,9 @@ public class Project implements ResourceFactory {
*
* @deprecated since 1.4.x
*/
- public void copyFile(File sourceFile, File destFile, boolean filtering,
- boolean overwrite, boolean preserveLastModified)
+ @Deprecated
+ public void copyFile(final File sourceFile, final File destFile, final boolean filtering,
+ final boolean overwrite, final boolean preserveLastModified)
throws IOException {
FILE_UTILS.copyFile(sourceFile, destFile,
filtering ? globalFilters : null, overwrite, preserveLastModified);
@@ -1693,7 +1713,8 @@ public class Project implements ResourceFactory {
* despite running on a platform with a version
* above 1.1.
*/
- public void setFileLastModified(File file, long time)
+ @Deprecated
+ public void setFileLastModified(final File file, final long time)
throws BuildException {
FILE_UTILS.setFileLastModified(file, time);
log("Setting modification time for " + file, MSG_VERBOSE);
@@ -1710,7 +1731,7 @@ public class Project implements ResourceFactory {
* <code>"true"</code> or <code>"yes"</code>, or
* <code>false</code> otherwise.
*/
- public static boolean toBoolean(String s) {
+ public static boolean toBoolean(final String s) {
return ("on".equalsIgnoreCase(s)
|| "true".equalsIgnoreCase(s)
|| "yes".equalsIgnoreCase(s));
@@ -1722,16 +1743,16 @@ public class Project implements ResourceFactory {
* @return Project instance, if any.
* @since Ant 1.7.1
*/
- public static Project getProject(Object o) {
+ public static Project getProject(final Object o) {
if (o instanceof ProjectComponent) {
return ((ProjectComponent) o).getProject();
}
try {
- Method m = o.getClass().getMethod("getProject", (Class[]) null);
+ final Method m = o.getClass().getMethod("getProject", (Class[]) null);
if (Project.class == m.getReturnType()) {
return (Project) m.invoke(o, (Object[]) null);
}
- } catch (Exception e) {
+ } catch (final Exception e) {
//too bad
}
return null;
@@ -1751,7 +1772,7 @@ public class Project implements ResourceFactory {
* @exception BuildException if there is a cyclic dependency among the
* targets, or if a named target does not exist.
*/
- public final Vector<Target> topoSort(String root, Hashtable<String, Target> targetTable)
+ public final Vector<Target> topoSort(final String root, final Hashtable<String, Target> targetTable)
throws BuildException {
return topoSort(new String[] {root}, targetTable, true);
}
@@ -1773,8 +1794,8 @@ public class Project implements ResourceFactory {
* targets, or if a named target does not exist.
* @since Ant 1.6.3
*/
- public final Vector<Target> topoSort(String root, Hashtable<String, Target> targetTable,
- boolean returnAll) throws BuildException {
+ public final Vector<Target> topoSort(final String root, final Hashtable<String, Target> targetTable,
+ final boolean returnAll) throws BuildException {
return topoSort(new String[] {root}, targetTable, returnAll);
}
@@ -1795,11 +1816,11 @@ public class Project implements ResourceFactory {
* targets, or if a named target does not exist.
* @since Ant 1.6.3
*/
- public final Vector<Target> topoSort(String[] root, Hashtable<String, Target> targetTable,
- boolean returnAll) throws BuildException {
- Vector<Target> ret = new VectorSet<Target>();
- Hashtable<String, String> state = new Hashtable<String, String>();
- Stack<String> visiting = new Stack<String>();
+ public final Vector<Target> topoSort(final String[] root, final Hashtable<String, Target> targetTable,
+ final boolean returnAll) throws BuildException {
+ final Vector<Target> ret = new VectorSet<Target>();
+ final Hashtable<String, String> state = new Hashtable<String, String>();
+ final Stack<String> visiting = new Stack<String>();
// We first run a DFS based sort using each root as a starting node.
// This creates the minimum sequence of Targets to the root node(s).
@@ -1810,7 +1831,7 @@ public class Project implements ResourceFactory {
// build Target.
for (int i = 0; i < root.length; i++) {
- String st = (String) (state.get(root[i]));
+ final String st = (state.get(root[i]));
if (st == null) {
tsort(root[i], targetTable, state, visiting, ret);
} else if (st == VISITING) {
@@ -1818,7 +1839,7 @@ public class Project implements ResourceFactory {
+ root[i]);
}
}
- StringBuffer buf = new StringBuffer("Build sequence for target(s)");
+ final StringBuffer buf = new StringBuffer("Build sequence for target(s)");
for (int j = 0; j < root.length; j++) {
buf.append((j == 0) ? " `" : ", `").append(root[j]).append('\'');
@@ -1826,10 +1847,10 @@ public class Project implements ResourceFactory {
buf.append(" is " + ret);
log(buf.toString(), MSG_VERBOSE);
- Vector<Target> complete = (returnAll) ? ret : new Vector<Target>(ret);
- for (Enumeration<String> en = targetTable.keys(); en.hasMoreElements();) {
- String curTarget = en.nextElement();
- String st = state.get(curTarget);
+ final Vector<Target> complete = (returnAll) ? ret : new Vector<Target>(ret);
+ for (final Enumeration<String> en = targetTable.keys(); en.hasMoreElements();) {
+ final String curTarget = en.nextElement();
+ final String st = state.get(curTarget);
if (st == null) {
tsort(curTarget, targetTable, state, visiting, complete);
} else if (st == VISITING) {
@@ -1881,34 +1902,34 @@ public class Project implements ResourceFactory {
* @exception BuildException if a non-existent target is specified or if
* a circular dependency is detected.
*/
- private void tsort(String root, Hashtable<String, Target> targetTable,
- Hashtable<String, String> state, Stack<String> visiting,
- Vector<Target> ret)
+ private void tsort(final String root, final Hashtable<String, Target> targetTable,
+ final Hashtable<String, String> state, final Stack<String> visiting,
+ final Vector<Target> ret)
throws BuildException {
state.put(root, VISITING);
visiting.push(root);
- Target target = targetTable.get(root);
+ final Target target = targetTable.get(root);
// Make sure we exist
if (target == null) {
- StringBuilder sb = new StringBuilder("Target \"");
+ final StringBuilder sb = new StringBuilder("Target \"");
sb.append(root);
sb.append("\" does not exist in the project \"");
sb.append(name);
sb.append("\". ");
visiting.pop();
if (!visiting.empty()) {
- String parent = visiting.peek();
+ final String parent = visiting.peek();
sb.append("It is used from target \"");
sb.append(parent);
sb.append("\".");
}
throw new BuildException(new String(sb));
}
- for (Enumeration<String> en = target.getDependencies(); en.hasMoreElements();) {
- String cur = en.nextElement();
- String m = state.get(cur);
+ for (final Enumeration<String> en = target.getDependencies(); en.hasMoreElements();) {
+ final String cur = en.nextElement();
+ final String m = state.get(cur);
if (m == null) {
// Not been visited
tsort(cur, targetTable, state, visiting, ret);
@@ -1917,7 +1938,7 @@ public class Project implements ResourceFactory {
throw makeCircularException(cur, visiting);
}
}
- String p = visiting.pop();
+ final String p = visiting.pop();
if (root != p) {
throw new RuntimeException("Unexpected internal error: expected to "
+ "pop " + root + " but got " + p);
@@ -1935,7 +1956,7 @@ public class Project implements ResourceFactory {
*
* @return a BuildException detailing the specified circular dependency.
*/
- private static BuildException makeCircularException(String end, Stack<String> stk) {
+ private static BuildException makeCircularException(final String end, final Stack<String> stk) {
final StringBuilder sb = new StringBuilder("Circular dependency: ");
sb.append(end);
String c;
@@ -1951,7 +1972,7 @@ public class Project implements ResourceFactory {
* Inherit the id references.
* @param parent the parent project of this project.
*/
- public void inheritIDReferences(Project parent) {
+ public void inheritIDReferences(final Project parent) {
}
/**
@@ -1960,7 +1981,7 @@ public class Project implements ResourceFactory {
* @param id the id to set.
* @param value the value to set it to (Unknown element in this case.
*/
- public void addIdReference(String id, Object value) {
+ public void addIdReference(final String id, final Object value) {
idReferences.put(id, value);
}
@@ -1970,8 +1991,8 @@ public class Project implements ResourceFactory {
* @param referenceName The name of the reference. Must not be <code>null</code>.
* @param value The value of the reference.
*/
- public void addReference(String referenceName, Object value) {
- Object old = ((AntRefTable) references).getReal(referenceName);
+ public void addReference(final String referenceName, final Object value) {
+ final Object old = ((AntRefTable) references).getReal(referenceName);
if (old == value) {
// no warning, this is not changing anything
return;
@@ -1999,7 +2020,7 @@ public class Project implements ResourceFactory {
*
* @since Ant 1.8.0
*/
- public boolean hasReference(String key) {
+ public boolean hasReference(final String key) {
return references.containsKey(key);
}
@@ -2025,7 +2046,7 @@ public class Project implements ResourceFactory {
* @return the reference with the specified ID, or <code>null</code> if
* there is no such reference in the project, with type inference.
*/
- public <T> T getReference(String key) {
+ public <T> T getReference(final String key) {
@SuppressWarnings("unchecked")
final T ret = (T) references.get(key);
if (ret != null) {
@@ -2037,7 +2058,7 @@ public class Project implements ResourceFactory {
log("Unresolvable reference " + key
+ " might be a misuse of property expansion syntax.", MSG_WARN);
}
- } catch (Exception e) {
+ } catch (final Exception e) {
//ignore
}
}
@@ -2057,7 +2078,7 @@ public class Project implements ResourceFactory {
*
* @since 1.95, Ant 1.5
*/
- public String getElementName(Object element) {
+ public String getElementName(final Object element) {
return ComponentHelper.getComponentHelper(this).getElementName(element);
}
@@ -2066,8 +2087,8 @@ public class Project implements ResourceFactory {
* to the build listeners for this project.
*/
public void fireBuildStarted() {
- BuildEvent event = new BuildEvent(this);
- BuildListener[] currListeners = listeners;
+ final BuildEvent event = new BuildEvent(this);
+ final BuildListener[] currListeners = listeners;
for (int i = 0; i < currListeners.length; i++) {
currListeners[i].buildStarted(event);
}
@@ -2080,10 +2101,10 @@ public class Project implements ResourceFactory {
* failure. May be <code>null</code>, indicating
* a successful build.
*/
- public void fireBuildFinished(Throwable exception) {
- BuildEvent event = new BuildEvent(this);
+ public void fireBuildFinished(final Throwable exception) {
+ final BuildEvent event = new BuildEvent(this);
event.setException(exception);
- BuildListener[] currListeners = listeners;
+ final BuildListener[] currListeners = listeners;
for (int i = 0; i < currListeners.length; i++) {
currListeners[i].buildFinished(event);
}
@@ -2098,8 +2119,8 @@ public class Project implements ResourceFactory {
* @since Ant 1.6.2
*/
public void fireSubBuildStarted() {
- BuildEvent event = new BuildEvent(this);
- BuildListener[] currListeners = listeners;
+ final BuildEvent event = new BuildEvent(this);
+ final BuildListener[] currListeners = listeners;
for (int i = 0; i < currListeners.length; i++) {
if (currListeners[i] instanceof SubBuildListener) {
((SubBuildListener) currListeners[i]).subBuildStarted(event);
@@ -2116,10 +2137,10 @@ public class Project implements ResourceFactory {
*
* @since Ant 1.6.2
*/
- public void fireSubBuildFinished(Throwable exception) {
- BuildEvent event = new BuildEvent(this);
+ public void fireSubBuildFinished(final Throwable exception) {
+ final BuildEvent event = new BuildEvent(this);
event.setException(exception);
- BuildListener[] currListeners = listeners;
+ final BuildListener[] currListeners = listeners;
for (int i = 0; i < currListeners.length; i++) {
if (currListeners[i] instanceof SubBuildListener) {
((SubBuildListener) currListeners[i]).subBuildFinished(event);
@@ -2134,9 +2155,9 @@ public class Project implements ResourceFactory {
* @param target The target which is starting to build.
* Must not be <code>null</code>.
*/
- protected void fireTargetStarted(Target target) {
- BuildEvent event = new BuildEvent(target);
- BuildListener[] currListeners = listeners;
+ protected void fireTargetStarted(final Target target) {
+ final BuildEvent event = new BuildEvent(target);
+ final BuildListener[] currListeners = listeners;
for (int i = 0; i < currListeners.length; i++) {
currListeners[i].targetStarted(event);
}
@@ -2153,10 +2174,10 @@ public class Project implements ResourceFactory {
* failure. May be <code>null</code>, indicating
* a successful build.
*/
- protected void fireTargetFinished(Target target, Throwable exception) {
- BuildEvent event = new BuildEvent(target);
+ protected void fireTargetFinished(final Target target, final Throwable exception) {
+ final BuildEvent event = new BuildEvent(target);
event.setException(exception);
- BuildListener[] currListeners = listeners;
+ final BuildListener[] currListeners = listeners;
for (int i = 0; i < currListeners.length; i++) {
currListeners[i].targetFinished(event);
}
@@ -2170,11 +2191,11 @@ public class Project implements ResourceFactory {
* @param task The target which is starting to execute.
* Must not be <code>null</code>.
*/
- protected void fireTaskStarted(Task task) {
+ protected void fireTaskStarted(final Task task) {
// register this as the current task on the current thread.
registerThreadTask(Thread.currentThread(), task);
- BuildEvent event = new BuildEvent(task);
- BuildListener[] currListeners = listeners;
+ final BuildEvent event = new BuildEvent(task);
+ final BuildListener[] currListeners = listeners;
for (int i = 0; i < currListeners.length; i++) {
currListeners[i].taskStarted(event);
}
@@ -2190,13 +2211,13 @@ public class Project implements ResourceFactory {
* failure. May be <code>null</code>, indicating
* a successful build.
*/
- protected void fireTaskFinished(Task task, Throwable exception) {
+ protected void fireTaskFinished(final Task task, final Throwable exception) {
registerThreadTask(Thread.currentThread(), null);
System.out.flush();
System.err.flush();
- BuildEvent event = new BuildEvent(task);
+ final BuildEvent event = new BuildEvent(task);
event.setException(exception);
- BuildListener[] currListeners = listeners;
+ final BuildListener[] currListeners = listeners;
for (int i = 0; i < currListeners.length; i++) {
currListeners[i].taskFinished(event);
}
@@ -2214,14 +2235,14 @@ public class Project implements ResourceFactory {
* @param message The message to send. Should not be <code>null</code>.
* @param priority The priority of the message.
*/
- private void fireMessageLoggedEvent(BuildEvent event, String message,
- int priority) {
+ private void fireMessageLoggedEvent(final BuildEvent event, String message,
+ final int priority) {
if (message == null) {
message = String.valueOf(message);
}
if (message.endsWith(StringUtils.LINE_SEP)) {
- int endIndex = message.length() - StringUtils.LINE_SEP.length();
+ final int endIndex = message.length() - StringUtils.LINE_SEP.length();
event.setMessage(message.substring(0, endIndex), priority);
} else {
event.setMessage(message, priority);
@@ -2244,7 +2265,7 @@ public class Project implements ResourceFactory {
}
try {
isLoggingMessage.set(Boolean.TRUE);
- BuildListener[] currListeners = listeners;
+ final BuildListener[] currListeners = listeners;
for (int i = 0; i < currListeners.length; i++) {
currListeners[i].messageLogged(event);
}
@@ -2262,8 +2283,8 @@ public class Project implements ResourceFactory {
* @param message The message to send. Should not be <code>null</code>.
* @param priority The priority of the message.
*/
- protected void fireMessageLogged(Project project, String message,
- int priority) {
+ protected void fireMessageLogged(final Project project, final String message,
+ final int priority) {
fireMessageLogged(project, message, null, priority);
}
@@ -2278,9 +2299,9 @@ public class Project implements ResourceFactory {
* @param priority The priority of the message.
* @since 1.7
*/
- protected void fireMessageLogged(Project project, String message,
- Throwable throwable, int priority) {
- BuildEvent event = new BuildEvent(project);
+ protected void fireMessageLogged(final Project project, final String message,
+ final Throwable throwable, final int priority) {
+ final BuildEvent event = new BuildEvent(project);
event.setException(throwable);
fireMessageLoggedEvent(event, message, priority);
}
@@ -2294,8 +2315,8 @@ public class Project implements ResourceFactory {
* @param message The message to send. Should not be <code>null</code>.
* @param priority The priority of the message.
*/
- protected void fireMessageLogged(Target target, String message,
- int priority) {
+ protected void fireMessageLogged(final Target target, final String message,
+ final int priority) {
fireMessageLogged(target, message, null, priority);
}
@@ -2310,9 +2331,9 @@ public class Project implements ResourceFactory {
* @param priority The priority of the message.
* @since 1.7
*/
- protected void fireMessageLogged(Target target, String message,
- Throwable throwable, int priority) {
- BuildEvent event = new BuildEvent(target);
+ protected void fireMessageLogged(final Target target, final String message,
+ final Throwable throwable, final int priority) {
+ final BuildEvent event = new BuildEvent(target);
event.setException(throwable);
fireMessageLoggedEvent(event, message, priority);
}
@@ -2326,7 +2347,7 @@ public class Project implements ResourceFactory {
* @param message The message to send. Should not be <code>null</code>.
* @param priority The priority of the message.
*/
- protected void fireMessageLogged(Task task, String message, int priority) {
+ protected void fireMessageLogged(final Task task, final String message, final int priority) {
fireMessageLogged(task, message, null, priority);
}
@@ -2341,9 +2362,9 @@ public class Project implements ResourceFactory {
* @param priority The priority of the message.
* @since 1.7
*/
- protected void fireMessageLogged(Task task, String message,
- Throwable throwable, int priority) {
- BuildEvent event = new BuildEvent(task);
+ protected void fireMessageLogged(final Task task, final String message,
+ final Throwable throwable, final int priority) {
+ final BuildEvent event = new BuildEvent(task);
event.setException(throwable);
fireMessageLoggedEvent(event, message, priority);
}
@@ -2356,8 +2377,8 @@ public class Project implements ResourceFactory {
* @param task the task to be registered.
* @since Ant 1.5
*/
- public void registerThreadTask(Thread thread, Task task) {
- synchronized(threadTasks) {
+ public void registerThreadTask(final Thread thread, final Task task) {
+ synchronized (threadTasks) {
if (task != null) {
threadTasks.put(thread, task);
threadGroupTasks.put(thread.getThreadGroup(), task);
@@ -2375,13 +2396,13 @@ public class Project implements ResourceFactory {
* @return the task which is currently registered for the given thread or
* null if no task is registered.
*/
- public Task getThreadTask(Thread thread) {
- synchronized(threadTasks) {
- Task task = (Task) threadTasks.get(thread);
+ public Task getThreadTask(final Thread thread) {
+ synchronized (threadTasks) {
+ Task task = threadTasks.get(thread);
if (task == null) {
ThreadGroup group = thread.getThreadGroup();
while (task == null && group != null) {
- task = (Task) threadGroupTasks.get(group);
+ task = threadGroupTasks.get(group);
group = group.getParent();
}
}
@@ -2406,7 +2427,7 @@ public class Project implements ResourceFactory {
* of UnknownElement (this is similar with the JDNI
* refs behavior).
*/
- private Object getReal(Object key) {
+ private Object getReal(final Object key) {
return super.get(key);
}
@@ -2421,11 +2442,12 @@ public class Project implements ResourceFactory {
* @param key lookup key.
* @return mapped value.
*/
- public Object get(Object key) {
+ @Override
+ public Object get(final Object key) {
Object o = getReal(key);
if (o instanceof UnknownElement) {
// Make sure that
- UnknownElement ue = (UnknownElement) o;
+ final UnknownElement ue = (UnknownElement) o;
ue.maybeConfigure();
o = ue.getRealThing();
}
@@ -2445,13 +2467,13 @@ public class Project implements ResourceFactory {
return;
}
try {
- Method method =
+ final Method method =
obj.getClass().getMethod(
"setProject", new Class[] {Project.class});
if (method != null) {
method.invoke(obj, new Object[] {this});
}
- } catch (Throwable e) {
+ } catch (final Throwable e) {
// ignore this if the object does not have
// a set project method or the method
// is private/protected.
@@ -2465,7 +2487,8 @@ public class Project implements ResourceFactory {
* @return the file resource.
* @since Ant 1.7
*/
- public Resource getResource(String name) {
+ @Override
+ public Resource getResource(final String name) {
return new FileResource(getBaseDir(), name);
}
}
http://git-wip-us.apache.org/repos/asf/ant/blob/1b76f1b6/src/main/org/apache/tools/ant/ProjectHelper.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/ProjectHelper.java b/src/main/org/apache/tools/ant/ProjectHelper.java
index a95c266..c6eaa07 100644
--- a/src/main/org/apache/tools/ant/ProjectHelper.java
+++ b/src/main/org/apache/tools/ant/ProjectHelper.java
@@ -101,7 +101,7 @@ public class ProjectHelper {
*
* @since 1.8.2
*/
- public final static class OnMissingExtensionPoint {
+ public static final class OnMissingExtensionPoint {
/** fail if the extension-point is not defined */
public static final OnMissingExtensionPoint FAIL = new OnMissingExtensionPoint(
@@ -181,7 +181,7 @@ public class ProjectHelper {
return extensionStack;
}
- private final static ThreadLocal<String> targetPrefix = new ThreadLocal<String>();
+ private static final ThreadLocal<String> targetPrefix = new ThreadLocal<String>();
/**
* The prefix to prepend to imported target names.
@@ -205,7 +205,7 @@ public class ProjectHelper {
targetPrefix.set(prefix);
}
- private final static ThreadLocal<String> prefixSeparator = new ThreadLocal<String>() {
+ private static final ThreadLocal<String> prefixSeparator = new ThreadLocal<String>() {
protected String initialValue() {
return ".";
}
@@ -231,7 +231,7 @@ public class ProjectHelper {
prefixSeparator.set(sep);
}
- private final static ThreadLocal<Boolean> inIncludeMode = new ThreadLocal<Boolean>() {
+ private static final ThreadLocal<Boolean> inIncludeMode = new ThreadLocal<Boolean>() {
protected Boolean initialValue() {
return Boolean.FALSE;
}
http://git-wip-us.apache.org/repos/asf/ant/blob/1b76f1b6/src/main/org/apache/tools/ant/filters/ConcatFilter.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/filters/ConcatFilter.java b/src/main/org/apache/tools/ant/filters/ConcatFilter.java
index 391a1ef..a28edbf 100644
--- a/src/main/org/apache/tools/ant/filters/ConcatFilter.java
+++ b/src/main/org/apache/tools/ant/filters/ConcatFilter.java
@@ -36,7 +36,7 @@ import org.apache.tools.ant.types.Parameter;
* </filterchain>
* </copy>
* </pre>
- *
+ *
* <p>Copies all java sources from <i>src</i> to <i>build</i> and adds the
* content of <i>apache-license-java.txt</i> add the beginning of each
* file.</p>
@@ -90,7 +90,8 @@ public final class ConcatFilter extends BaseParamFilterReader
* @exception IOException if the underlying stream throws an IOException
* during reading
*/
- public int read() throws IOException {
+ @Override
+ public int read() throws IOException {
// do the "singleton" initialization
if (!getInitialized()) {
initialize();
@@ -170,7 +171,8 @@ public final class ConcatFilter extends BaseParamFilterReader
* @return a new filter based on this configuration, but filtering
* the specified reader
*/
- public Reader chain(final Reader rdr) {
+ @Override
+ public Reader chain(final Reader rdr) {
ConcatFilter newFilter = new ConcatFilter(rdr);
newFilter.setPrepend(getPrepend());
newFilter.setAppend(getAppend());
http://git-wip-us.apache.org/repos/asf/ant/blob/1b76f1b6/src/main/org/apache/tools/ant/launch/Launcher.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/launch/Launcher.java b/src/main/org/apache/tools/ant/launch/Launcher.java
index ab05903..228f6f6 100644
--- a/src/main/org/apache/tools/ant/launch/Launcher.java
+++ b/src/main/org/apache/tools/ant/launch/Launcher.java
@@ -105,15 +105,15 @@ public class Launcher {
*
* @param args commandline arguments
*/
- public static void main(String[] args) {
+ public static void main(final String[] args) {
int exitCode;
try {
- Launcher launcher = new Launcher();
+ final Launcher launcher = new Launcher();
exitCode = launcher.run(args);
- } catch (LaunchException e) {
+ } catch (final LaunchException e) {
exitCode = EXIT_CODE_ERROR;
System.err.println(e.getMessage());
- } catch (Throwable t) {
+ } catch (final Throwable t) {
exitCode = EXIT_CODE_ERROR;
t.printStackTrace(System.err);
}
@@ -136,26 +136,28 @@ public class Launcher {
* @param libPathURLs the list of paths to add to
* @throws MalformedURLException if we can't create a URL
*/
- private void addPath(String path, boolean getJars, List<URL> libPathURLs)
+ private void addPath(final String path, final boolean getJars, final List<URL> libPathURLs)
throws MalformedURLException {
- StringTokenizer tokenizer = new StringTokenizer(path, File.pathSeparator);
+ final StringTokenizer tokenizer = new StringTokenizer(path, File.pathSeparator);
while (tokenizer.hasMoreElements()) {
- String elementName = tokenizer.nextToken();
- File element = new File(elementName);
+ final String elementName = tokenizer.nextToken();
+ final File element = new File(elementName);
if (elementName.indexOf('%') != -1 && !element.exists()) {
continue;
}
if (getJars && element.isDirectory()) {
// add any jars in the directory
- URL[] dirURLs = Locator.getLocationURLs(element);
+ final URL[] dirURLs = Locator.getLocationURLs(element);
for (int j = 0; j < dirURLs.length; ++j) {
if (launchDiag) { System.out.println("adding library JAR: " + dirURLs[j]);}
libPathURLs.add(dirURLs[j]);
}
}
- URL url = Locator.fileToURL(element);
- if (launchDiag) { System.out.println("adding library URL: " + url) ;}
+ final URL url = Locator.fileToURL(element);
+ if (launchDiag) {
+ System.out.println("adding library URL: " + url);
+ }
libPathURLs.add(url);
}
}
@@ -170,13 +172,13 @@ public class Launcher {
* cannot be created.
* @throws LaunchException for launching problems
*/
- private int run(String[] args)
+ private int run(final String[] args)
throws LaunchException, MalformedURLException {
- String antHomeProperty = System.getProperty(ANTHOME_PROPERTY);
+ final String antHomeProperty = System.getProperty(ANTHOME_PROPERTY);
File antHome = null;
- File sourceJar = Locator.getClassSource(getClass());
- File jarDir = sourceJar.getParentFile();
+ final File sourceJar = Locator.getClassSource(getClass());
+ final File jarDir = sourceJar.getParentFile();
String mainClassname = MAIN_CLASS;
if (antHomeProperty != null) {
@@ -193,9 +195,9 @@ public class Launcher {
+ "ant could not be located (estimated value="+antHome.getAbsolutePath()+")");
}
- List<String> libPaths = new ArrayList<String>();
+ final List<String> libPaths = new ArrayList<String>();
String cpString = null;
- List<String> argList = new ArrayList<String>();
+ final List<String> argList = new ArrayList<String>();
String[] newArgs;
boolean noUserLib = false;
boolean noClassPath = false;
@@ -244,21 +246,21 @@ public class Launcher {
if (argList.size() == args.length) {
newArgs = args;
} else {
- newArgs = (String[]) argList.toArray(new String[argList.size()]);
+ newArgs = argList.toArray(new String[argList.size()]);
}
- URL[] libURLs = getLibPathURLs(
+ final URL[] libURLs = getLibPathURLs(
noClassPath ? null : cpString, libPaths);
- URL[] systemURLs = getSystemURLs(jarDir);
- URL[] userURLs = noUserLib ? new URL[0] : getUserURLs();
+ final URL[] systemURLs = getSystemURLs(jarDir);
+ final URL[] userURLs = noUserLib ? new URL[0] : getUserURLs();
- File toolsJAR = Locator.getToolsJar();
+ final File toolsJAR = Locator.getToolsJar();
logPath("tools.jar",toolsJAR);
- URL[] jars = getJarArray(
+ final URL[] jars = getJarArray(
libURLs, userURLs, systemURLs, toolsJAR);
// now update the class.path property
- StringBuffer baseClassPath
+ final StringBuffer baseClassPath
= new StringBuffer(System.getProperty(JAVA_CLASS_PATH));
if (baseClassPath.charAt(baseClassPath.length() - 1)
== File.pathSeparatorChar) {
@@ -272,27 +274,27 @@ public class Launcher {
setProperty(JAVA_CLASS_PATH, baseClassPath.toString());
- URLClassLoader loader = new URLClassLoader(jars, Launcher.class.getClassLoader());
+ final URLClassLoader loader = new URLClassLoader(jars, Launcher.class.getClassLoader());
Thread.currentThread().setContextClassLoader(loader);
Class<?> mainClass = null;
int exitCode = 0;
Throwable thrown=null;
try {
mainClass = loader.loadClass(mainClassname);
- AntMain main = (AntMain) mainClass.newInstance();
+ final AntMain main = (AntMain) mainClass.newInstance();
main.startAnt(newArgs, null, null);
- } catch (InstantiationException ex) {
+ } catch (final InstantiationException ex) {
System.err.println(
"Incompatible version of " + mainClassname + " detected");
- File mainJar = Locator.getClassSource(mainClass);
+ final File mainJar = Locator.getClassSource(mainClass);
System.err.println(
"Location of this class " + mainJar);
thrown = ex;
- } catch (ClassNotFoundException cnfe) {
+ } catch (final ClassNotFoundException cnfe) {
System.err.println(
"Failed to locate" + mainClassname);
thrown = cnfe;
- } catch (Throwable t) {
+ } catch (final Throwable t) {
t.printStackTrace(System.err);
thrown=t;
}
@@ -314,15 +316,15 @@ public class Launcher {
* @return an array of URLs.
* @throws MalformedURLException if the URLs cannot be created.
*/
- private URL[] getLibPathURLs(String cpString, List<String> libPaths)
+ private URL[] getLibPathURLs(final String cpString, final List<String> libPaths)
throws MalformedURLException {
- List<URL> libPathURLs = new ArrayList<URL>();
+ final List<URL> libPathURLs = new ArrayList<URL>();
if (cpString != null) {
addPath(cpString, false, libPathURLs);
}
- for (String libPath : libPaths) {
+ for (final String libPath : libPaths) {
addPath(libPath, true, libPathURLs);
}
@@ -337,9 +339,9 @@ public class Launcher {
* @return the URLs
* @throws MalformedURLException if the URLs cannot be created.
*/
- private URL[] getSystemURLs(File antLauncherDir) throws MalformedURLException {
+ private URL[] getSystemURLs(final File antLauncherDir) throws MalformedURLException {
File antLibDir = null;
- String antLibDirProperty = System.getProperty(ANTLIBDIR_PROPERTY);
+ final String antLibDirProperty = System.getProperty(ANTLIBDIR_PROPERTY);
if (antLibDirProperty != null) {
antLibDir = new File(antLibDirProperty);
}
@@ -356,7 +358,7 @@ public class Launcher {
* @throws MalformedURLException if the URLs cannot be created.
*/
private URL[] getUserURLs() throws MalformedURLException {
- File userLibDir
+ final File userLibDir
= new File(System.getProperty(USER_HOMEDIR), USER_LIBDIR);
return Locator.getLocationURLs(userLibDir);
@@ -372,13 +374,13 @@ public class Launcher {
* @throws MalformedURLException if there is a problem.
*/
private URL[] getJarArray (
- URL[] libJars, URL[] userJars, URL[] systemJars, File toolsJar)
+ final URL[] libJars, final URL[] userJars, final URL[] systemJars, final File toolsJar)
throws MalformedURLException {
int numJars = libJars.length + userJars.length + systemJars.length;
if (toolsJar != null) {
numJars++;
}
- URL[] jars = new URL[numJars];
+ final URL[] jars = new URL[numJars];
System.arraycopy(libJars, 0, jars, 0, libJars.length);
System.arraycopy(userJars, 0, jars, libJars.length, userJars.length);
System.arraycopy(systemJars, 0, jars, userJars.length + libJars.length,
@@ -395,14 +397,14 @@ public class Launcher {
* @param name property name
* @param value value
*/
- private void setProperty(String name, String value) {
+ private void setProperty(final String name, final String value) {
if (launchDiag) {
System.out.println("Setting \"" + name + "\" to \"" + value + "\"");
}
System.setProperty(name, value);
}
- private void logPath(String name,File path) {
+ private void logPath(final String name,final File path) {
if(launchDiag) {
System.out.println(name+"= \""+path+"\"");
}
http://git-wip-us.apache.org/repos/asf/ant/blob/1b76f1b6/src/main/org/apache/tools/ant/launch/Locator.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/launch/Locator.java b/src/main/org/apache/tools/ant/launch/Locator.java
index 5847f5c..035b8b2 100644
--- a/src/main/org/apache/tools/ant/launch/Locator.java
+++ b/src/main/org/apache/tools/ant/launch/Locator.java
@@ -27,8 +27,6 @@ import java.text.CharacterIterator;
import java.text.StringCharacterIterator;
import java.util.Locale;
-import org.apache.tools.ant.util.FileUtils;
-
// CheckStyle:LineLengthCheck OFF - urls are long!
/**
* The Locator is a utility class which is used to find certain items
http://git-wip-us.apache.org/repos/asf/ant/blob/1b76f1b6/src/main/org/apache/tools/ant/listener/AnsiColorLogger.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/listener/AnsiColorLogger.java b/src/main/org/apache/tools/ant/listener/AnsiColorLogger.java
index 08c1ebd..9683c41 100644
--- a/src/main/org/apache/tools/ant/listener/AnsiColorLogger.java
+++ b/src/main/org/apache/tools/ant/listener/AnsiColorLogger.java
@@ -78,7 +78,7 @@ import org.apache.tools.ant.Project;
* 7 -> Reverse
* 8 -> Hidden
* </pre>
- *
+ *
* Foreground is one of the following:<pre>
* 30 -> Black
* 31 -> Red
@@ -207,7 +207,8 @@ public class AnsiColorLogger extends DefaultLogger {
* @see DefaultLogger#printMessage
*/
/** {@inheritDoc}. */
- protected void printMessage(final String message,
+ @Override
+ protected void printMessage(final String message,
final PrintStream stream,
final int priority) {
if (message != null && stream != null) {
http://git-wip-us.apache.org/repos/asf/ant/blob/1b76f1b6/src/main/org/apache/tools/ant/listener/SilentLogger.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/listener/SilentLogger.java b/src/main/org/apache/tools/ant/listener/SilentLogger.java
index 49da6e6..7b63b87 100644
--- a/src/main/org/apache/tools/ant/listener/SilentLogger.java
+++ b/src/main/org/apache/tools/ant/listener/SilentLogger.java
@@ -22,34 +22,40 @@ import org.apache.tools.ant.DefaultLogger;
/**
* A logger which logs nothing but build failure and what task might output
- *
+ *
* @since 1.9.0
*/
public class SilentLogger extends DefaultLogger {
- public void buildStarted(BuildEvent event) {
+ @Override
+ public void buildStarted(BuildEvent event) {
// log nothing
}
- public void buildFinished(BuildEvent event) {
+ @Override
+ public void buildFinished(BuildEvent event) {
if (event.getException() != null) {
super.buildFinished(event);
}
}
- public void targetStarted(BuildEvent event) {
+ @Override
+ public void targetStarted(BuildEvent event) {
// log nothing
}
- public void targetFinished(BuildEvent event) {
+ @Override
+ public void targetFinished(BuildEvent event) {
// log nothing
}
- public void taskStarted(BuildEvent event) {
+ @Override
+ public void taskStarted(BuildEvent event) {
// log nothing
}
- public void taskFinished(BuildEvent event) {
+ @Override
+ public void taskFinished(BuildEvent event) {
// log nothing
}