@@ -356,11 +356,9 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener, Clo | |||
public void setClassPath(final Path classpath) { | |||
pathComponents.removeAllElements(); | |||
if (classpath != null) { | |||
final Path actualClasspath = classpath.concatSystemClasspath("ignore"); | |||
final String[] pathElements = actualClasspath.list(); | |||
for (int i = 0; i < pathElements.length; ++i) { | |||
for (String pathElement : classpath.concatSystemClasspath("ignore").list()) { | |||
try { | |||
addPathElement(pathElements[i]); | |||
addPathElement(pathElement); | |||
} catch (final BuildException e) { | |||
// ignore path elements which are invalid | |||
// relative to the project | |||
@@ -422,8 +422,7 @@ public final class Diagnostics { | |||
*/ | |||
private static void doReportAntHomeLibraries(PrintStream out) { | |||
out.println(MagicNames.ANT_HOME + ": " + System.getProperty(MagicNames.ANT_HOME)); | |||
File[] libs = listLibraries(); | |||
printLibraries(libs, out); | |||
printLibraries(listLibraries(), out); | |||
} | |||
/** | |||
@@ -435,8 +434,7 @@ public final class Diagnostics { | |||
String home = System.getProperty(Launcher.USER_HOMEDIR); | |||
out.println("user.home: " + home); | |||
File libDir = new File(home, Launcher.USER_LIBDIR); | |||
File[] libs = listJarFiles(libDir); | |||
printLibraries(libs, out); | |||
printLibraries(listJarFiles(libDir), out); | |||
} | |||
/** | |||
@@ -449,8 +447,8 @@ public final class Diagnostics { | |||
out.println("No such directory."); | |||
return; | |||
} | |||
for (int i = 0; i < libs.length; i++) { | |||
out.println(libs[i].getName() + " (" + libs[i].length() + " bytes)"); | |||
for (File lib : libs) { | |||
out.println(lib.getName() + " (" + lib.length() + " bytes)"); | |||
} | |||
} | |||
@@ -1215,7 +1215,7 @@ public class DirectoryScanner | |||
} | |||
private void scandir(final File dir, final TokenizedPath path, final boolean fast, | |||
String[] newfiles, final LinkedList<String> directoryNamesFollowed) { | |||
String[] newFiles, final LinkedList<String> directoryNamesFollowed) { | |||
String vpath = path.toString(); | |||
if (vpath.length() > 0 && !vpath.endsWith(File.separator)) { | |||
vpath += File.separator; | |||
@@ -1227,11 +1227,11 @@ public class DirectoryScanner | |||
} | |||
if (!followSymlinks) { | |||
final ArrayList<String> noLinks = new ArrayList<String>(); | |||
for (int i = 0; i < newfiles.length; i++) { | |||
for (final String newFile : newFiles) { | |||
try { | |||
if (SYMLINK_UTILS.isSymbolicLink(dir, newfiles[i])) { | |||
final String name = vpath + newfiles[i]; | |||
final File file = new File(dir, newfiles[i]); | |||
if (SYMLINK_UTILS.isSymbolicLink(dir, newFile)) { | |||
final String name = vpath + newFile; | |||
final File file = new File(dir, newFile); | |||
if (file.isDirectory()) { | |||
dirsExcluded.addElement(name); | |||
} else if (file.isFile()) { | |||
@@ -1239,25 +1239,25 @@ public class DirectoryScanner | |||
} | |||
accountForNotFollowedSymlink(name, file); | |||
} else { | |||
noLinks.add(newfiles[i]); | |||
noLinks.add(newFile); | |||
} | |||
} catch (final IOException ioe) { | |||
final String msg = "IOException caught while checking " | |||
+ "for links, couldn't get canonical path!"; | |||
// will be caught and redirected to Ant's logging system | |||
System.err.println(msg); | |||
noLinks.add(newfiles[i]); | |||
noLinks.add(newFile); | |||
} | |||
} | |||
newfiles = (noLinks.toArray(new String[noLinks.size()])); | |||
newFiles = (noLinks.toArray(new String[noLinks.size()])); | |||
} else { | |||
directoryNamesFollowed.addFirst(dir.getName()); | |||
} | |||
for (int i = 0; i < newfiles.length; i++) { | |||
final String name = vpath + newfiles[i]; | |||
final TokenizedPath newPath = new TokenizedPath(path, newfiles[i]); | |||
final File file = new File(dir, newfiles[i]); | |||
for (String newFile : newFiles) { | |||
final String name = vpath + newFile; | |||
final TokenizedPath newPath = new TokenizedPath(path, newFile); | |||
final File file = new File(dir, newFile); | |||
final String[] children = file.list(); | |||
if (children == null || (children.length == 0 && file.isFile())) { | |||
if (isIncluded(newPath)) { | |||
@@ -1269,8 +1269,7 @@ public class DirectoryScanner | |||
} else if (file.isDirectory()) { // dir | |||
if (followSymlinks | |||
&& causesIllegalSymlinkLoop(newfiles[i], dir, | |||
directoryNamesFollowed)) { | |||
&& causesIllegalSymlinkLoop(newFile, dir, directoryNamesFollowed)) { | |||
// will be caught and redirected to Ant's logging system | |||
System.err.println("skipping symbolic link " | |||
+ file.getAbsolutePath() | |||
@@ -179,10 +179,8 @@ public final class IntrospectionHelper { | |||
*/ | |||
private IntrospectionHelper(final Class<?> bean) { | |||
this.bean = bean; | |||
final Method[] methods = bean.getMethods(); | |||
Method addTextMethod = null; | |||
for (int i = 0; i < methods.length; i++) { | |||
final Method m = methods[i]; | |||
for (final Method m : bean.getMethods()) { | |||
final String name = m.getName(); | |||
final Class<?> returnType = m.getReturnType(); | |||
final Class<?>[] args = m.getParameterTypes(); | |||
@@ -205,7 +203,7 @@ public final class IntrospectionHelper { | |||
} | |||
if ("addText".equals(name) && Void.TYPE.equals(returnType) | |||
&& args.length == 1 && String.class.equals(args[0])) { | |||
addTextMethod = methods[i]; | |||
addTextMethod = m; | |||
} else if (name.startsWith("set") && Void.TYPE.equals(returnType) | |||
&& args.length == 1 && !args[0].isArray()) { | |||
final String propName = getPropertyName(name, "set"); | |||
@@ -1631,9 +1629,7 @@ public final class IntrospectionHelper { | |||
Class<?> matchedClass = null; | |||
Method matchedMethod = null; | |||
final int size = methods.size(); | |||
for (int i = 0; i < size; ++i) { | |||
final Method method = methods.get(i); | |||
for (final Method method : methods) { | |||
final Class<?> methodClass = method.getParameterTypes()[0]; | |||
if (methodClass.isAssignableFrom(paramClass)) { | |||
if (matchedClass == null) { | |||
@@ -1679,9 +1675,7 @@ public final class IntrospectionHelper { | |||
return null; | |||
} | |||
synchronized (definitions) { | |||
final int size = definitions.size(); | |||
for (int i = 0; i < size; ++i) { | |||
final AntTypeDefinition d = definitions.get(i); | |||
for (final AntTypeDefinition d : definitions) { | |||
final Class<?> exposedClass = d.getExposedClass(helper.getProject()); | |||
if (exposedClass == null) { | |||
continue; | |||
@@ -393,8 +393,8 @@ public class Project implements ResourceFactory { | |||
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++) { | |||
if (listeners[i] == listener) { | |||
for (BuildListener buildListener : listeners) { | |||
if (buildListener == listener) { | |||
return; | |||
} | |||
} | |||
@@ -439,8 +439,8 @@ public class Project implements ResourceFactory { | |||
public Vector<BuildListener> getBuildListeners() { | |||
synchronized (listenersLock) { | |||
final Vector<BuildListener> r = new Vector<BuildListener>(listeners.length); | |||
for (int i = 0; i < listeners.length; i++) { | |||
r.add(listeners[i]); | |||
for (BuildListener listener : listeners) { | |||
r.add(listener); | |||
} | |||
return r; | |||
} | |||
@@ -1832,13 +1832,13 @@ public class Project implements ResourceFactory { | |||
// dependency tree, not just on the Targets that depend on the | |||
// build Target. | |||
for (int i = 0; i < roots.length; i++) { | |||
final String st = (state.get(roots[i])); | |||
for (String root : roots) { | |||
final String st = state.get(root); | |||
if (st == null) { | |||
tsort(roots[i], targetTable, state, visiting, ret); | |||
tsort(root, targetTable, state, visiting, ret); | |||
} else if (st == VISITING) { | |||
throw new BuildException("Unexpected node in visiting state: " | |||
+ roots[i]); | |||
+ root); | |||
} | |||
} | |||
final StringBuffer buf = new StringBuffer("Build sequence for target(s)"); | |||
@@ -2093,9 +2093,8 @@ public class Project implements ResourceFactory { | |||
*/ | |||
public void fireBuildStarted() { | |||
final BuildEvent event = new BuildEvent(this); | |||
final BuildListener[] currListeners = listeners; | |||
for (int i = 0; i < currListeners.length; i++) { | |||
currListeners[i].buildStarted(event); | |||
for (BuildListener currListener : listeners) { | |||
currListener.buildStarted(event); | |||
} | |||
} | |||
@@ -2109,9 +2108,8 @@ public class Project implements ResourceFactory { | |||
public void fireBuildFinished(final Throwable exception) { | |||
final BuildEvent event = new BuildEvent(this); | |||
event.setException(exception); | |||
final BuildListener[] currListeners = listeners; | |||
for (int i = 0; i < currListeners.length; i++) { | |||
currListeners[i].buildFinished(event); | |||
for (BuildListener currListener : listeners) { | |||
currListener.buildFinished(event); | |||
} | |||
// Inform IH to clear the cache | |||
IntrospectionHelper.clearCache(); | |||
@@ -2125,10 +2123,9 @@ public class Project implements ResourceFactory { | |||
*/ | |||
public void fireSubBuildStarted() { | |||
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); | |||
for (BuildListener currListener : listeners) { | |||
if (currListener instanceof SubBuildListener) { | |||
((SubBuildListener) currListener).subBuildStarted(event); | |||
} | |||
} | |||
} | |||
@@ -2145,10 +2142,9 @@ public class Project implements ResourceFactory { | |||
public void fireSubBuildFinished(final Throwable exception) { | |||
final BuildEvent event = new BuildEvent(this); | |||
event.setException(exception); | |||
final BuildListener[] currListeners = listeners; | |||
for (int i = 0; i < currListeners.length; i++) { | |||
if (currListeners[i] instanceof SubBuildListener) { | |||
((SubBuildListener) currListeners[i]).subBuildFinished(event); | |||
for (BuildListener currListener : listeners) { | |||
if (currListener instanceof SubBuildListener) { | |||
((SubBuildListener) currListener).subBuildFinished(event); | |||
} | |||
} | |||
} | |||
@@ -2162,9 +2158,8 @@ public class Project implements ResourceFactory { | |||
*/ | |||
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); | |||
for (BuildListener currListener : listeners) { | |||
currListener.targetStarted(event); | |||
} | |||
} | |||
@@ -2182,9 +2177,8 @@ public class Project implements ResourceFactory { | |||
protected void fireTargetFinished(final Target target, final Throwable exception) { | |||
final BuildEvent event = new BuildEvent(target); | |||
event.setException(exception); | |||
final BuildListener[] currListeners = listeners; | |||
for (int i = 0; i < currListeners.length; i++) { | |||
currListeners[i].targetFinished(event); | |||
for (BuildListener currListener : listeners) { | |||
currListener.targetFinished(event); | |||
} | |||
} | |||
@@ -2200,9 +2194,8 @@ public class Project implements ResourceFactory { | |||
// register this as the current task on the current thread. | |||
registerThreadTask(Thread.currentThread(), task); | |||
final BuildEvent event = new BuildEvent(task); | |||
final BuildListener[] currListeners = listeners; | |||
for (int i = 0; i < currListeners.length; i++) { | |||
currListeners[i].taskStarted(event); | |||
for (BuildListener currListener : listeners) { | |||
currListener.taskStarted(event); | |||
} | |||
} | |||
@@ -2222,9 +2215,8 @@ public class Project implements ResourceFactory { | |||
System.err.flush(); | |||
final BuildEvent event = new BuildEvent(task); | |||
event.setException(exception); | |||
final BuildListener[] currListeners = listeners; | |||
for (int i = 0; i < currListeners.length; i++) { | |||
currListeners[i].taskFinished(event); | |||
for (BuildListener currListener : listeners) { | |||
currListener.taskFinished(event); | |||
} | |||
} | |||
@@ -2270,9 +2262,8 @@ public class Project implements ResourceFactory { | |||
} | |||
try { | |||
isLoggingMessage.set(Boolean.TRUE); | |||
final BuildListener[] currListeners = listeners; | |||
for (int i = 0; i < currListeners.length; i++) { | |||
currListeners[i].messageLogged(event); | |||
for (BuildListener currListener : listeners) { | |||
currListener.messageLogged(event); | |||
} | |||
} finally { | |||
isLoggingMessage.set(Boolean.FALSE); | |||
@@ -2472,11 +2463,9 @@ public class Project implements ResourceFactory { | |||
return; | |||
} | |||
try { | |||
final Method method = | |||
obj.getClass().getMethod( | |||
"setProject", new Class[] {Project.class}); | |||
final Method method = obj.getClass().getMethod("setProject", Project.class); | |||
if (method != null) { | |||
method.invoke(obj, new Object[] {this}); | |||
method.invoke(obj, this); | |||
} | |||
} catch (final Throwable e) { | |||
// ignore this if the object does not have | |||
@@ -136,9 +136,9 @@ public class ProjectHelper { | |||
if (name == null) { | |||
throw new NullPointerException(); | |||
} | |||
for (int i = 0; i < values.length; i++) { | |||
if (name.equals(values[i].name())) { | |||
return values[i]; | |||
for (OnMissingExtensionPoint value : values) { | |||
if (name.equals(value.name())) { | |||
return value; | |||
} | |||
} | |||
throw new IllegalArgumentException( | |||
@@ -1144,11 +1144,11 @@ public class PropertyHelper implements GetProperty { | |||
final HashSet<Class<? extends Delegate>> result = new HashSet<Class<? extends Delegate>>(); | |||
Class<?> c = d.getClass(); | |||
while (c != null) { | |||
Class<?>[] ifs = c.getInterfaces(); | |||
for (int i = 0; i < ifs.length; i++) { | |||
if (Delegate.class.isAssignableFrom(ifs[i])) { | |||
for (Class<?> ifc : c.getInterfaces()) { | |||
if (Delegate.class.isAssignableFrom(ifc)) { | |||
@SuppressWarnings("unchecked") | |||
final Class<? extends Delegate> delegateInterface = (Class<? extends Delegate>) ifs[i]; | |||
final Class<? extends Delegate> delegateInterface = | |||
(Class<? extends Delegate>) ifc; | |||
result.add(delegateInterface); | |||
} | |||
} | |||
@@ -19,7 +19,6 @@ | |||
package org.apache.tools.ant.attribute; | |||
import java.util.HashMap; | |||
import java.util.Iterator; | |||
import java.util.Map; | |||
import org.apache.tools.ant.ProjectComponent; | |||
@@ -70,10 +69,9 @@ public abstract class BaseIfAttribute | |||
protected Map getParams(UnknownElement el) { | |||
Map ret = new HashMap(); | |||
RuntimeConfigurable rc = el.getWrapper(); | |||
Map attributes = rc.getAttributeMap(); // This does a copy! | |||
for (Iterator i = attributes.entrySet().iterator(); i.hasNext();) { | |||
Map.Entry entry = (Map.Entry) i.next(); | |||
String key = (String) entry.getKey(); | |||
Map<String, Object> attributes = rc.getAttributeMap(); // This does a copy! | |||
for (Map.Entry<String, Object> entry : attributes.entrySet()) { | |||
String key = entry.getKey(); | |||
String value = (String) entry.getValue(); | |||
if (key.startsWith("ant-attribute:param")) { | |||
int pos = key.lastIndexOf(':'); | |||
@@ -191,13 +191,13 @@ public final class ConcatFilter extends BaseParamFilterReader | |||
// get parameters | |||
final Parameter[] params = getParameters(); | |||
if (params != null) { | |||
for (int i = 0; i < params.length; i++) { | |||
if ("prepend".equals(params[i].getName())) { | |||
setPrepend(new File(params[i].getValue())); | |||
for (Parameter param : params) { | |||
if ("prepend".equals(param.getName())) { | |||
setPrepend(new File(param.getValue())); | |||
continue; | |||
} | |||
if ("append".equals(params[i].getName())) { | |||
setAppend(new File(params[i].getValue())); | |||
if ("append".equals(param.getName())) { | |||
setAppend(new File(param.getValue())); | |||
continue; | |||
} | |||
} | |||
@@ -187,13 +187,13 @@ public final class HeadFilter extends BaseParamFilterReader | |||
private void initialize() { | |||
Parameter[] params = getParameters(); | |||
if (params != null) { | |||
for (int i = 0; i < params.length; i++) { | |||
if (LINES_KEY.equals(params[i].getName())) { | |||
lines = Long.parseLong(params[i].getValue()); | |||
for (Parameter param : params) { | |||
if (LINES_KEY.equals(param.getName())) { | |||
lines = Long.parseLong(param.getValue()); | |||
continue; | |||
} | |||
if (SKIP_KEY.equals(params[i].getName())) { | |||
skip = Long.parseLong(params[i].getValue()); | |||
if (SKIP_KEY.equals(param.getName())) { | |||
skip = Long.parseLong(param.getValue()); | |||
continue; | |||
} | |||
} | |||
@@ -204,11 +204,11 @@ public final class LineContains | |||
private void initialize() { | |||
Parameter[] params = getParameters(); | |||
if (params != null) { | |||
for (int i = 0; i < params.length; i++) { | |||
if (CONTAINS_KEY.equals(params[i].getType())) { | |||
contains.addElement(params[i].getValue()); | |||
} else if (NEGATE_KEY.equals(params[i].getType())) { | |||
setNegate(Project.toBoolean(params[i].getValue())); | |||
for (Parameter param : params) { | |||
if (CONTAINS_KEY.equals(param.getType())) { | |||
contains.addElement(param.getValue()); | |||
} else if (NEGATE_KEY.equals(param.getType())) { | |||
setNegate(Project.toBoolean(param.getValue())); | |||
} | |||
} | |||
} | |||
@@ -237,13 +237,13 @@ public final class LineContainsRegExp | |||
private void initialize() { | |||
Parameter[] params = getParameters(); | |||
if (params != null) { | |||
for (int i = 0; i < params.length; i++) { | |||
if (REGEXP_KEY.equals(params[i].getType())) { | |||
setRegexp(params[i].getValue()); | |||
} else if (NEGATE_KEY.equals(params[i].getType())) { | |||
setNegate(Project.toBoolean(params[i].getValue())); | |||
} else if (CS_KEY.equals(params[i].getType())) { | |||
setCaseSensitive(Project.toBoolean(params[i].getValue())); | |||
for (Parameter param : params) { | |||
if (REGEXP_KEY.equals(param.getType())) { | |||
setRegexp(param.getValue()); | |||
} else if (NEGATE_KEY.equals(param.getType())) { | |||
setNegate(Project.toBoolean(param.getValue())); | |||
} else if (CS_KEY.equals(param.getType())) { | |||
setCaseSensitive(Project.toBoolean(param.getValue())); | |||
} | |||
} | |||
} | |||
@@ -153,9 +153,9 @@ public final class PrefixLines | |||
private void initialize() { | |||
Parameter[] params = getParameters(); | |||
if (params != null) { | |||
for (int i = 0; i < params.length; i++) { | |||
if (PREFIX_KEY.equals(params[i].getName())) { | |||
prefix = params[i].getValue(); | |||
for (Parameter param : params) { | |||
if (PREFIX_KEY.equals(param.getName())) { | |||
prefix = param.getValue(); | |||
break; | |||
} | |||
} | |||
@@ -314,19 +314,18 @@ public final class SortFilter extends BaseParamFilterReader | |||
// get parameters | |||
Parameter[] params = getParameters(); | |||
if (params != null) { | |||
for (int i = 0; i < params.length; i++) { | |||
final String paramName = params[i].getName(); | |||
for (Parameter param : params) { | |||
final String paramName = param.getName(); | |||
if (REVERSE_KEY.equals(paramName)) { | |||
setReverse(Boolean.valueOf(params[i].getValue()) | |||
.booleanValue()); | |||
setReverse(Boolean.valueOf(param.getValue()).booleanValue()); | |||
continue; | |||
} | |||
if (COMPARATOR_KEY.equals(paramName)) { | |||
try { | |||
String className = (String) params[i].getValue(); | |||
String className = (String) param.getValue(); | |||
@SuppressWarnings("unchecked") | |||
final Comparator<? super String> comparatorInstance = (Comparator<? super String>) (Class | |||
.forName(className).newInstance()); | |||
final Comparator<? super String> comparatorInstance | |||
= (Comparator<? super String>) (Class.forName(className).newInstance()); | |||
setComparator(comparatorInstance); | |||
continue; | |||
} catch (InstantiationException e) { | |||
@@ -140,9 +140,9 @@ public final class StripLineBreaks | |||
String userDefinedLineBreaks = null; | |||
Parameter[] params = getParameters(); | |||
if (params != null) { | |||
for (int i = 0; i < params.length; i++) { | |||
if (LINE_BREAKS_KEY.equals(params[i].getName())) { | |||
userDefinedLineBreaks = params[i].getValue(); | |||
for (Parameter param : params) { | |||
if (LINE_BREAKS_KEY.equals(param.getName())) { | |||
userDefinedLineBreaks = param.getValue(); | |||
break; | |||
} | |||
} | |||
@@ -186,9 +186,9 @@ public final class StripLineComments | |||
private void initialize() { | |||
Parameter[] params = getParameters(); | |||
if (params != null) { | |||
for (int i = 0; i < params.length; i++) { | |||
if (COMMENTS_KEY.equals(params[i].getType())) { | |||
comments.addElement(params[i].getValue()); | |||
for (Parameter param : params) { | |||
if (COMMENTS_KEY.equals(param.getType())) { | |||
comments.addElement(param.getValue()); | |||
} | |||
} | |||
} | |||
@@ -163,9 +163,9 @@ public final class SuffixLines | |||
private void initialize() { | |||
Parameter[] params = getParameters(); | |||
if (params != null) { | |||
for (int i = 0; i < params.length; i++) { | |||
if (SUFFIX_KEY.equals(params[i].getName())) { | |||
suffix = params[i].getValue(); | |||
for (Parameter param : params) { | |||
if (SUFFIX_KEY.equals(param.getName())) { | |||
suffix = param.getValue(); | |||
break; | |||
} | |||
} | |||
@@ -142,10 +142,10 @@ public final class TabsToSpaces | |||
private void initialize() { | |||
Parameter[] params = getParameters(); | |||
if (params != null) { | |||
for (int i = 0; i < params.length; i++) { | |||
if (params[i] != null) { | |||
if (TAB_LENGTH_KEY.equals(params[i].getName())) { | |||
tabLength = Integer.parseInt(params[i].getValue()); | |||
for (Parameter param : params) { | |||
if (param != null) { | |||
if (TAB_LENGTH_KEY.equals(param.getName())) { | |||
tabLength = Integer.parseInt(param.getValue()); | |||
break; | |||
} | |||
} | |||
@@ -187,13 +187,13 @@ public final class TailFilter extends BaseParamFilterReader | |||
private void initialize() { | |||
Parameter[] params = getParameters(); | |||
if (params != null) { | |||
for (int i = 0; i < params.length; i++) { | |||
if (LINES_KEY.equals(params[i].getName())) { | |||
setLines(Long.parseLong(params[i].getValue())); | |||
for (Parameter param : params) { | |||
if (LINES_KEY.equals(param.getName())) { | |||
setLines(Long.parseLong(param.getValue())); | |||
continue; | |||
} | |||
if (SKIP_KEY.equals(params[i].getName())) { | |||
skip = Long.parseLong(params[i].getValue()); | |||
if (SKIP_KEY.equals(param.getName())) { | |||
skip = Long.parseLong(param.getValue()); | |||
continue; | |||
} | |||
} | |||
@@ -48,8 +48,7 @@ public final class JavaClassHelper { | |||
final ClassParser parser = new ClassParser(bis, ""); | |||
final JavaClass javaClass = parser.parse(); | |||
final Field[] fields = javaClass.getFields(); | |||
for (int i = 0; i < fields.length; i++) { | |||
final Field field = fields[i]; | |||
for (final Field field : fields) { | |||
if (field != null) { | |||
final ConstantValue cv = field.getConstantValue(); | |||
if (cv != null) { | |||
@@ -36,9 +36,9 @@ public class DefaultExecutor implements Executor { | |||
public void executeTargets(Project project, String[] targetNames) | |||
throws BuildException { | |||
BuildException thrownException = null; | |||
for (int i = 0; i < targetNames.length; i++) { | |||
for (String targetName : targetNames) { | |||
try { | |||
project.executeTarget(targetNames[i]); | |||
project.executeTarget(targetName); | |||
} catch (BuildException ex) { | |||
if (project.isKeepGoingMode()) { | |||
thrownException = ex; | |||
@@ -42,11 +42,11 @@ public class IgnoreDependenciesExecutor implements Executor { | |||
throws BuildException { | |||
Hashtable<String, Target> targets = project.getTargets(); | |||
BuildException thrownException = null; | |||
for (int i = 0; i < targetNames.length; i++) { | |||
for (String targetName : targetNames) { | |||
try { | |||
Target t = targets.get(targetNames[i]); | |||
Target t = targets.get(targetName); | |||
if (t == null) { | |||
throw new BuildException("Unknown target " + targetNames[i]); | |||
throw new BuildException("Unknown target " + targetName); | |||
} | |||
t.performTasks(); | |||
} catch (BuildException ex) { | |||
@@ -148,10 +148,11 @@ public class Launcher { | |||
} | |||
if (getJars && element.isDirectory()) { | |||
// add any jars in the directory | |||
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]); | |||
for (URL dirURL : Locator.getLocationURLs(element)) { | |||
if (launchDiag) { | |||
System.out.println("adding library JAR: " + dirURL); | |||
} | |||
libPathURLs.add(dirURL); | |||
} | |||
} | |||
@@ -268,9 +269,9 @@ public class Launcher { | |||
baseClassPath.setLength(baseClassPath.length() - 1); | |||
} | |||
for (int i = 0; i < jars.length; ++i) { | |||
for (URL jar : jars) { | |||
baseClassPath.append(File.pathSeparatorChar); | |||
baseClassPath.append(Locator.fromURI(jars[i].toString())); | |||
baseClassPath.append(Locator.fromURI(jar.toString())); | |||
} | |||
setProperty(JAVA_CLASS_PATH, baseClassPath.toString()); | |||
@@ -89,10 +89,7 @@ public final class Locator { | |||
gAfterEscaping2[DEL] = 'F'; | |||
char[] escChs = {' ', '<', '>', '#', '%', '"', '{', '}', | |||
'|', '\\', '^', '~', '[', ']', '`'}; | |||
int len = escChs.length; | |||
char ch; | |||
for (int i = 0; i < len; i++) { | |||
ch = escChs[i]; | |||
for (char ch : escChs) { | |||
gNeedEscaping[ch] = true; | |||
gAfterEscaping1[ch] = gHexChs[ch >> NIBBLE]; | |||
gAfterEscaping2[ch] = gHexChs[ch & NIBBLE_MASK]; | |||
@@ -498,8 +495,8 @@ public final class Locator { | |||
urls = new URL[1]; | |||
String path = location.getPath(); | |||
String littlePath = path.toLowerCase(Locale.ENGLISH); | |||
for (int i = 0; i < extensions.length; ++i) { | |||
if (littlePath.endsWith(extensions[i])) { | |||
for (String extension : extensions) { | |||
if (littlePath.endsWith(extension)) { | |||
urls[0] = fileToURL(location); | |||
break; | |||
} | |||
@@ -438,10 +438,10 @@ public abstract class AbstractCvsTask extends Task { | |||
stringBuffer.append(newLine); | |||
stringBuffer.append("environment:"); | |||
stringBuffer.append(newLine); | |||
for (int z = 0; z < variableArray.length; z++) { | |||
for (String variable : variableArray) { | |||
stringBuffer.append(newLine); | |||
stringBuffer.append("\t"); | |||
stringBuffer.append(variableArray[z]); | |||
stringBuffer.append(variable); | |||
} | |||
} | |||
@@ -456,8 +456,8 @@ public class AntStructure extends Task { | |||
* @return true if all the strings in the array math XML-NMTOKEN | |||
*/ | |||
public static final boolean areNmtokens(final String[] s) { | |||
for (int i = 0; i < s.length; i++) { | |||
if (!isNmtoken(s[i])) { | |||
for (String value : s) { | |||
if (!isNmtoken(value)) { | |||
return false; | |||
} | |||
} | |||
@@ -581,9 +581,9 @@ public class Checksum extends MatchingTask implements Condition { | |||
} | |||
private String createDigestString(byte[] fileDigest) { | |||
StringBuffer checksumSb = new StringBuffer(); | |||
for (int i = 0; i < fileDigest.length; i++) { | |||
String hexStr = Integer.toHexString(BYTE_MASK & fileDigest[i]); | |||
StringBuilder checksumSb = new StringBuilder(); | |||
for (byte digestByte : fileDigest) { | |||
String hexStr = Integer.toHexString(BYTE_MASK & digestByte); | |||
if (hexStr.length() < 2) { | |||
checksumSb.append("0"); | |||
} | |||
@@ -225,9 +225,8 @@ public class Classloader extends Task { | |||
} | |||
if (existingLoader && classpath != null) { | |||
String[] list = classpath.list(); | |||
for (int i = 0; i < list.length; i++) { | |||
File f = new File(list[i]); | |||
for (String path : classpath.list()) { | |||
File f = new File(path); | |||
if (f.exists()) { | |||
log("Adding to class loader " + acl + " " + f.getAbsolutePath(), | |||
Project.MSG_DEBUG); | |||
@@ -773,28 +773,27 @@ public class Copy extends Task { | |||
final FileNameMapper mapper, final Hashtable<String, String[]> map) { | |||
String[] toCopy = null; | |||
if (forceOverwrite) { | |||
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]); | |||
final List<String> v = new ArrayList<String>(); | |||
for (String name : names) { | |||
if (mapper.mapFileName(name) != null) { | |||
v.add(name); | |||
} | |||
} | |||
toCopy = new String[v.size()]; | |||
v.copyInto(toCopy); | |||
toCopy = v.toArray(new String[v.size()]); | |||
} else { | |||
final SourceFileScanner ds = new SourceFileScanner(this); | |||
toCopy = ds.restrict(names, fromDir, toDir, mapper, granularity); | |||
} | |||
for (int i = 0; i < toCopy.length; i++) { | |||
final File src = new File(fromDir, toCopy[i]); | |||
final String[] mappedFiles = mapper.mapFileName(toCopy[i]); | |||
for (String name : toCopy) { | |||
final File src = new File(fromDir, name); | |||
final String[] mappedFiles = mapper.mapFileName(name); | |||
if (mappedFiles == null || mappedFiles.length == 0) { | |||
continue; | |||
} | |||
if (!enableMultipleMappings) { | |||
map.put(src.getAbsolutePath(), | |||
new String[] {new File(toDir, mappedFiles[0]).getAbsolutePath()}); | |||
new String[]{new File(toDir, mappedFiles[0]).getAbsolutePath()}); | |||
} else { | |||
// reuse the array created by the mapper | |||
for (int k = 0; k < mappedFiles.length; k++) { | |||
@@ -819,14 +818,13 @@ public class Copy extends Task { | |||
final HashMap<Resource, String[]> map = new HashMap<Resource, String[]>(); | |||
Resource[] toCopy = null; | |||
if (forceOverwrite) { | |||
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]); | |||
final List<Resource> v = new ArrayList<Resource>(); | |||
for (Resource rc : fromResources) { | |||
if (mapper.mapFileName(rc.getName()) != null) { | |||
v.add(rc); | |||
} | |||
} | |||
toCopy = new Resource[v.size()]; | |||
v.copyInto(toCopy); | |||
toCopy = v.toArray(new Resource[v.size()]); | |||
} else { | |||
toCopy = ResourceUtils.selectOutOfDateSources(this, fromResources, | |||
mapper, | |||
@@ -837,22 +835,21 @@ public class Copy extends Task { | |||
}, | |||
granularity); | |||
} | |||
for (int i = 0; i < toCopy.length; i++) { | |||
final String[] mappedFiles = mapper.mapFileName(toCopy[i].getName()); | |||
for (Resource rc : toCopy) { | |||
final String[] mappedFiles = mapper.mapFileName(rc.getName()); | |||
if (mappedFiles == null || mappedFiles.length == 0) { | |||
throw new BuildException("Can't copy a resource without a" | |||
+ " name if the mapper doesn't" | |||
+ " provide one."); | |||
} | |||
if (!enableMultipleMappings) { | |||
map.put(toCopy[i], | |||
new String[] {new File(toDir, mappedFiles[0]).getAbsolutePath()}); | |||
map.put(rc, new String[]{new File(toDir, mappedFiles[0]).getAbsolutePath()}); | |||
} else { | |||
// reuse the array created by the mapper | |||
for (int k = 0; k < mappedFiles.length; k++) { | |||
mappedFiles[k] = new File(toDir, mappedFiles[k]).getAbsolutePath(); | |||
} | |||
map.put(toCopy[i], mappedFiles); | |||
map.put(rc, mappedFiles); | |||
} | |||
} | |||
return map; | |||
@@ -870,11 +867,8 @@ public class Copy extends Task { | |||
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++) { | |||
final String toFile = toFiles[i]; | |||
for (final String toFile : e.getValue()) { | |||
if (fromFile.equals(toFile)) { | |||
log("Skipping self-copy of " + fromFile, verbosity); | |||
continue; | |||
@@ -177,17 +177,15 @@ public class CopyPath extends Task { | |||
return; | |||
} | |||
for (int sources = 0; sources < sourceFiles.length; sources++) { | |||
for (String sourceFileName : sourceFiles) { | |||
String sourceFileName = sourceFiles[sources]; | |||
File sourceFile = new File(sourceFileName); | |||
String[] toFiles = (String[]) mapper.mapFileName(sourceFileName); | |||
if (toFiles == null) { | |||
continue; | |||
} | |||
for (int i = 0; i < toFiles.length; i++) { | |||
String destFileName = toFiles[i]; | |||
for (String destFileName : toFiles) { | |||
File destFile = new File(destDir, destFileName); | |||
if (sourceFile.equals(destFile)) { | |||
@@ -144,8 +144,7 @@ public class Copydir extends MatchingTask { | |||
} | |||
private void scanDir(File from, File to, String[] files) { | |||
for (int i = 0; i < files.length; i++) { | |||
String filename = files[i]; | |||
for (String filename : files) { | |||
File srcFile = new File(from, filename); | |||
File destFile; | |||
if (flatten) { | |||
@@ -627,8 +627,7 @@ public class Delete extends MatchingTask { | |||
} | |||
final int size = filesets.size(); | |||
for (int i = 0; i < size; i++) { | |||
FileSet fs = (FileSet) filesets.get(i); | |||
for (FileSet fs : filesets) { | |||
if (fs.getProject() == null) { | |||
log("Deleting fileset with no project specified;" | |||
+ " assuming executing project", Project.MSG_VERBOSE); | |||
@@ -674,11 +673,9 @@ public class Delete extends MatchingTask { | |||
String[] links = new String[n.length]; | |||
System.arraycopy(n, 0, links, 0, n.length); | |||
Arrays.sort(links, ReverseDirs.REVERSE); | |||
for (int l = 0; l < links.length; l++) { | |||
for (String link : links) { | |||
try { | |||
SYMLINK_UTILS | |||
.deleteSymbolicLink(new File(links[l]), | |||
this); | |||
SYMLINK_UTILS.deleteSymbolicLink(new File(link), this); | |||
} catch (java.io.IOException ex) { | |||
handle(ex); | |||
} | |||
@@ -772,8 +769,7 @@ public class Delete extends MatchingTask { | |||
if (list == null) { | |||
list = new String[0]; | |||
} | |||
for (int i = 0; i < list.length; i++) { | |||
String s = list[i]; | |||
for (String s : list) { | |||
File f = new File(d, s); | |||
if (f.isDirectory()) { | |||
removeDir(f); | |||
@@ -801,8 +797,8 @@ public class Delete extends MatchingTask { | |||
if (files.length > 0) { | |||
log("Deleting " + files.length + " files from " | |||
+ d.getAbsolutePath(), quiet ? Project.MSG_VERBOSE : verbosity); | |||
for (int j = 0; j < files.length; j++) { | |||
File f = new File(d, files[j]); | |||
for (String filename : files) { | |||
File f = new File(d, filename); | |||
log("Deleting " + f.getAbsolutePath(), | |||
quiet ? Project.MSG_VERBOSE : verbosity); | |||
if (!delete(f)) { | |||
@@ -90,9 +90,7 @@ public class Deltree extends Task { | |||
// if (dir.getCanonicalPath().equals(dir.getAbsolutePath())) { | |||
// (costin) It will not work if /home/costin is symlink to | |||
// /da0/home/costin ( taz for example ) | |||
String[] list = dir.list(); | |||
for (int i = 0; i < list.length; i++) { | |||
String s = list[i]; | |||
for (String s : dir.list()) { | |||
File f = new File(dir, s); | |||
if (f.isDirectory()) { | |||
removeDir(f); | |||
@@ -447,9 +447,9 @@ public class ExecTask extends Task { | |||
Path p = null; | |||
String[] environment = env.getVariables(); | |||
if (environment != null) { | |||
for (int i = 0; i < environment.length; i++) { | |||
if (isPath(environment[i])) { | |||
p = new Path(getProject(), getPath(environment[i])); | |||
for (String variable : environment) { | |||
if (isPath(variable)) { | |||
p = new Path(getProject(), getPath(variable)); | |||
break; | |||
} | |||
} | |||
@@ -461,10 +461,9 @@ public class ExecTask extends Task { | |||
} | |||
} | |||
if (p != null) { | |||
String[] dirs = p.list(); | |||
for (int i = 0; i < dirs.length; i++) { | |||
for (String pathname : p.list()) { | |||
executableFile | |||
= FILE_UTILS.resolveFile(new File(dirs[i]), exec); | |||
= FILE_UTILS.resolveFile(new File(pathname), exec); | |||
if (executableFile.exists()) { | |||
return executableFile.getAbsolutePath(); | |||
} | |||
@@ -605,9 +604,9 @@ public class ExecTask extends Task { | |||
exe.setVMLauncher(vmLauncher); | |||
String[] environment = env.getVariables(); | |||
if (environment != null) { | |||
for (int i = 0; i < environment.length; i++) { | |||
log("Setting environment variable: " + environment[i], | |||
Project.MSG_VERBOSE); | |||
for (String variable : environment) { | |||
log("Setting environment variable: " + variable, | |||
Project.MSG_VERBOSE); | |||
} | |||
} | |||
exe.setNewenvironment(newEnvironment); | |||
@@ -612,8 +612,7 @@ public class Execute { | |||
} | |||
Map<String, String> osEnv = | |||
new LinkedHashMap<String, String>(getEnvironmentVariables()); | |||
for (int i = 0; i < env.length; i++) { | |||
String keyValue = env[i]; | |||
for (String keyValue : env) { | |||
String key = keyValue.substring(0, keyValue.indexOf('=')); | |||
// Find the key in the current environment copy | |||
// and remove it. | |||
@@ -272,9 +272,8 @@ public class ExecuteJava implements Runnable, TimeoutObserver { | |||
public int fork(ProjectComponent pc) throws BuildException { | |||
CommandlineJava cmdl = new CommandlineJava(); | |||
cmdl.setClassname(javaCommand.getExecutable()); | |||
String[] args = javaCommand.getArguments(); | |||
for (int i = 0; i < args.length; i++) { | |||
cmdl.createArgument().setValue(args[i]); | |||
for (String arg : javaCommand.getArguments()) { | |||
cmdl.createArgument().setValue(arg); | |||
} | |||
if (classpath != null) { | |||
cmdl.createClasspath(pc.getProject()).append(classpath); | |||
@@ -21,6 +21,7 @@ package org.apache.tools.ant.taskdefs; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.util.HashSet; | |||
import java.util.Set; | |||
import java.util.Vector; | |||
import org.apache.tools.ant.BuildException; | |||
@@ -369,19 +370,17 @@ public class ExecuteOn extends ExecTask { | |||
DirectoryScanner ds = fs.getDirectoryScanner(getProject()); | |||
if (!FileDirBoth.DIR.equals(currentType)) { | |||
String[] s = getFiles(base, ds); | |||
for (int j = 0; j < s.length; j++) { | |||
for (String value : getFiles(base, ds)) { | |||
totalFiles++; | |||
fileNames.addElement(s[j]); | |||
baseDirs.addElement(base); | |||
fileNames.add(value); | |||
baseDirs.add(base); | |||
} | |||
} | |||
if (!FileDirBoth.FILE.equals(currentType)) { | |||
String[] s = getDirs(base, ds); | |||
for (int j = 0; j < s.length; j++) { | |||
for (String value : getDirs(base, ds)) { | |||
totalDirs++; | |||
fileNames.addElement(s[j]); | |||
baseDirs.addElement(base); | |||
fileNames.add(value); | |||
baseDirs.add(base); | |||
} | |||
} | |||
if (fileNames.size() == 0 && skipEmpty) { | |||
@@ -516,9 +515,9 @@ public class ExecuteOn extends ExecTask { | |||
final char fileSeparator = File.separatorChar; | |||
Vector<String> targets = new Vector<String>(); | |||
if (targetFilePos != null) { | |||
HashSet<String> addedFiles = new HashSet<String>(); | |||
for (int i = 0; i < srcFiles.length; i++) { | |||
String[] subTargets = mapper.mapFileName(srcFiles[i]); | |||
Set<String> addedFiles = new HashSet<String>(); | |||
for (String srcFile : srcFiles) { | |||
String[] subTargets = mapper.mapFileName(srcFile); | |||
if (subTargets != null) { | |||
for (int j = 0; j < subTargets.length; j++) { | |||
String name = null; | |||
@@ -279,18 +279,16 @@ public class Expand extends Task { | |||
boolean included = false; | |||
Set<String> includePatterns = new HashSet<String>(); | |||
Set<String> excludePatterns = new HashSet<String>(); | |||
final int size = patternsets.size(); | |||
for (int v = 0; v < size; v++) { | |||
PatternSet p = patternsets.elementAt(v); | |||
for (PatternSet p : patternsets) { | |||
String[] incls = p.getIncludePatterns(getProject()); | |||
if (incls == null || incls.length == 0) { | |||
// no include pattern implicitly means includes="**" | |||
incls = new String[] {"**"}; | |||
incls = new String[]{"**"}; | |||
} | |||
for (int w = 0; w < incls.length; w++) { | |||
String pattern = incls[w].replace('/', File.separatorChar) | |||
.replace('\\', File.separatorChar); | |||
for (String incl : incls) { | |||
String pattern = incl.replace('/', File.separatorChar) | |||
.replace('\\', File.separatorChar); | |||
if (pattern.endsWith(File.separator)) { | |||
pattern += "**"; | |||
} | |||
@@ -299,10 +297,9 @@ public class Expand extends Task { | |||
String[] excls = p.getExcludePatterns(getProject()); | |||
if (excls != null) { | |||
for (int w = 0; w < excls.length; w++) { | |||
String pattern = excls[w] | |||
.replace('/', File.separatorChar) | |||
.replace('\\', File.separatorChar); | |||
for (String excl : excls) { | |||
String pattern = excl.replace('/', File.separatorChar) | |||
.replace('\\', File.separatorChar); | |||
if (pattern.endsWith(File.separator)) { | |||
pattern += "**"; | |||
} | |||
@@ -299,10 +299,9 @@ public class FixCRLF extends MatchingTask implements ChainableReader { | |||
Project.MSG_VERBOSE); | |||
DirectoryScanner ds = super.getDirectoryScanner(srcDir); | |||
String[] files = ds.getIncludedFiles(); | |||
for (int i = 0; i < files.length; i++) { | |||
processFile(files[i]); | |||
for (String filename : ds.getIncludedFiles()) { | |||
processFile(filename); | |||
} | |||
} | |||
@@ -574,10 +574,8 @@ public class Jar extends Zip { | |||
private void writeManifest(ZipOutputStream zOut, Manifest manifest) | |||
throws IOException { | |||
for (Enumeration<String> e = manifest.getWarnings(); | |||
e.hasMoreElements();) { | |||
log("Manifest warning: " + e.nextElement(), | |||
Project.MSG_WARN); | |||
for (String warning : Collections.list(manifest.getWarnings())) { | |||
log("Manifest warning: " + warning, Project.MSG_WARN); | |||
} | |||
zipDir((Resource) null, zOut, "META-INF/", ZipFileSet.DEFAULT_DIR_MODE, | |||
@@ -661,13 +659,12 @@ public class Jar extends Zip { | |||
cpEntries[c++] = tok.nextToken(); | |||
} | |||
} | |||
String[] indexJarEntries = indexJars.list(); | |||
for (int i = 0; i < indexJarEntries.length; i++) { | |||
String name = findJarName(indexJarEntries[i], cpEntries); | |||
for (String indexJarEntry : indexJars.list()) { | |||
String name = findJarName(indexJarEntry, cpEntries); | |||
if (name != null) { | |||
ArrayList<String> dirs = new ArrayList<String>(); | |||
ArrayList<String> files = new ArrayList<String>(); | |||
grabFilesAndDirs(indexJarEntries[i], dirs, files); | |||
grabFilesAndDirs(indexJarEntry, dirs, files); | |||
if (dirs.size() + files.size() > 0) { | |||
writer.println(name); | |||
writeIndexLikeList(dirs, files, writer); | |||
@@ -830,8 +827,8 @@ public class Jar extends Zip { | |||
// checks here deferring them for the second run | |||
Resource[][] manifests = grabManifests(rcs); | |||
int count = 0; | |||
for (int i = 0; i < manifests.length; i++) { | |||
count += manifests[i].length; | |||
for (Resource[] mf : manifests) { | |||
count += mf.length; | |||
} | |||
log("found a total of " + count + " manifests in " | |||
+ manifests.length + " resource collections", | |||
@@ -1153,10 +1153,9 @@ public class Javac extends MatchingTask { | |||
*/ | |||
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]); | |||
for (String extension : findSupportedFileExtensions()) { | |||
m.setFrom(extension); | |||
m.setTo("*.class"); | |||
final SourceFileScanner sfs = new SourceFileScanner(this); | |||
final File[] newFiles = sfs.restrictAsFiles(files, srcDir, destDir, m); | |||
@@ -1175,9 +1174,8 @@ public class Javac extends MatchingTask { | |||
} | |||
private void collectFileListFromSourcePath() { | |||
final String[] list = src.list(); | |||
for (int i = 0; i < list.length; i++) { | |||
final File srcDir = getProject().resolveFile(list[i]); | |||
for (String filename : src.list()) { | |||
final File srcDir = getProject().resolveFile(filename); | |||
if (!srcDir.exists()) { | |||
throw new BuildException("srcdir \"" | |||
+ srcDir.getPath() | |||
@@ -1195,7 +1193,8 @@ public class Javac extends MatchingTask { | |||
final FileUtils fu = FileUtils.getFileUtils(); | |||
for (String pathElement : moduleSourcepath.list()) { | |||
boolean valid = false; | |||
for (Map.Entry<String,Collection<File>> modules : resolveModuleSourcePathElement(getProject().getBaseDir(), pathElement).entrySet()) { | |||
for (Map.Entry<String,Collection<File>> modules : resolveModuleSourcePathElement( | |||
getProject().getBaseDir(), pathElement).entrySet()) { | |||
final String moduleName = modules.getKey(); | |||
for (File srcDir : modules.getValue()) { | |||
if (srcDir.exists()) { | |||
@@ -33,6 +33,7 @@ import java.io.OutputStreamWriter; | |||
import java.net.MalformedURLException; | |||
import java.net.URL; | |||
import java.util.ArrayList; | |||
import java.util.Collections; | |||
import java.util.Enumeration; | |||
import java.util.HashSet; | |||
import java.util.Iterator; | |||
@@ -1918,32 +1919,26 @@ public class Javadoc extends Task { | |||
private void doDoclet(final Commandline toExecute) { | |||
if (doclet != null) { | |||
if (doclet.getName() == null) { | |||
throw new BuildException("The doclet name must be " | |||
+ "specified.", getLocation()); | |||
} else { | |||
toExecute.createArgument().setValue("-doclet"); | |||
toExecute.createArgument().setValue(doclet.getName()); | |||
if (doclet.getPath() != null) { | |||
final Path docletPath | |||
= doclet.getPath().concatSystemClasspath("ignore"); | |||
if (docletPath.size() != 0) { | |||
toExecute.createArgument().setValue("-docletpath"); | |||
toExecute.createArgument().setPath(docletPath); | |||
} | |||
throw new BuildException("The doclet name must be specified.", | |||
getLocation()); | |||
} | |||
toExecute.createArgument().setValue("-doclet"); | |||
toExecute.createArgument().setValue(doclet.getName()); | |||
if (doclet.getPath() != null) { | |||
final Path docletPath | |||
= doclet.getPath().concatSystemClasspath("ignore"); | |||
if (docletPath.size() != 0) { | |||
toExecute.createArgument().setValue("-docletpath"); | |||
toExecute.createArgument().setPath(docletPath); | |||
} | |||
for (final Enumeration<DocletParam> e = doclet.getParams(); | |||
e.hasMoreElements();) { | |||
final DocletParam param = e.nextElement(); | |||
if (param.getName() == null) { | |||
throw new BuildException("Doclet parameters must " | |||
+ "have a name"); | |||
} | |||
toExecute.createArgument().setValue(param.getName()); | |||
if (param.getValue() != null) { | |||
toExecute.createArgument() | |||
.setValue(param.getValue()); | |||
} | |||
} | |||
for (final DocletParam param : Collections.list(doclet.getParams())) { | |||
if (param.getName() == null) { | |||
throw new BuildException("Doclet parameters must have a name"); | |||
} | |||
toExecute.createArgument().setValue(param.getName()); | |||
if (param.getValue() != null) { | |||
toExecute.createArgument().setValue(param.getValue()); | |||
} | |||
} | |||
} | |||
@@ -2152,27 +2147,20 @@ public class Javadoc extends Task { | |||
// -tag arguments. | |||
final DirectoryScanner tagDefScanner = | |||
ta.getDirectoryScanner(getProject()); | |||
final String[] files = tagDefScanner.getIncludedFiles(); | |||
for (int i = 0; i < files.length; i++) { | |||
final File tagDefFile = new File(tagDir, files[i]); | |||
for (String file : tagDefScanner.getIncludedFiles()) { | |||
final File tagDefFile = new File(tagDir, file); | |||
try { | |||
final BufferedReader in | |||
= new BufferedReader( | |||
new FileReader(tagDefFile) | |||
); | |||
final BufferedReader in = new BufferedReader( | |||
new FileReader(tagDefFile)); | |||
String line = null; | |||
while ((line = in.readLine()) != null) { | |||
toExecute.createArgument() | |||
.setValue("-tag"); | |||
toExecute.createArgument() | |||
.setValue(line); | |||
toExecute.createArgument().setValue("-tag"); | |||
toExecute.createArgument().setValue(line); | |||
} | |||
in.close(); | |||
} catch (final IOException ioe) { | |||
throw new BuildException( | |||
"Couldn't read " | |||
+ " tag file from " | |||
+ tagDefFile.getAbsolutePath(), ioe); | |||
throw new BuildException("Couldn't read tag file from " | |||
+ tagDefFile.getAbsolutePath(), ioe); | |||
} | |||
} | |||
} | |||
@@ -2278,9 +2266,8 @@ public class Javadoc extends Task { | |||
} | |||
private boolean containsWhitespace(final String s) { | |||
final int len = s.length(); | |||
for (int i = 0; i < len; i++) { | |||
if (Character.isWhitespace(s.charAt(i))) { | |||
for (char c : s.toCharArray()) { | |||
if (Character.isWhitespace(c)) { | |||
return true; | |||
} | |||
} | |||
@@ -2290,10 +2277,8 @@ public class Javadoc extends Task { | |||
private String quoteString(final String str, final char delim) { | |||
final StringBuffer buf = new StringBuffer(str.length() * 2); | |||
buf.append(delim); | |||
final int len = str.length(); | |||
boolean lastCharWasCR = false; | |||
for (int i = 0; i < len; i++) { | |||
final char c = str.charAt(i); | |||
for (final char c : str.toCharArray()) { | |||
if (c == delim) { // can't put the non-constant delim into a case | |||
buf.append('\\').append(c); | |||
lastCharWasCR = false; | |||
@@ -2429,11 +2414,10 @@ public class Javadoc extends Task { | |||
final File baseDir = ds.getDir(getProject()); | |||
log("scanning " + baseDir + " for packages.", Project.MSG_DEBUG); | |||
final DirectoryScanner dsc = ds.getDirectoryScanner(getProject()); | |||
final String[] dirs = dsc.getIncludedDirectories(); | |||
boolean containsPackages = false; | |||
for (int i = 0; i < dirs.length; i++) { | |||
for (String dir : dsc.getIncludedDirectories()) { | |||
// are there any java files in this directory? | |||
final File pd = new File(baseDir, dirs[i]); | |||
final File pd = new File(baseDir, dir); | |||
final String[] files = pd.list(new FilenameFilter () { | |||
public boolean accept(final File dir1, final String name) { | |||
return name.endsWith(".java") | |||
@@ -2443,7 +2427,7 @@ public class Javadoc extends Task { | |||
}); | |||
if (files.length > 0) { | |||
if ("".equals(dirs[i])) { | |||
if ("".equals(dir)) { | |||
log(baseDir | |||
+ " contains source files in the default package," | |||
+ " you must specify them as source files" | |||
@@ -2452,7 +2436,7 @@ public class Javadoc extends Task { | |||
} else { | |||
containsPackages = true; | |||
final String packageName = | |||
dirs[i].replace(File.separatorChar, '.'); | |||
dir.replace(File.separatorChar, '.'); | |||
if (!addedPackages.contains(packageName)) { | |||
addedPackages.add(packageName); | |||
pn.addElement(packageName); | |||
@@ -90,8 +90,8 @@ public class Jikes { | |||
tmpFile = FileUtils.getFileUtils().createTempFile("jikes", | |||
"tmp", null, false, true); | |||
out = new BufferedWriter(new FileWriter(tmpFile)); | |||
for (int i = 0; i < args.length; i++) { | |||
out.write(args[i]); | |||
for (String arg : args) { | |||
out.write(arg); | |||
out.newLine(); | |||
} | |||
out.flush(); | |||
@@ -262,8 +262,7 @@ public class MacroDef extends AntlibDefinition { | |||
+ "\" has already been used by the text element"); | |||
} | |||
final int size = attributes.size(); | |||
for (int i = 0; i < size; ++i) { | |||
Attribute att = (Attribute) attributes.get(i); | |||
for (Attribute att : attributes) { | |||
if (att.getName().equals(attribute.getName())) { | |||
throw new BuildException( | |||
"the name \"" + attribute.getName() | |||
@@ -20,6 +20,7 @@ package org.apache.tools.ant.taskdefs; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.util.Iterator; | |||
import java.util.Map; | |||
import org.apache.tools.ant.BuildException; | |||
import org.apache.tools.ant.DirectoryScanner; | |||
@@ -167,17 +168,16 @@ public class Move extends Copy { | |||
if (includeEmpty) { | |||
int createCount = 0; | |||
for (Iterator fromDirNames = dirCopyMap.keySet().iterator(); fromDirNames.hasNext();) { | |||
String fromDirName = (String) fromDirNames.next(); | |||
String[] toDirNames = (String[]) dirCopyMap.get(fromDirName); | |||
for (Map.Entry<String, String[]> entry : dirCopyMap.entrySet()) { | |||
String fromDirName = entry.getKey(); | |||
boolean selfMove = false; | |||
for (int i = 0; i < toDirNames.length; i++) { | |||
if (fromDirName.equals(toDirNames[i])) { | |||
for (String toDirName : entry.getValue()) { | |||
if (fromDirName.equals(toDirName)) { | |||
log("Skipping self-move of " + fromDirName, verbosity); | |||
selfMove = true; | |||
continue; | |||
} | |||
File d = new File(toDirNames[i]); | |||
File d = new File(toDirName); | |||
if (!d.exists()) { | |||
if (!(d.mkdirs() || d.exists())) { | |||
log("Unable to create directory " | |||
@@ -417,9 +417,9 @@ public class Parallel extends Task | |||
int tries = 0; | |||
do { | |||
oneAlive = false; | |||
for (int i = 0; i < running.length; i++) { | |||
if (running[i] != null && !running[i].isFinished()) { | |||
running[i].interrupt(); | |||
for (TaskRunnable runnable : running) { | |||
if (runnable != null && !runnable.isFinished()) { | |||
runnable.interrupt(); | |||
Thread.yield(); | |||
oneAlive = true; | |||
} | |||
@@ -18,7 +18,6 @@ | |||
package org.apache.tools.ant.taskdefs; | |||
import java.util.Hashtable; | |||
import java.util.Iterator; | |||
import java.util.Map; | |||
import org.apache.tools.ant.BuildEvent; | |||
@@ -68,7 +67,7 @@ public class Recorder extends Task implements SubBuildListener { | |||
/** Strip task banners if true. */ | |||
private boolean emacsMode = false; | |||
/** The list of recorder entries. */ | |||
private static Hashtable recorderEntries = new Hashtable(); | |||
private static Hashtable<String, RecorderEntry> recorderEntries = new Hashtable<>(); | |||
////////////////////////////////////////////////////////////////////// | |||
// CONSTRUCTORS / INITIALIZERS | |||
@@ -206,10 +205,9 @@ public class Recorder extends Task implements SubBuildListener { | |||
*/ | |||
protected RecorderEntry getRecorder(String name, Project proj) | |||
throws BuildException { | |||
Object o = recorderEntries.get(name); | |||
RecorderEntry entry; | |||
RecorderEntry entry = recorderEntries.get(name); | |||
if (o == null) { | |||
if (entry == null) { | |||
// create a recorder entry | |||
entry = new RecorderEntry(name); | |||
@@ -220,9 +218,8 @@ public class Recorder extends Task implements SubBuildListener { | |||
} | |||
entry.setProject(proj); | |||
recorderEntries.put(name, entry); | |||
} else { | |||
entry = (RecorderEntry) o; | |||
} | |||
return entry; | |||
} | |||
@@ -308,12 +305,12 @@ public class Recorder extends Task implements SubBuildListener { | |||
* | |||
* @since Ant 1.7 | |||
*/ | |||
@SuppressWarnings("unchecked") | |||
private void cleanup() { | |||
Hashtable entries = (Hashtable) recorderEntries.clone(); | |||
Iterator itEntries = entries.entrySet().iterator(); | |||
while (itEntries.hasNext()) { | |||
Map.Entry entry = (Map.Entry) itEntries.next(); | |||
RecorderEntry re = (RecorderEntry) entry.getValue(); | |||
Hashtable<String, RecorderEntry> entries | |||
= (Hashtable<String, RecorderEntry>) recorderEntries.clone(); | |||
for (Map.Entry<String, RecorderEntry> entry : entries.entrySet()) { | |||
RecorderEntry re = entry.getValue(); | |||
if (re.getProject() == getProject()) { | |||
recorderEntries.remove(entry.getKey()); | |||
} | |||
@@ -70,7 +70,7 @@ public class Replace extends MatchingTask { | |||
private Resource propertyResource = null; | |||
private Resource replaceFilterResource = null; | |||
private Properties properties = null; | |||
private ArrayList replacefilters = new ArrayList(); | |||
private ArrayList<Replacefilter> replacefilters = new ArrayList<Replacefilter>(); | |||
private File dir = null; | |||
@@ -744,9 +744,7 @@ public class Replace extends MatchingTask { | |||
*/ | |||
private StringBuffer buildFilterChain(StringBuffer inputBuffer) { | |||
StringBuffer buf = inputBuffer; | |||
final int size = replacefilters.size(); | |||
for (int i = 0; i < size; i++) { | |||
Replacefilter filter = (Replacefilter) replacefilters.get(i); | |||
for (Replacefilter filter : replacefilters) { | |||
filter.setInputBuffer(buf); | |||
buf = filter.getOutputBuffer(); | |||
} | |||
@@ -203,13 +203,13 @@ public class SubAnt extends Task { | |||
} | |||
*/ | |||
BuildException buildException = null; | |||
for (int i = 0; i < count; ++i) { | |||
for (String filename : filenames) { | |||
File file = null; | |||
String subdirPath = null; | |||
Throwable thrownException = null; | |||
try { | |||
File directory = null; | |||
file = new File(filenames[i]); | |||
file = new File(filename); | |||
if (file.isDirectory()) { | |||
if (verbose) { | |||
subdirPath = file.getPath(); | |||
@@ -226,9 +226,8 @@ public class Sync extends Task { | |||
ds.addExcludes(excls); | |||
ds.scan(); | |||
String[] files = ds.getIncludedFiles(); | |||
for (int i = 0; i < files.length; i++) { | |||
File f = new File(toDir, files[i]); | |||
for (String file : ds.getIncludedFiles()) { | |||
File f = new File(toDir, file); | |||
log("Removing orphan file: " + f, Project.MSG_DEBUG); | |||
f.delete(); | |||
++removedCount[1]; | |||
@@ -286,13 +285,11 @@ public class Sync extends Task { | |||
int removedCount = 0; | |||
if (dir.isDirectory()) { | |||
File[] children = dir.listFiles(); | |||
for (int i = 0; i < children.length; ++i) { | |||
File file = children[i]; | |||
for (File file : children) { | |||
// Test here again to avoid method call for non-directories! | |||
if (file.isDirectory()) { | |||
removedCount += | |||
removeEmptyDirectories(file, true, | |||
preservedEmptyDirectories); | |||
removedCount += removeEmptyDirectories(file, true, | |||
preservedEmptyDirectories); | |||
} | |||
} | |||
if (children.length > 0) { | |||
@@ -347,8 +347,8 @@ public class Touch extends Task { | |||
if (millis < 0 && r.isExists()) { | |||
modTime = r.getLastModified(); | |||
} | |||
for (int i = 0; i < mapped.length; i++) { | |||
touch(getProject().resolveFile(mapped[i]), modTime); | |||
for (String fileName : mapped) { | |||
touch(getProject().resolveFile(fileName), modTime); | |||
} | |||
} | |||
} | |||
@@ -220,22 +220,19 @@ public class Untar extends Expand { | |||
* @exception BuildException thrown if bzip stream does not | |||
* start with expected magic values | |||
*/ | |||
public InputStream decompress(final String name, | |||
final InputStream istream) | |||
throws IOException, BuildException { | |||
public InputStream decompress(final String name, final InputStream istream) | |||
throws IOException, BuildException { | |||
final String v = getValue(); | |||
if (GZIP.equals(v)) { | |||
return new GZIPInputStream(istream); | |||
} else { | |||
if (BZIP2.equals(v)) { | |||
final char[] magic = new char[] {'B', 'Z'}; | |||
for (int i = 0; i < magic.length; i++) { | |||
if (istream.read() != magic[i]) { | |||
throw new BuildException("Invalid bz2 file." + name); | |||
} | |||
} | |||
if (BZIP2.equals(v)) { | |||
for (char c : new char[] {'B', 'Z'}) { | |||
if (istream.read() != c) { | |||
throw new BuildException("Invalid bz2 file." + name); | |||
} | |||
return new CBZip2InputStream(istream); | |||
} | |||
return new CBZip2InputStream(istream); | |||
} | |||
return istream; | |||
} | |||
@@ -120,7 +120,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||
private boolean force = false; | |||
/** XSL output properties to be used */ | |||
private final Vector outputProperties = new Vector(); | |||
private final Vector<OutputProperty> outputProperties = new Vector<OutputProperty>(); | |||
/** for resolving entities such as dtds */ | |||
private final XMLCatalog xmlCatalog = new XMLCatalog(); | |||
@@ -940,7 +940,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||
* Get an enumeration on the outputproperties. | |||
* @return the outputproperties | |||
*/ | |||
public Enumeration getOutputProperties() { | |||
public Enumeration<OutputProperty> getOutputProperties() { | |||
return outputProperties.elements(); | |||
} | |||
@@ -1513,7 +1513,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||
* return the attribute elements. | |||
* @return the enumeration of attributes | |||
*/ | |||
public Enumeration getAttributes() { | |||
public Enumeration<Attribute> getAttributes() { | |||
return Collections.enumeration(attributes); | |||
} | |||
@@ -54,19 +54,16 @@ public class Javac12 extends DefaultCompilerAdapter { | |||
try { | |||
// Create an instance of the compiler, redirecting output to | |||
// the project log | |||
Class c = Class.forName(CLASSIC_COMPILER_CLASSNAME); | |||
Class<?> c = Class.forName(CLASSIC_COMPILER_CLASSNAME); | |||
Constructor cons = | |||
c.getConstructor(new Class[] {OutputStream.class, | |||
String.class}); | |||
c.getConstructor(OutputStream.class, String.class); | |||
Object compiler | |||
= cons.newInstance(new Object[] {logstr, "javac"}); | |||
= cons.newInstance(logstr, "javac"); | |||
// Call the compile() method | |||
Method compile = c.getMethod("compile", | |||
new Class [] {String[].class}); | |||
Boolean ok = | |||
(Boolean) compile.invoke(compiler, | |||
new Object[] {cmd.getArguments()}); | |||
Method compile = c.getMethod("compile", String[].class); | |||
Boolean ok = (Boolean) compile.invoke(compiler, | |||
new Object[] {cmd.getArguments()}); | |||
return ok.booleanValue(); | |||
} catch (ClassNotFoundException ex) { | |||
throw new BuildException("Cannot use classic compiler, as it is " | |||
@@ -100,18 +100,17 @@ public class AntVersion extends Task implements Condition { | |||
private DeweyDecimal getVersion() { | |||
Project p = new Project(); | |||
p.init(); | |||
char[] versionString = p.getProperty("ant.version").toCharArray(); | |||
StringBuffer sb = new StringBuffer(); | |||
StringBuilder sb = new StringBuilder(); | |||
boolean foundFirstDigit = false; | |||
for (int i = 0; i < versionString.length; i++) { | |||
if (Character.isDigit(versionString[i])) { | |||
sb.append(versionString[i]); | |||
for (char versionChar : p.getProperty("ant.version").toCharArray()) { | |||
if (Character.isDigit(versionChar)) { | |||
sb.append(versionChar); | |||
foundFirstDigit = true; | |||
} | |||
if (versionString[i] == '.' && foundFirstDigit) { | |||
sb.append(versionString[i]); | |||
if (versionChar == '.' && foundFirstDigit) { | |||
sb.append(versionChar); | |||
} | |||
if (Character.isLetter(versionString[i]) && foundFirstDigit) { | |||
if (Character.isLetter(versionChar) && foundFirstDigit) { | |||
break; | |||
} | |||
} | |||
@@ -167,10 +167,8 @@ public class HasMethod extends ProjectComponent implements Condition { | |||
} | |||
} | |||
private boolean isFieldFound(Class clazz) { | |||
Field[] fields = clazz.getDeclaredFields(); | |||
for (int i = 0; i < fields.length; i++) { | |||
Field fieldEntry = fields[i]; | |||
private boolean isFieldFound(Class<?> clazz) { | |||
for (Field fieldEntry : clazz.getDeclaredFields()) { | |||
if (fieldEntry.getName().equals(field)) { | |||
return true; | |||
} | |||
@@ -178,10 +176,8 @@ public class HasMethod extends ProjectComponent implements Condition { | |||
return false; | |||
} | |||
private boolean isMethodFound(Class clazz) { | |||
Method[] methods = clazz.getDeclaredMethods(); | |||
for (int i = 0; i < methods.length; i++) { | |||
Method methodEntry = methods[i]; | |||
private boolean isMethodFound(Class<?> clazz) { | |||
for (Method methodEntry : clazz.getDeclaredMethods()) { | |||
if (methodEntry.getName().equals(method)) { | |||
return true; | |||
} | |||
@@ -441,8 +441,8 @@ public class CvsTagDiff extends AbstractCvsTask { | |||
CollectionUtils.flattenToString(packageNames)); | |||
DOM_WRITER.openElement(root, writer, 0, "\t"); | |||
writer.println(); | |||
for (int i = 0, c = entries.length; i < c; i++) { | |||
writeTagEntry(doc, writer, entries[i]); | |||
for (CvsTagEntry entry : entries) { | |||
writeTagEntry(doc, writer, entry); | |||
} | |||
DOM_WRITER.closeElement(root, writer, 0, "\t", true); | |||
writer.flush(); | |||
@@ -27,8 +27,10 @@ import java.io.PrintStream; | |||
import java.io.UnsupportedEncodingException; | |||
import java.security.Provider; | |||
import java.security.Security; | |||
import java.util.ArrayList; | |||
import java.util.Enumeration; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
import java.util.Locale; | |||
import java.util.Properties; | |||
import java.util.StringTokenizer; | |||
@@ -263,21 +265,20 @@ public class MimeMailer extends Mailer { | |||
|| sfe.getValidSentAddresses().length == 0) { | |||
throw new BuildException("Couldn't reach any recipient", | |||
sfe); | |||
} else { | |||
Address[] invalid = sfe.getInvalidAddresses(); | |||
if (invalid == null) { | |||
invalid = new Address[0]; | |||
} | |||
for (int i = 0; i < invalid.length; i++) { | |||
didntReach(invalid[i], "invalid", sfe); | |||
} | |||
Address[] validUnsent = sfe.getValidUnsentAddresses(); | |||
if (validUnsent == null) { | |||
validUnsent = new Address[0]; | |||
} | |||
for (int i = 0; i < validUnsent.length; i++) { | |||
didntReach(validUnsent[i], "valid", sfe); | |||
} | |||
} | |||
Address[] invalid = sfe.getInvalidAddresses(); | |||
if (invalid == null) { | |||
invalid = new Address[0]; | |||
} | |||
for (Address address : invalid) { | |||
didntReach(address, "invalid", sfe); | |||
} | |||
Address[] validUnsent = sfe.getValidUnsentAddresses(); | |||
if (validUnsent == null) { | |||
validUnsent = new Address[0]; | |||
} | |||
for (Address address : validUnsent) { | |||
didntReach(address, "valid", sfe); | |||
} | |||
} | |||
} catch (final MessagingException e) { | |||
@@ -287,20 +288,17 @@ public class MimeMailer extends Mailer { | |||
} | |||
} | |||
private static InternetAddress[] internetAddresses(final Vector list) | |||
private static InternetAddress[] internetAddresses(final Vector<EmailAddress> list) | |||
throws AddressException, UnsupportedEncodingException { | |||
final int size = list.size(); | |||
final InternetAddress[] addrs = new InternetAddress[size]; | |||
for (int i = 0; i < size; ++i) { | |||
final EmailAddress addr = (EmailAddress) list.elementAt(i); | |||
final List<InternetAddress> addrs = new ArrayList<InternetAddress>(); | |||
for (final EmailAddress addr : list) { | |||
final String name = addr.getName(); | |||
addrs[i] = (name == null) | |||
addrs.add((name == null) | |||
? new InternetAddress(addr.getAddress()) | |||
: new InternetAddress(addr.getAddress(), name); | |||
: new InternetAddress(addr.getAddress(), name)); | |||
} | |||
return addrs; | |||
return addrs.toArray(new InternetAddress[addrs.size()]); | |||
} | |||
private String parseCharSetFromMimeType(final String type) { | |||
@@ -103,13 +103,13 @@ public class VmsCommandLauncher extends Java13CommandLauncher { | |||
// add the environment as logicals to the DCL script | |||
if (env != null) { | |||
int eqIndex; | |||
for (int i = 0; i < env.length; i++) { | |||
eqIndex = env[i].indexOf('='); | |||
for (String variable : env) { | |||
eqIndex = variable.indexOf('='); | |||
if (eqIndex != -1) { | |||
out.write("$ DEFINE/NOLOG "); | |||
out.write(env[i].substring(0, eqIndex)); | |||
out.write(variable.substring(0, eqIndex)); | |||
out.write(" \""); | |||
out.write(env[i].substring(eqIndex + 1)); | |||
out.write(variable.substring(eqIndex + 1)); | |||
out.write('\"'); | |||
out.newLine(); | |||
} | |||
@@ -254,10 +254,10 @@ public class Native2Ascii extends MatchingTask { | |||
String message = "Converting " + count + " file" | |||
+ (count != 1 ? "s" : "") + " from "; | |||
log(message + srcDir + " to " + destDir); | |||
for (int i = 0; i < files.length; i++) { | |||
String[] dest = m.mapFileName(files[i]); | |||
for (String file : files) { | |||
String[] dest = m.mapFileName(file); | |||
if (dest != null && dest.length > 0) { | |||
convert(files[i], dest[0]); | |||
convert(file, dest[0]); | |||
} | |||
} | |||
} | |||
@@ -29,7 +29,7 @@ import java.io.OutputStream; | |||
import java.lang.reflect.Field; | |||
import java.net.URL; | |||
import java.util.ArrayList; | |||
import java.util.Enumeration; | |||
import java.util.Collections; | |||
import java.util.HashMap; | |||
import java.util.Hashtable; | |||
import java.util.List; | |||
@@ -122,7 +122,7 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||
private URIResolver uriResolver; | |||
/** transformer output properties */ | |||
private final Vector outputProperties = new Vector(); | |||
private final Vector<String[]> outputProperties = new Vector<String[]>(); | |||
/** stylesheet parameters */ | |||
private final Hashtable<String, Object> params = new Hashtable<String, Object>(); | |||
@@ -334,9 +334,7 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||
if (uriResolver != null) { | |||
transformer.setURIResolver(uriResolver); | |||
} | |||
final int size = outputProperties.size(); | |||
for (int i = 0; i < size; i++) { | |||
final String[] pair = (String[]) outputProperties.elementAt(i); | |||
for (String[] pair : outputProperties) { | |||
transformer.setOutputProperty(pair[0], pair[1]); | |||
} | |||
@@ -376,11 +374,8 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||
* Sets the parameters for the transformer. | |||
*/ | |||
private void setTransformationParameters() { | |||
for (final Enumeration enumeration = params.keys(); | |||
enumeration.hasMoreElements();) { | |||
final String name = (String) enumeration.nextElement(); | |||
final Object value = params.get(name); | |||
transformer.setParameter(name, value); | |||
for (Map.Entry<String, Object> entry : params.entrySet()) { | |||
transformer.setParameter(entry.getKey(), entry.getValue()); | |||
} | |||
} | |||
@@ -435,8 +430,7 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||
// specific attributes for the transformer | |||
final int size = attributes.size(); | |||
for (int i = 0; i < size; i++) { | |||
final Object[] pair = attributes.get(i); | |||
for (final Object[] pair : attributes) { | |||
tfactory.setAttribute((String) pair[0], pair[1]); | |||
} | |||
@@ -636,10 +630,8 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||
setFactory(factory.getName()); | |||
// configure factory attributes | |||
for (final Enumeration attrs = factory.getAttributes(); | |||
attrs.hasMoreElements();) { | |||
final XSLTProcess.Factory.Attribute attr = | |||
(XSLTProcess.Factory.Attribute) attrs.nextElement(); | |||
for (final XSLTProcess.Factory.Attribute attr | |||
: Collections.list(factory.getAttributes())) { | |||
setAttribute(attr.getName(), attr.getValue()); | |||
} | |||
for (final XSLTProcess.Factory.Feature feature | |||
@@ -657,10 +649,8 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||
// configure output properties | |||
for (final Enumeration props = xsltTask.getOutputProperties(); | |||
props.hasMoreElements();) { | |||
final XSLTProcess.OutputProperty prop | |||
= (XSLTProcess.OutputProperty) props.nextElement(); | |||
for (final XSLTProcess.OutputProperty prop | |||
: Collections.list(xsltTask.getOutputProperties())) { | |||
setOutputProperty(prop.getName(), prop.getValue()); | |||
} | |||
@@ -74,7 +74,7 @@ public class XMLValidateTask extends Task { | |||
/** file to be validated */ | |||
protected File file = null; | |||
/** sets of file to be validated */ | |||
protected Vector filesets = new Vector(); | |||
protected Vector<FileSet> filesets = new Vector<FileSet>(); | |||
protected Path classpath; | |||
/** | |||
@@ -90,12 +90,12 @@ public class XMLValidateTask extends Task { | |||
// CheckStyle:VisibilityModifier ON | |||
/** The vector to store all attributes (features) to be set on the parser. **/ | |||
private Vector attributeList = new Vector(); | |||
private Vector<Attribute> attributeList = new Vector<Attribute>(); | |||
/** | |||
* List of properties. | |||
*/ | |||
private final Vector propertyList = new Vector(); | |||
private final Vector<Property> propertyList = new Vector<Property>(); | |||
private XMLCatalog xmlCatalog = new XMLCatalog(); | |||
/** Message for successful validation */ | |||
@@ -287,42 +287,35 @@ public class XMLValidateTask extends Task { | |||
*/ | |||
public void execute() throws BuildException { | |||
try { | |||
int fileProcessed = 0; | |||
if (file == null && (filesets.size() == 0)) { | |||
throw new BuildException( | |||
"Specify at least one source - " + "a file or a fileset."); | |||
} | |||
int fileProcessed = 0; | |||
if (file == null && (filesets.size() == 0)) { | |||
throw new BuildException( | |||
"Specify at least one source - " + "a file or a fileset."); | |||
} | |||
if (file != null) { | |||
if (file.exists() && file.canRead() && file.isFile()) { | |||
doValidate(file); | |||
fileProcessed++; | |||
} else { | |||
String errorMsg = "File " + file + " cannot be read"; | |||
if (failOnError) { | |||
throw new BuildException(errorMsg); | |||
if (file != null) { | |||
if (file.exists() && file.canRead() && file.isFile()) { | |||
doValidate(file); | |||
fileProcessed++; | |||
} else { | |||
log(errorMsg, Project.MSG_ERR); | |||
String errorMsg = "File " + file + " cannot be read"; | |||
if (failOnError) { | |||
throw new BuildException(errorMsg); | |||
} else { | |||
log(errorMsg, Project.MSG_ERR); | |||
} | |||
} | |||
} | |||
} | |||
final int size = filesets.size(); | |||
for (int i = 0; i < size; i++) { | |||
FileSet fs = (FileSet) filesets.elementAt(i); | |||
DirectoryScanner ds = fs.getDirectoryScanner(getProject()); | |||
String[] files = ds.getIncludedFiles(); | |||
for (int j = 0; j < files.length; j++) { | |||
File srcFile = new File(fs.getDir(getProject()), files[j]); | |||
doValidate(srcFile); | |||
fileProcessed++; | |||
for (FileSet fs : filesets) { | |||
DirectoryScanner ds = fs.getDirectoryScanner(getProject()); | |||
for (String fileName : ds.getIncludedFiles()) { | |||
File srcFile = new File(fs.getDir(getProject()), fileName); | |||
doValidate(srcFile); | |||
fileProcessed++; | |||
} | |||
} | |||
} | |||
onSuccessfulValidation(fileProcessed); | |||
onSuccessfulValidation(fileProcessed); | |||
} finally { | |||
cleanup(); | |||
} | |||
@@ -355,16 +348,12 @@ public class XMLValidateTask extends Task { | |||
setFeature(XmlConstants.FEATURE_VALIDATION, true); | |||
} | |||
// set the feature from the attribute list | |||
final int attSize = attributeList.size(); | |||
for (int i = 0; i < attSize; i++) { | |||
Attribute feature = (Attribute) attributeList.elementAt(i); | |||
for (Attribute feature : attributeList) { | |||
setFeature(feature.getName(), feature.getValue()); | |||
} | |||
// Sets properties | |||
final int propSize = propertyList.size(); | |||
for (int i = 0; i < propSize; i++) { | |||
final Property prop = (Property) propertyList.elementAt(i); | |||
for (Property prop : propertyList) { | |||
setProperty(prop.getName(), prop.getValue()); | |||
} | |||
} | |||
@@ -286,16 +286,16 @@ public class IPlanetDeploymentTool extends GenericDeploymentTool { | |||
int endOfPath = descriptorFileName.lastIndexOf(File.separator); | |||
String relativePath = descriptorFileName.substring(0, endOfPath + 1); | |||
for (int i = 0; i < cmpDescriptors.length; i++) { | |||
int endOfCmp = cmpDescriptors[i].lastIndexOf('/'); | |||
String cmpDescriptor = cmpDescriptors[i].substring(endOfCmp + 1); | |||
for (String descriptor : cmpDescriptors) { | |||
int endOfCmp = descriptor.lastIndexOf('/'); | |||
String cmpDescriptor = descriptor.substring(endOfCmp + 1); | |||
File cmpFile = new File(baseDir, relativePath + cmpDescriptor); | |||
if (!cmpFile.exists()) { | |||
throw new BuildException("The CMP descriptor file (" | |||
+ cmpFile + ") could not be found.", getLocation()); | |||
} | |||
files.put(cmpDescriptors[i], cmpFile); | |||
files.put(descriptor, cmpFile); | |||
} | |||
} | |||
@@ -28,7 +28,6 @@ import java.util.ArrayList; | |||
import java.util.Date; | |||
import java.util.HashMap; | |||
import java.util.Hashtable; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.Properties; | |||
@@ -898,7 +897,7 @@ public class IPlanetEjbc { | |||
private boolean cmp = false; // Does this EJB support CMP? | |||
private boolean iiop = false; // Does this EJB support IIOP? | |||
private boolean hasession = false; // Does this EJB require failover? | |||
private List cmpDescriptors = new ArrayList(); // CMP descriptor list | |||
private List<String> cmpDescriptors = new ArrayList<String>(); // CMP descriptor list | |||
/** | |||
* Construct a new EJBInfo object with the given name. | |||
@@ -1233,10 +1232,8 @@ public class IPlanetEjbc { | |||
* Loop through each stub/skeleton class that must be generated, and | |||
* determine (if all exist) which file has the most recent timestamp | |||
*/ | |||
for (int i = 0; i < classnames.length; i++) { | |||
String pathToClass = | |||
classnames[i].replace('.', File.separatorChar) + ".class"; | |||
for (String classname : classnames) { | |||
String pathToClass = classname.replace('.', File.separatorChar) + ".class"; | |||
File classFile = new File(destDir, pathToClass); | |||
/* | |||
@@ -1330,9 +1327,8 @@ public class IPlanetEjbc { | |||
+ "\n\r iiop: " + iiop | |||
+ "\n\r hasession: " + hasession; | |||
Iterator i = cmpDescriptors.iterator(); | |||
while (i.hasNext()) { | |||
s += "\n\r CMP Descriptor: " + i.next(); | |||
for (String cmpDescriptor : cmpDescriptors) { | |||
s += "\n\r CMP Descriptor: " + cmpDescriptor; | |||
} | |||
return s; | |||
@@ -109,9 +109,8 @@ public final class ExtensionUtil { | |||
final DirectoryScanner scanner = fileSet.getDirectoryScanner(project); | |||
final File basedir = scanner.getBasedir(); | |||
final String[] files = scanner.getIncludedFiles(); | |||
for (int i = 0; i < files.length; i++) { | |||
final File file = new File(basedir, files[ i ]); | |||
for (String fileName : scanner.getIncludedFiles()) { | |||
final File file = new File(basedir, fileName); | |||
loadExtensions(file, extensions, includeImpl, includeURL); | |||
} | |||
} | |||
@@ -71,32 +71,28 @@ class LibraryDisplayer { | |||
printLine(size); | |||
if (0 != available.length) { | |||
System.out.println("Extensions Supported By Library:"); | |||
for (int i = 0; i < available.length; i++) { | |||
final Extension extension = available[ i ]; | |||
System.out.println(extension.toString()); | |||
for (Extension extension : available) { | |||
System.out.println(extension); | |||
} | |||
} | |||
if (0 != required.length) { | |||
System.out.println("Extensions Required By Library:"); | |||
for (int i = 0; i < required.length; i++) { | |||
final Extension extension = required[ i ]; | |||
System.out.println(extension.toString()); | |||
for (Extension extension : required) { | |||
System.out.println(extension); | |||
} | |||
} | |||
if (0 != options.length) { | |||
System.out.println("Extensions that will be used by Library if present:"); | |||
for (int i = 0; i < options.length; i++) { | |||
final Extension extension = options[ i ]; | |||
System.out.println(extension.toString()); | |||
for (Extension option : options) { | |||
System.out.println(option); | |||
} | |||
} | |||
if (0 != specifications.length) { | |||
System.out.println("Specifications Supported By Library:"); | |||
for (int i = 0; i < specifications.length; i++) { | |||
final Specification specification = specifications[ i ]; | |||
for (Specification specification : specifications) { | |||
displaySpecification(specification); | |||
} | |||
} | |||
@@ -500,10 +500,9 @@ public class Translate extends MatchingTask { | |||
for (int i = 0; i < size; i++) { | |||
FileSet fs = (FileSet) filesets.elementAt(i); | |||
DirectoryScanner ds = fs.getDirectoryScanner(getProject()); | |||
String[] srcFiles = ds.getIncludedFiles(); | |||
for (int j = 0; j < srcFiles.length; j++) { | |||
for (String srcFile : ds.getIncludedFiles()) { | |||
try { | |||
File dest = FILE_UTILS.resolveFile(toDir, srcFiles[j]); | |||
File dest = FILE_UTILS.resolveFile(toDir, srcFile); | |||
//Make sure parent dirs exist, else, create them. | |||
try { | |||
File destDir = new File(dest.getParent()); | |||
@@ -516,7 +515,7 @@ public class Translate extends MatchingTask { | |||
Project.MSG_DEBUG); | |||
} | |||
destLastModified = dest.lastModified(); | |||
File src = FILE_UTILS.resolveFile(ds.getBasedir(), srcFiles[j]); | |||
File src = FILE_UTILS.resolveFile(ds.getBasedir(), srcFile); | |||
srcLastModified = src.lastModified(); | |||
//Check to see if dest file has to be recreated | |||
boolean needsWork = forceOverwrite | |||
@@ -530,14 +529,12 @@ public class Translate extends MatchingTask { | |||
} | |||
} | |||
if (needsWork) { | |||
log("Processing " + srcFiles[j], | |||
Project.MSG_DEBUG); | |||
log("Processing " + srcFile, Project.MSG_DEBUG); | |||
translateOneFile(src, dest); | |||
++filesProcessed; | |||
} else { | |||
log("Skipping " + srcFiles[j] | |||
+ " as destination file is up to date", | |||
Project.MSG_VERBOSE); | |||
log("Skipping " + srcFile + " as destination file is up to date", | |||
Project.MSG_VERBOSE); | |||
} | |||
} catch (IOException ioe) { | |||
throw new BuildException(ioe.getMessage(), getLocation()); | |||
@@ -223,8 +223,7 @@ public class Image extends MatchingTask { | |||
final File dstDir, final FileNameMapper mapper) { | |||
int writeCount = 0; | |||
for (int i = 0; i < srcNames.length; ++i) { | |||
final String srcName = srcNames[i]; | |||
for (final String srcName : srcNames) { | |||
final File srcFile = new File(srcDir, srcName).getAbsoluteFile(); | |||
final String[] dstNames = mapper.mapFileName(srcName); | |||
@@ -279,10 +279,7 @@ public class jlink { | |||
*/ | |||
private void addDirContents(ZipOutputStream output, File dir, String prefix, | |||
boolean compress) throws IOException { | |||
String[] contents = dir.list(); | |||
for (int i = 0; i < contents.length; ++i) { | |||
String name = contents[i]; | |||
for (String name : dir.list()) { | |||
File file = new File(dir, name); | |||
if (file.isDirectory()) { | |||
@@ -481,8 +481,8 @@ public class JspC extends MatchingTask { | |||
// lists and compile lists | |||
resetFileLists(); | |||
int filecount = 0; | |||
for (int i = 0; i < list.length; i++) { | |||
File srcDir = getProject().resolveFile(list[i]); | |||
for (String fileName : list) { | |||
File srcDir = getProject().resolveFile(fileName); | |||
if (!srcDir.exists()) { | |||
throw new BuildException("srcdir \"" + srcDir.getPath() | |||
+ "\" does not exist!", | |||
@@ -112,8 +112,8 @@ public final class BatchTest extends BaseTest { | |||
void addTestsTo(Vector v) { | |||
JUnitTest[] tests = createAllJUnitTest(); | |||
v.ensureCapacity(v.size() + tests.length); | |||
for (int i = 0; i < tests.length; i++) { | |||
v.addElement(tests[i]); | |||
for (JUnitTest test : tests) { | |||
v.addElement(test); | |||
} | |||
} | |||
@@ -24,7 +24,6 @@ import java.io.IOException; | |||
import java.io.OutputStream; | |||
import java.text.SimpleDateFormat; | |||
import java.util.Date; | |||
import java.util.Iterator; | |||
import java.util.SortedSet; | |||
import java.util.TreeSet; | |||
import java.util.Vector; | |||
@@ -89,7 +88,7 @@ public class FailureRecorder extends ProjectComponent implements JUnitResultForm | |||
private static final String LOG_PREFIX = " [junit]"; | |||
/** Class names of failed tests without duplicates. */ | |||
private static SortedSet/*<TestInfos>*/ failedTests = new TreeSet(); | |||
private static SortedSet<TestInfos> failedTests = new TreeSet<TestInfos>(); | |||
/** A writer for writing the generated source to. */ | |||
private BufferedWriter writer; | |||
@@ -299,8 +298,7 @@ public class FailureRecorder extends ProjectComponent implements JUnitResultForm | |||
writer.newLine(); | |||
writer.write(" TestSuite suite = new TestSuite();"); | |||
writer.newLine(); | |||
for (Iterator iter = failedTests.iterator(); iter.hasNext();) { | |||
TestInfos testInfos = (TestInfos) iter.next(); | |||
for (TestInfos testInfos : failedTests) { | |||
writer.write(" suite.addTest("); | |||
writer.write(String.valueOf(testInfos)); | |||
writer.write(");"); | |||
@@ -137,9 +137,9 @@ public class JUnit4TestMethodAdapter implements Test { | |||
throw new IllegalArgumentException("methodNames is <null>"); | |||
} | |||
methodsListDescription = Description.createSuiteDescription(testClass); | |||
for (int i = 0; i < methodNames.length; i++) { | |||
for (String methodName : methodNames) { | |||
methodsListDescription.addChild( | |||
Description.createTestDescription(testClass, methodNames[i])); | |||
Description.createTestDescription(testClass, methodName)); | |||
} | |||
this.testClass = testClass; | |||
this.methodNames = methodNames; | |||
@@ -176,12 +176,11 @@ public class JUnit4TestMethodAdapter implements Test { | |||
if (methodNames.length == 0) { | |||
buf.append("No methods"); | |||
} else { | |||
buf.append(methodNames.length == 1 ? "Method" : "Methods"); | |||
buf.append(' '); | |||
buf.append(methodNames[0]); | |||
for (int i = 1; i < methodNames.length; i++) { | |||
buf.append(',').append(methodNames[i]); | |||
buf.append(methodNames.length == 1 ? "Method " : "Methods "); | |||
for (String methodName : methodNames) { | |||
buf.append(methodName).append(','); | |||
} | |||
buf.setLength(buf.length() - 1); | |||
} | |||
buf.append('(').append(testClass.getName()).append(')'); | |||
return buf.toString(); | |||
@@ -34,6 +34,7 @@ import java.security.AccessController; | |||
import java.security.PrivilegedAction; | |||
import java.util.ArrayList; | |||
import java.util.Collection; | |||
import java.util.Collections; | |||
import java.util.Enumeration; | |||
import java.util.HashMap; | |||
import java.util.Hashtable; | |||
@@ -968,18 +969,13 @@ public class JUnitTask extends Task { | |||
/* I assume we don't want to do this with "per batch" forking. */ | |||
List<List> newlist = new ArrayList<List>(); | |||
if (forkMode.getValue().equals(ForkMode.PER_TEST)) { | |||
final Iterator<List> i1 = testList.iterator(); | |||
while (i1.hasNext()) { | |||
final List l = i1.next(); | |||
if (l.size() == 1) { | |||
newlist.add(l); | |||
for (List<JUnitTest> list : testList) { | |||
if (list.size() == 1) { | |||
newlist.add(list); | |||
} else { | |||
final Iterator i2 = l.iterator(); | |||
while (i2.hasNext()) { | |||
final List tmpSingleton = new ArrayList(); | |||
tmpSingleton.add(i2.next()); | |||
newlist.add(tmpSingleton); | |||
} | |||
for (JUnitTest test : list) { | |||
newlist.add(Collections.singletonList(test)); | |||
} | |||
} | |||
} | |||
} else { | |||
@@ -1213,8 +1209,7 @@ public class JUnitTask extends Task { | |||
StringBuffer formatterArg = new StringBuffer(STRING_BUFFER_SIZE); | |||
final FormatterElement[] feArray = mergeFormatters(test); | |||
for (int i = 0; i < feArray.length; i++) { | |||
final FormatterElement fe = feArray[i]; | |||
for (final FormatterElement fe : feArray) { | |||
if (fe.shouldUse(this)) { | |||
formatterArg.append(Constants.FORMATTER); | |||
formatterArg.append(fe.getClassname()); | |||
@@ -1264,9 +1259,9 @@ public class JUnitTask extends Task { | |||
final String[] environment = env.getVariables(); | |||
if (environment != null) { | |||
for (int i = 0; i < environment.length; i++) { | |||
log("Setting environment variable: " + environment[i], | |||
Project.MSG_VERBOSE); | |||
for (String variable : environment) { | |||
log("Setting environment variable: " + variable, | |||
Project.MSG_VERBOSE); | |||
} | |||
} | |||
execute.setNewenvironment(newEnvironment); | |||
@@ -1635,9 +1630,7 @@ public class JUnitTask extends Task { | |||
runner.setPermissions(perm); | |||
final FormatterElement[] feArray = mergeFormatters(test); | |||
for (int i = 0; i < feArray.length; i++) { | |||
final FormatterElement fe = feArray[i]; | |||
for (final FormatterElement fe : mergeFormatters(test)) { | |||
if (fe.shouldUse(this)) { | |||
final File outFile = getOutput(fe, test); | |||
if (outFile != null) { | |||
@@ -1958,8 +1951,7 @@ public class JUnitTask extends Task { | |||
test.setCounts(1, 0, 1, 0); | |||
test.setProperties(getProject().getProperties()); | |||
for (int i = 0; i < feArray.length; i++) { | |||
final FormatterElement fe = feArray[i]; | |||
for (final FormatterElement fe : feArray) { | |||
if (fe.shouldUse(this)) { | |||
final JUnitTaskMirror.JUnitResultFormatterMirror formatter = | |||
fe.createFormatter(classLoader); | |||
@@ -364,9 +364,8 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
public void run() { | |||
res = new IgnoredTestResult(); | |||
res.addListener(wrapListener(this)); | |||
final int size = formatters.size(); | |||
for (int i = 0; i < size; i++) { | |||
res.addListener(wrapListener((TestListener) formatters.elementAt(i))); | |||
for (JUnitTaskMirror.JUnitResultFormatterMirror f : formatters) { | |||
res.addListener(wrapListener((TestListener) f)); | |||
} | |||
final ByteArrayOutputStream errStrm = new ByteArrayOutputStream(); | |||
@@ -507,9 +506,8 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
suite = TestSuite.createTest(testClass, methods[0]); | |||
} else { | |||
final TestSuite testSuite = new TestSuite(testClass.getName()); | |||
for (int i = 0; i < methods.length; i++) { | |||
testSuite.addTest( | |||
TestSuite.createTest(testClass, methods[i])); | |||
for (String method : methods) { | |||
testSuite.addTest(TestSuite.createTest(testClass, method)); | |||
} | |||
suite = testSuite; | |||
} | |||
@@ -527,9 +525,8 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
fireStartTestSuite(); | |||
startTestSuiteSuccess = true; | |||
if (exception != null) { // had an exception constructing suite | |||
final int formatterSize = formatters.size(); | |||
for (int i = 0; i < formatterSize; i++) { | |||
((TestListener) formatters.elementAt(i)).addError(null, exception); | |||
for (JUnitTaskMirror.JUnitResultFormatterMirror f : formatters) { | |||
((TestListener) f).addError(null, exception); | |||
} | |||
junitTest.setCounts(1, 0, 1, 0); | |||
junitTest.setRunTime(0); | |||
@@ -825,27 +822,22 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
} | |||
private void sendOutAndErr(final String out, final String err) { | |||
final int size = formatters.size(); | |||
for (int i = 0; i < size; i++) { | |||
final JUnitResultFormatter formatter = | |||
((JUnitResultFormatter) formatters.elementAt(i)); | |||
for (JUnitTaskMirror.JUnitResultFormatterMirror f : formatters) { | |||
final JUnitResultFormatter formatter = (JUnitResultFormatter) f; | |||
formatter.setSystemOutput(out); | |||
formatter.setSystemError(err); | |||
} | |||
} | |||
private void fireStartTestSuite() { | |||
final int size = formatters.size(); | |||
for (int i = 0; i < size; i++) { | |||
((JUnitResultFormatter) formatters.elementAt(i)).startTestSuite(junitTest); | |||
for (JUnitTaskMirror.JUnitResultFormatterMirror f : formatters) { | |||
((JUnitResultFormatter) f).startTestSuite(junitTest); | |||
} | |||
} | |||
private void fireEndTestSuite() { | |||
final int size = formatters.size(); | |||
for (int i = 0; i < size; i++) { | |||
((JUnitResultFormatter) formatters.elementAt(i)).endTestSuite(junitTest); | |||
for (JUnitTaskMirror.JUnitResultFormatterMirror f : formatters) { | |||
((JUnitResultFormatter) f).endTestSuite(junitTest); | |||
} | |||
} | |||
@@ -924,52 +916,52 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
args[0] = args[0].substring(Constants.TESTSFILE.length()); | |||
} | |||
for (int i = 1; i < args.length; i++) { | |||
if (args[i].startsWith(Constants.METHOD_NAMES)) { | |||
for (String arg : args) { | |||
if (arg.startsWith(Constants.METHOD_NAMES)) { | |||
try { | |||
final String methodsList = args[i].substring(Constants.METHOD_NAMES.length()); | |||
final String methodsList = arg.substring(Constants.METHOD_NAMES.length()); | |||
methods = JUnitTest.parseTestMethodNamesList(methodsList); | |||
} catch (final IllegalArgumentException ex) { | |||
System.err.println("Invalid specification of test method names: " + args[i]); | |||
System.err.println("Invalid specification of test method names: " + arg); | |||
System.exit(ERRORS); | |||
} | |||
} else if (args[i].startsWith(Constants.HALT_ON_ERROR)) { | |||
haltError = Project.toBoolean(args[i].substring(Constants.HALT_ON_ERROR.length())); | |||
} else if (args[i].startsWith(Constants.HALT_ON_FAILURE)) { | |||
haltFail = Project.toBoolean(args[i].substring(Constants.HALT_ON_FAILURE.length())); | |||
} else if (args[i].startsWith(Constants.FILTERTRACE)) { | |||
stackfilter = Project.toBoolean(args[i].substring(Constants.FILTERTRACE.length())); | |||
} else if (args[i].startsWith(Constants.CRASHFILE)) { | |||
crashFile = args[i].substring(Constants.CRASHFILE.length()); | |||
} else if (arg.startsWith(Constants.HALT_ON_ERROR)) { | |||
haltError = Project.toBoolean(arg.substring(Constants.HALT_ON_ERROR.length())); | |||
} else if (arg.startsWith(Constants.HALT_ON_FAILURE)) { | |||
haltFail = Project.toBoolean(arg.substring(Constants.HALT_ON_FAILURE.length())); | |||
} else if (arg.startsWith(Constants.FILTERTRACE)) { | |||
stackfilter = Project.toBoolean(arg.substring(Constants.FILTERTRACE.length())); | |||
} else if (arg.startsWith(Constants.CRASHFILE)) { | |||
crashFile = arg.substring(Constants.CRASHFILE.length()); | |||
registerTestCase(Constants.BEFORE_FIRST_TEST); | |||
} else if (args[i].startsWith(Constants.FORMATTER)) { | |||
} else if (arg.startsWith(Constants.FORMATTER)) { | |||
try { | |||
createAndStoreFormatter(args[i].substring(Constants.FORMATTER.length())); | |||
createAndStoreFormatter(arg.substring(Constants.FORMATTER.length())); | |||
} catch (final BuildException be) { | |||
System.err.println(be.getMessage()); | |||
System.exit(ERRORS); | |||
} | |||
} else if (args[i].startsWith(Constants.PROPSFILE)) { | |||
final FileInputStream in = new FileInputStream(args[i] | |||
} else if (arg.startsWith(Constants.PROPSFILE)) { | |||
final FileInputStream in = new FileInputStream(arg | |||
.substring(Constants.PROPSFILE.length())); | |||
props.load(in); | |||
in.close(); | |||
} else if (args[i].startsWith(Constants.SHOWOUTPUT)) { | |||
showOut = Project.toBoolean(args[i].substring(Constants.SHOWOUTPUT.length())); | |||
} else if (args[i].startsWith(Constants.LOGTESTLISTENEREVENTS)) { | |||
} else if (arg.startsWith(Constants.SHOWOUTPUT)) { | |||
showOut = Project.toBoolean(arg.substring(Constants.SHOWOUTPUT.length())); | |||
} else if (arg.startsWith(Constants.LOGTESTLISTENEREVENTS)) { | |||
logTestListenerEvents = Project.toBoolean( | |||
args[i].substring(Constants.LOGTESTLISTENEREVENTS.length())); | |||
} else if (args[i].startsWith(Constants.OUTPUT_TO_FORMATTERS)) { | |||
arg.substring(Constants.LOGTESTLISTENEREVENTS.length())); | |||
} else if (arg.startsWith(Constants.OUTPUT_TO_FORMATTERS)) { | |||
outputToFormat = Project.toBoolean( | |||
args[i].substring(Constants.OUTPUT_TO_FORMATTERS.length())); | |||
} else if (args[i].startsWith(Constants.LOG_FAILED_TESTS)) { | |||
arg.substring(Constants.OUTPUT_TO_FORMATTERS.length())); | |||
} else if (arg.startsWith(Constants.LOG_FAILED_TESTS)) { | |||
logFailedTests = Project.toBoolean( | |||
args[i].substring(Constants.LOG_FAILED_TESTS.length())); | |||
} else if (args[i].startsWith(Constants.SKIP_NON_TESTS)) { | |||
arg.substring(Constants.LOG_FAILED_TESTS.length())); | |||
} else if (arg.startsWith(Constants.SKIP_NON_TESTS)) { | |||
skipNonTests = Project.toBoolean( | |||
args[i].substring(Constants.SKIP_NON_TESTS.length())); | |||
} else if (args[i].startsWith(Constants.THREADID)) { | |||
antThreadID = Integer.parseInt(args[i].substring(Constants.THREADID.length())); | |||
arg.substring(Constants.SKIP_NON_TESTS.length())); | |||
} else if (arg.startsWith(Constants.THREADID)) { | |||
antThreadID = Integer.parseInt(arg.substring(Constants.THREADID.length())); | |||
} | |||
} | |||
@@ -1045,7 +1037,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
System.exit(returnCode); | |||
} | |||
private static Vector fromCmdLine = new Vector(); | |||
private static Vector<FormatterElement> fromCmdLine = new Vector<FormatterElement>(); | |||
private static void transferFormatters(final JUnitTestRunner runner, | |||
final JUnitTest test) { | |||
@@ -1079,9 +1071,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
registerTestCase(JUnitVersionHelper.getTestCaseName(arg0)); | |||
} | |||
}); | |||
final int size = fromCmdLine.size(); | |||
for (int i = 0; i < size; i++) { | |||
final FormatterElement fe = (FormatterElement) fromCmdLine.elementAt(i); | |||
for (FormatterElement fe : fromCmdLine) { | |||
if (multipleTests && fe.getUseFile()) { | |||
final File destFile = new File(test.getTodir(), | |||
test.getOutfile() + fe.getExtension()); | |||
@@ -1163,8 +1153,8 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||
} | |||
private static boolean filterLine(final String line) { | |||
for (int i = 0; i < DEFAULT_TRACE_FILTERS.length; i++) { | |||
if (line.indexOf(DEFAULT_TRACE_FILTERS[i]) != -1) { | |||
for (String filter : DEFAULT_TRACE_FILTERS) { | |||
if (line.indexOf(filter) != -1) { | |||
return true; | |||
} | |||
} | |||
@@ -42,7 +42,6 @@ import org.w3c.dom.Document; | |||
import org.w3c.dom.Element; | |||
import org.xml.sax.SAXException; | |||
/** | |||
* Aggregates all <junit> XML formatter testsuite data under | |||
* a specific directory and transforms the results via XSLT. | |||
@@ -244,15 +243,12 @@ public class XMLResultAggregator extends Task implements XMLConstants { | |||
generatedId = 0; | |||
// get all files and add them to the document | |||
File[] files = getFiles(); | |||
for (int i = 0; i < files.length; i++) { | |||
File file = files[i]; | |||
for (File file : getFiles()) { | |||
try { | |||
log("Parsing file: '" + file + "'", Project.MSG_VERBOSE); | |||
if (file.length() > 0) { | |||
Document testsuiteDoc | |||
= builder.parse( | |||
FileUtils.getFileUtils().toURI(files[i].getAbsolutePath())); | |||
Document testsuiteDoc = builder.parse(FileUtils | |||
.getFileUtils().toURI(file.getAbsolutePath())); | |||
Element elem = testsuiteDoc.getDocumentElement(); | |||
// make sure that this is REALLY a testsuite. | |||
if (TESTSUITE.equals(elem.getNodeName())) { | |||
@@ -74,10 +74,10 @@ public final class KaffeNative2Ascii extends DefaultNative2Ascii { | |||
* | |||
* @return null if neither class can get loaded. | |||
*/ | |||
private static Class getN2aClass() { | |||
for (int i = 0; i < N2A_CLASSNAMES.length; i++) { | |||
private static Class<?> getN2aClass() { | |||
for (String className : N2A_CLASSNAMES) { | |||
try { | |||
return Class.forName(N2A_CLASSNAMES[i]); | |||
return Class.forName(className); | |||
} catch (ClassNotFoundException cnfe) { | |||
// Ignore | |||
} | |||
@@ -240,7 +240,7 @@ public class FTP extends Task implements FTPTaskConfig { | |||
*/ | |||
public String getParent() { | |||
String result = ""; | |||
for(int i = 0; i < parts.length - 1; i++){ | |||
for (int i = 0; i < parts.length - 1; i++){ | |||
result += File.separatorChar + parts[i]; | |||
} | |||
return result; | |||
@@ -390,10 +390,10 @@ public class FTP extends Task implements FTPTaskConfig { | |||
Hashtable newroots = new Hashtable(); | |||
// put in the newroots vector the include patterns without | |||
// wildcard tokens | |||
for (int icounter = 0; icounter < includes.length; icounter++) { | |||
String newpattern = | |||
SelectorUtils.rtrimWildcardTokens(includes[icounter]); | |||
newroots.put(newpattern, includes[icounter]); | |||
for (String include : includes) { | |||
String newpattern | |||
= SelectorUtils.rtrimWildcardTokens(include); | |||
newroots.put(newpattern, include); | |||
} | |||
if (remotedir == null) { | |||
try { | |||
@@ -505,11 +505,10 @@ public class FTP extends Task implements FTPTaskConfig { | |||
ftp.changeToParentDirectory(); | |||
return; | |||
} | |||
for (int i = 0; i < newfiles.length; i++) { | |||
FTPFile file = newfiles[i]; | |||
for (FTPFile file : newfiles) { | |||
if (file != null | |||
&& !".".equals(file.getName()) | |||
&& !"..".equals(file.getName())) { | |||
&& !".".equals(file.getName()) | |||
&& !"..".equals(file.getName())) { | |||
String name = vpath + file.getName(); | |||
scannedDirs.put(name, new FTPFileProxy(file)); | |||
if (isFunctioningAsDirectory(ftp, dir, file)) { | |||
@@ -519,7 +518,7 @@ public class FTP extends Task implements FTPTaskConfig { | |||
slowScanAllowed = false; | |||
} else if (isIncluded(name)) { | |||
accountForIncludedDir(name, | |||
new AntFTPFile(ftp, file, completePath) , fast); | |||
new AntFTPFile(ftp, file, completePath), fast); | |||
} else { | |||
dirsNotIncluded.addElement(name); | |||
if (fast && couldHoldIncluded(name)) { | |||
@@ -750,14 +749,14 @@ public class FTP extends Task implements FTPTaskConfig { | |||
} | |||
} | |||
private String fiddleName(String origin) { | |||
StringBuffer result = new StringBuffer(); | |||
for (int icounter = 0; icounter < origin.length(); icounter++) { | |||
if (Character.isLowerCase(origin.charAt(icounter))) { | |||
result.append(Character.toUpperCase(origin.charAt(icounter))); | |||
} else if (Character.isUpperCase(origin.charAt(icounter))) { | |||
result.append(Character.toLowerCase(origin.charAt(icounter))); | |||
StringBuilder result = new StringBuilder(); | |||
for (char ch : origin.toCharArray()) { | |||
if (Character.isLowerCase(ch)) { | |||
result.append(Character.toUpperCase(ch)); | |||
} else if (Character.isUpperCase(ch)) { | |||
result.append(Character.toLowerCase(ch)); | |||
} else { | |||
result.append(origin.charAt(icounter)); | |||
result.append(ch); | |||
} | |||
} | |||
return result.toString(); | |||
@@ -805,7 +804,7 @@ public class FTP extends Task implements FTPTaskConfig { | |||
public AntFTPFile(AntFTPFile parent, String path) { | |||
this.parent = parent; | |||
this.client = parent.client; | |||
Vector pathElements = SelectorUtils.tokenizePath(path); | |||
Vector<String> pathElements = SelectorUtils.tokenizePath(path); | |||
try { | |||
boolean result = this.client.changeWorkingDirectory(parent.getAbsolutePath()); | |||
//this should not happen, except if parent has been deleted by another process | |||
@@ -817,9 +816,7 @@ public class FTP extends Task implements FTPTaskConfig { | |||
throw new BuildException("could not change working dir to " | |||
+ parent.curpwd); | |||
} | |||
final int size = pathElements.size(); | |||
for (int fcount = 0; fcount < size - 1; fcount++) { | |||
String currentPathElement = (String) pathElements.elementAt(fcount); | |||
for (String currentPathElement : pathElements) { | |||
try { | |||
boolean result = this.client.changeWorkingDirectory(currentPathElement); | |||
if (!result && !isCaseSensitive() | |||
@@ -836,12 +833,12 @@ public class FTP extends Task implements FTPTaskConfig { | |||
+ currentPathElement; | |||
} catch (IOException ioe) { | |||
throw new BuildException("could not change working dir to " | |||
+ (String) pathElements.elementAt(fcount) | |||
+ currentPathElement | |||
+ " from " + this.curpwd); | |||
} | |||
} | |||
String lastpathelement = (String) pathElements.elementAt(size - 1); | |||
String lastpathelement = pathElements.elementAt(pathElements.size() - 1); | |||
FTPFile [] theFiles = listFiles(this.curpwd); | |||
this.ftpFile = getFile(theFiles, lastpathelement); | |||
} | |||
@@ -855,14 +852,13 @@ public class FTP extends Task implements FTPTaskConfig { | |||
String soughtPathElement) { | |||
// we are already in the right path, so the second parameter | |||
// is false | |||
FTPFile[] theFiles = listFiles(parentPath, false); | |||
if (theFiles == null) { | |||
FTPFile[] files = listFiles(parentPath, false); | |||
if (files == null) { | |||
return null; | |||
} | |||
for (int icounter = 0; icounter < theFiles.length; icounter++) { | |||
if (theFiles[icounter] != null | |||
&& theFiles[icounter].getName().equalsIgnoreCase(soughtPathElement)) { | |||
return theFiles[icounter].getName(); | |||
for (FTPFile file : files) { | |||
if (file != null && file.getName().equalsIgnoreCase(soughtPathElement)) { | |||
return file.getName(); | |||
} | |||
} | |||
return null; | |||
@@ -1783,11 +1779,10 @@ public class FTP extends Task implements FTPTaskConfig { | |||
this.granularityMillis = | |||
this.timestampGranularity.getMilliseconds(action); | |||
} | |||
for (int i = 0; i < dsfiles.length; i++) { | |||
final String dsfile = dsfiles[i]; | |||
for (final String dsfile : dsfiles) { | |||
executeRetryable(h, new Retryable() { | |||
public void execute() throws IOException { | |||
switch (action) { | |||
public void execute() throws IOException { | |||
switch (action) { | |||
case SEND_FILES: | |||
sendFile(ftp, fdir, dsfile); | |||
break; | |||
@@ -1802,14 +1797,14 @@ public class FTP extends Task implements FTPTaskConfig { | |||
break; | |||
case CHMOD: | |||
doSiteCommand(ftp, "chmod " + chmod | |||
+ " " + resolveFile(dsfile)); | |||
+ " " + resolveFile(dsfile)); | |||
transferred++; | |||
break; | |||
default: | |||
throw new BuildException("unknown ftp action " + action); | |||
} | |||
} | |||
}, dsfile); | |||
} | |||
}, dsfile); | |||
} | |||
} | |||
} finally { | |||
@@ -1979,7 +1974,7 @@ public class FTP extends Task implements FTPTaskConfig { | |||
* find a suitable name for local and remote temporary file | |||
*/ | |||
private File findFileName(FTPClient ftp) { | |||
FTPFile [] theFiles = null; | |||
FTPFile[] files = null; | |||
final int maxIterations = 1000; | |||
for (int counter = 1; counter < maxIterations; counter++) { | |||
File localFile = FILE_UTILS.createTempFile( | |||
@@ -1988,12 +1983,11 @@ public class FTP extends Task implements FTPTaskConfig { | |||
String fileName = localFile.getName(); | |||
boolean found = false; | |||
try { | |||
if (theFiles == null) { | |||
theFiles = ftp.listFiles(); | |||
if (files == null) { | |||
files = ftp.listFiles(); | |||
} | |||
for (int counter2 = 0; counter2 < theFiles.length; counter2++) { | |||
if (theFiles[counter2] != null | |||
&& theFiles[counter2].getName().equals(fileName)) { | |||
for (FTPFile file : files) { | |||
if (file != null && file.getName().equals(fileName)) { | |||
found = true; | |||
break; | |||
} | |||
@@ -291,10 +291,10 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror { | |||
Hashtable newroots = new Hashtable(); | |||
// put in the newroots vector the include patterns without | |||
// wildcard tokens | |||
for (int icounter = 0; icounter < includes.length; icounter++) { | |||
for (String include : includes) { | |||
String newpattern = | |||
SelectorUtils.rtrimWildcardTokens(includes[icounter]); | |||
newroots.put(newpattern, includes[icounter]); | |||
SelectorUtils.rtrimWildcardTokens(include); | |||
newroots.put(newpattern, include); | |||
} | |||
if (task.getRemotedir() == null) { | |||
try { | |||
@@ -412,11 +412,10 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror { | |||
ftp.changeToParentDirectory(); | |||
return; | |||
} | |||
for (int i = 0; i < newfiles.length; i++) { | |||
FTPFile file = newfiles[i]; | |||
for (FTPFile file : newfiles) { | |||
if (file != null | |||
&& !file.getName().equals(".") | |||
&& !file.getName().equals("..")) { | |||
&& !".".equals(file.getName()) | |||
&& !"..".equals(file.getName())) { | |||
String name = vpath + file.getName(); | |||
scannedDirs.put(name, new FTPFileProxy(file)); | |||
if (isFunctioningAsDirectory(ftp, dir, file)) { | |||
@@ -426,7 +425,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror { | |||
slowScanAllowed = false; | |||
} else if (isIncluded(name)) { | |||
accountForIncludedDir(name, | |||
new AntFTPFile(ftp, file, completePath) , fast); | |||
new AntFTPFile(ftp, file, completePath), fast); | |||
} else { | |||
dirsNotIncluded.addElement(name); | |||
if (fast && couldHoldIncluded(name)) { | |||
@@ -482,9 +481,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror { | |||
* @param fast boolean | |||
*/ | |||
private void accountForIncludedDir(String name, AntFTPFile file, boolean fast) { | |||
if (!dirsIncluded.contains(name) | |||
&& !dirsExcluded.contains(name)) { | |||
if (!dirsIncluded.contains(name) && !dirsExcluded.contains(name)) { | |||
if (!isExcluded(name)) { | |||
if (fast) { | |||
if (file.isSymbolicLink()) { | |||
@@ -658,14 +655,14 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror { | |||
} | |||
} | |||
private String fiddleName(String origin) { | |||
StringBuffer result = new StringBuffer(); | |||
for (int icounter = 0; icounter < origin.length(); icounter++) { | |||
if (Character.isLowerCase(origin.charAt(icounter))) { | |||
result.append(Character.toUpperCase(origin.charAt(icounter))); | |||
} else if (Character.isUpperCase(origin.charAt(icounter))) { | |||
result.append(Character.toLowerCase(origin.charAt(icounter))); | |||
StringBuilder result = new StringBuilder(); | |||
for (char ch : origin.toCharArray()) { | |||
if (Character.isLowerCase(ch)) { | |||
result.append(Character.toUpperCase(ch)); | |||
} else if (Character.isUpperCase(ch)) { | |||
result.append(Character.toLowerCase(ch)); | |||
} else { | |||
result.append(origin.charAt(icounter)); | |||
result.append(ch); | |||
} | |||
} | |||
return result.toString(); | |||
@@ -713,7 +710,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror { | |||
public AntFTPFile(AntFTPFile parent, String path) { | |||
this.parent = parent; | |||
this.client = parent.client; | |||
Vector pathElements = SelectorUtils.tokenizePath(path); | |||
Vector<String> pathElements = SelectorUtils.tokenizePath(path); | |||
try { | |||
boolean result = this.client.changeWorkingDirectory(parent.getAbsolutePath()); | |||
//this should not happen, except if parent has been deleted by another process | |||
@@ -722,18 +719,15 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror { | |||
} | |||
this.curpwd = parent.getAbsolutePath(); | |||
} catch (IOException ioe) { | |||
throw new BuildException("could not change working dir to " | |||
+ parent.curpwd); | |||
throw new BuildException("could not change working dir to " + parent.curpwd); | |||
} | |||
final int size = pathElements.size(); | |||
for (int fcount = 0; fcount < size - 1; fcount++) { | |||
String currentPathElement = (String) pathElements.elementAt(fcount); | |||
for (String currentPathElement : pathElements) { | |||
try { | |||
boolean result = this.client.changeWorkingDirectory(currentPathElement); | |||
if (!result && !isCaseSensitive() | |||
&& (remoteSystemCaseSensitive || !remoteSensitivityChecked)) { | |||
currentPathElement = findPathElementCaseUnsensitive(this.curpwd, | |||
currentPathElement); | |||
currentPathElement); | |||
if (currentPathElement == null) { | |||
return; | |||
} | |||
@@ -744,14 +738,12 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror { | |||
+ currentPathElement; | |||
} catch (IOException ioe) { | |||
throw new BuildException("could not change working dir to " | |||
+ (String) pathElements.elementAt(fcount) | |||
+ " from " + this.curpwd); | |||
+ currentPathElement + " from " + this.curpwd); | |||
} | |||
} | |||
String lastpathelement = (String) pathElements.elementAt(size - 1); | |||
FTPFile [] theFiles = listFiles(this.curpwd); | |||
this.ftpFile = getFile(theFiles, lastpathelement); | |||
String lastpathelement = pathElements.get(pathElements.size() - 1); | |||
this.ftpFile = getFile(listFiles(this.curpwd), lastpathelement); | |||
} | |||
/** | |||
* find a file in a directory in case insensitive way | |||
@@ -763,14 +755,13 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror { | |||
String soughtPathElement) { | |||
// we are already in the right path, so the second parameter | |||
// is false | |||
FTPFile[] theFiles = listFiles(parentPath, false); | |||
if (theFiles == null) { | |||
FTPFile[] files = listFiles(parentPath, false); | |||
if (files == null) { | |||
return null; | |||
} | |||
for (int icounter = 0; icounter < theFiles.length; icounter++) { | |||
if (theFiles[icounter] != null | |||
&& theFiles[icounter].getName().equalsIgnoreCase(soughtPathElement)) { | |||
return theFiles[icounter].getName(); | |||
for (FTPFile file : files) { | |||
if (file != null && file.getName().equalsIgnoreCase(soughtPathElement)) { | |||
return file.getName(); | |||
} | |||
} | |||
return null; | |||
@@ -1174,8 +1165,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror { | |||
task.setGranularityMillis(task.getTimestampGranularity() | |||
.getMilliseconds(task.getAction())); | |||
} | |||
for (int i = 0; i < dsfiles.length; i++) { | |||
final String dsfile = dsfiles[i]; | |||
for (final String dsfile : dsfiles) { | |||
executeRetryable(h, new Retryable() { | |||
public void execute() throws IOException { | |||
switch (task.getAction()) { | |||
@@ -1373,7 +1363,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror { | |||
* find a suitable name for local and remote temporary file | |||
*/ | |||
private File findFileName(FTPClient ftp) { | |||
FTPFile [] theFiles = null; | |||
FTPFile[] files = null; | |||
final int maxIterations = 1000; | |||
for (int counter = 1; counter < maxIterations; counter++) { | |||
File localFile = FILE_UTILS.createTempFile( | |||
@@ -1382,12 +1372,11 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror { | |||
String fileName = localFile.getName(); | |||
boolean found = false; | |||
try { | |||
if (theFiles == null) { | |||
theFiles = ftp.listFiles(); | |||
if (files == null) { | |||
files = ftp.listFiles(); | |||
} | |||
for (int counter2 = 0; counter2 < theFiles.length; counter2++) { | |||
if (theFiles[counter2] != null | |||
&& theFiles[counter2].getName().equals(fileName)) { | |||
for (FTPFile file : files) { | |||
if (file != null && file.getName().equals(fileName)) { | |||
found = true; | |||
break; | |||
} | |||
@@ -147,10 +147,9 @@ public class SoundTask extends Task { | |||
if (source.exists()) { | |||
if (source.isDirectory()) { | |||
// get the list of files in the dir | |||
String[] entries = source.list(); | |||
Vector files = new Vector(); | |||
for (int i = 0; i < entries.length; i++) { | |||
File f = new File(source, entries[i]); | |||
Vector<File> files = new Vector<File>(); | |||
for (String file : source.list()) { | |||
File f = new File(source, file); | |||
if (f.isFile()) { | |||
files.addElement(f); | |||
} | |||
@@ -86,10 +86,9 @@ public class SSHSession extends SSHBase { | |||
* tunnel specifications | |||
*/ | |||
public void setLocaltunnels(final String tunnels) { | |||
final String[] specs = tunnels.split(", "); | |||
for (int i = 0; i < specs.length; i++) { | |||
if (specs[i].length() > 0) { | |||
final String[] spec = specs[i].split(":", 3); | |||
for (String tunnelSpec : tunnels.split(", ")) { | |||
if (tunnelSpec.length() > 0) { | |||
final String[] spec = tunnelSpec.split(":", 3); | |||
final int lport = Integer.parseInt(spec[0]); | |||
final String rhost = spec[1]; | |||
final int rport = Integer.parseInt(spec[2]); | |||
@@ -109,10 +108,9 @@ public class SSHSession extends SSHBase { | |||
* tunnel specifications | |||
*/ | |||
public void setRemotetunnels(final String tunnels) { | |||
final String[] specs = tunnels.split(", "); | |||
for (int i = 0; i < specs.length; i++) { | |||
if (specs[i].length() > 0) { | |||
final String[] spec = specs[i].split(":", 3); | |||
for (String tunnelSpec : tunnels.split(", ")) { | |||
if (tunnelSpec.length() > 0) { | |||
final String[] spec = tunnelSpec.split(":", 3); | |||
final int rport = Integer.parseInt(spec[0]); | |||
final String lhost = spec[1]; | |||
final int lport = Integer.parseInt(spec[2]); | |||
@@ -206,8 +206,8 @@ public abstract class DefaultRmicAdapter implements RmicAdapter { | |||
Commandline cmd = new Commandline(); | |||
if (options != null) { | |||
for (int i = 0; i < options.length; i++) { | |||
cmd.createArgument().setValue(options[i]); | |||
for (String option : options) { | |||
cmd.createArgument().setValue(option); | |||
} | |||
} | |||
@@ -329,13 +329,12 @@ public abstract class DefaultRmicAdapter implements RmicAdapter { | |||
*/ | |||
protected String[] filterJvmCompilerArgs(String[] compilerArgs) { | |||
int len = compilerArgs.length; | |||
List args = new ArrayList(len); | |||
for (int i = 0; i < len; i++) { | |||
String arg = compilerArgs[i]; | |||
if (!arg.startsWith("-J")) { | |||
args.add(arg); | |||
} else { | |||
List<String> args = new ArrayList<String>(len); | |||
for (String arg : compilerArgs) { | |||
if (arg.startsWith("-J")) { | |||
attributes.log("Dropping " + arg + " from compiler arguments"); | |||
} else { | |||
args.add(arg); | |||
} | |||
} | |||
int count = args.size(); | |||
@@ -60,15 +60,14 @@ public class KaffeRmic extends DefaultRmicAdapter { | |||
Class c = getRmicClass(); | |||
if (c == null) { | |||
StringBuffer buf = new StringBuffer("Cannot use Kaffe rmic, as it" | |||
+ " is not available. None" | |||
+ " of "); | |||
for (int i = 0; i < RMIC_CLASSNAMES.length; i++) { | |||
if (i != 0) { | |||
StringBuilder buf = new StringBuilder( | |||
"Cannot use Kaffe rmic, as it is not available. None of "); | |||
for (String className : RMIC_CLASSNAMES) { | |||
if (buf.length() > 0) { | |||
buf.append(", "); | |||
} | |||
buf.append(RMIC_CLASSNAMES[i]); | |||
buf.append(className); | |||
} | |||
buf.append(" have been found. A common solution is to set the" | |||
+ " environment variable JAVA_HOME or CLASSPATH."); | |||
@@ -101,10 +100,10 @@ public class KaffeRmic extends DefaultRmicAdapter { | |||
* | |||
* @return null if neither class can get loaded. | |||
*/ | |||
private static Class getRmicClass() { | |||
for (int i = 0; i < RMIC_CLASSNAMES.length; i++) { | |||
private static Class<?> getRmicClass() { | |||
for (String className : RMIC_CLASSNAMES) { | |||
try { | |||
return Class.forName(RMIC_CLASSNAMES[i]); | |||
return Class.forName(className); | |||
} catch (ClassNotFoundException cnfe) { | |||
// Ignore | |||
} | |||
@@ -277,8 +277,8 @@ public abstract class AbstractFileSet extends DataType | |||
throw tooManyAttributes(); | |||
} | |||
if (includes != null) { | |||
for (int i = 0; i < includes.length; i++) { | |||
defaultPatterns.createInclude().setName(includes[i]); | |||
for (String include : includes) { | |||
defaultPatterns.createInclude().setName(include); | |||
} | |||
directoryScanner = null; | |||
} | |||
@@ -312,8 +312,8 @@ public abstract class AbstractFileSet extends DataType | |||
throw tooManyAttributes(); | |||
} | |||
if (excludes != null) { | |||
for (int i = 0; i < excludes.length; i++) { | |||
defaultPatterns.createExclude().setName(excludes[i]); | |||
for (String exclude : excludes) { | |||
defaultPatterns.createExclude().setName(exclude); | |||
} | |||
directoryScanner = null; | |||
} | |||
@@ -354,8 +354,8 @@ public class Commandline implements Cloneable { | |||
* @param line an array of arguments to append. | |||
*/ | |||
public void addArguments(String[] line) { | |||
for (int i = 0; i < line.length; i++) { | |||
createArgument().setValue(line[i]); | |||
for (String l : line) { | |||
createArgument().setValue(l); | |||
} | |||
} | |||
@@ -398,13 +398,11 @@ public class Commandline implements Cloneable { | |||
* @since Ant 1.6 | |||
*/ | |||
public void addArgumentsToList(ListIterator<String> list) { | |||
final int size = arguments.size(); | |||
for (int i = 0; i < size; i++) { | |||
Argument arg = arguments.get(i); | |||
for (Argument arg : arguments) { | |||
String[] s = arg.getParts(); | |||
if (s != null) { | |||
for (int j = 0; j < s.length; j++) { | |||
list.add(s[j]); | |||
for (String value : s) { | |||
list.add(value); | |||
} | |||
} | |||
} | |||
@@ -108,8 +108,8 @@ public class CommandlineJava implements Cloneable { | |||
public void addDefinitionsToList(ListIterator<String> listIt) { | |||
String[] props = super.getVariables(); | |||
if (props != null) { | |||
for (int i = 0; i < props.length; i++) { | |||
listIt.add("-D" + props[i]); | |||
for (String prop : props) { | |||
listIt.add("-D" + prop); | |||
} | |||
} | |||
Properties propertySetProperties = mergePropertySets(); | |||
@@ -17,7 +17,6 @@ | |||
*/ | |||
package org.apache.tools.ant.types; | |||
import java.util.Iterator; | |||
import java.util.Stack; | |||
import java.util.Vector; | |||
@@ -405,8 +404,7 @@ public class FilterChain extends DataType { | |||
if (isReference()) { | |||
super.dieOnCircularReference(stk, p); | |||
} else { | |||
for (Iterator<Object> i = filterReaders.iterator(); i.hasNext();) { | |||
Object o = i.next(); | |||
for (Object o : filterReaders) { | |||
if (o instanceof DataType) { | |||
pushAndInvokeCircularReferenceCheck((DataType) o, stk, p); | |||
} | |||
@@ -228,9 +228,8 @@ public class FilterSet extends DataType implements Cloneable { | |||
//silly hack to avoid stack overflow... | |||
if (!readingFiles) { | |||
readingFiles = true; | |||
final int size = filtersFiles.size(); | |||
for (int i = 0; i < size; i++) { | |||
readFiltersFromFile(filtersFiles.get(i)); | |||
for (File filtersFile : filtersFiles) { | |||
readFiltersFromFile(filtersFile); | |||
} | |||
filtersFiles.clear(); | |||
readingFiles = false; | |||
@@ -20,6 +20,7 @@ package org.apache.tools.ant.types; | |||
import java.io.File; | |||
import java.lang.reflect.Method; | |||
import java.util.Arrays; | |||
import java.util.Collections; | |||
import java.util.Iterator; | |||
import java.util.Locale; | |||
@@ -326,17 +327,16 @@ public class Path extends DataType implements Cloneable, ResourceCollection { | |||
* @param tryUserDir if true try the user directory if the file is not present | |||
*/ | |||
public void addExisting(Path source, boolean tryUserDir) { | |||
String[] list = source.list(); | |||
File userDir = (tryUserDir) ? new File(System.getProperty("user.dir")) | |||
: null; | |||
for (int i = 0; i < list.length; i++) { | |||
File f = resolveFile(getProject(), list[i]); | |||
for (String name : source.list()) { | |||
File f = resolveFile(getProject(), name); | |||
// probably not the best choice, but it solves the problem of | |||
// relative paths in CLASSPATH | |||
if (tryUserDir && !f.exists()) { | |||
f = new File(userDir, list[i]); | |||
f = new File(userDir, name); | |||
} | |||
if (f.exists()) { | |||
setLocation(f); | |||
@@ -624,28 +624,25 @@ public class Path extends DataType implements Cloneable, ResourceCollection { | |||
+ File.separator + "rt.jar")); | |||
// Sun's and Apple's 1.4 have JCE and JSSE in separate jars. | |||
String[] secJars = {"jce", "jsse"}; | |||
for (int i = 0; i < secJars.length; i++) { | |||
for (String secJar : Arrays.asList("jce", "jsse")) { | |||
addExisting(new Path(null, | |||
System.getProperty("java.home") | |||
+ File.separator + "lib" | |||
+ File.separator + secJars[i] + ".jar")); | |||
System.getProperty("java.home") | |||
+ File.separator + "lib" | |||
+ File.separator + secJar + ".jar")); | |||
addExisting(new Path(null, | |||
System.getProperty("java.home") | |||
+ File.separator + ".." | |||
+ File.separator + "Classes" | |||
+ File.separator + secJars[i] + ".jar")); | |||
System.getProperty("java.home") | |||
+ File.separator + ".." | |||
+ File.separator + "Classes" | |||
+ File.separator + secJar + ".jar")); | |||
} | |||
// IBM's 1.4 has rt.jar split into 4 smaller jars and a combined | |||
// JCE/JSSE in security.jar. | |||
String[] ibmJars | |||
= {"core", "graphics", "security", "server", "xml"}; | |||
for (int i = 0; i < ibmJars.length; i++) { | |||
for (String ibmJar : Arrays.asList("core", "graphics", "security", "server", "xml")) { | |||
addExisting(new Path(null, | |||
System.getProperty("java.home") | |||
+ File.separator + "lib" | |||
+ File.separator + ibmJars[i] + ".jar")); | |||
System.getProperty("java.home") | |||
+ File.separator + "lib" | |||
+ File.separator + ibmJar + ".jar")); | |||
} | |||
// Added for MacOS X | |||
@@ -679,9 +676,8 @@ public class Path extends DataType implements Cloneable, ResourceCollection { | |||
} | |||
} | |||
String[] dirs = extdirs.list(); | |||
for (int i = 0; i < dirs.length; i++) { | |||
File dir = resolveFile(getProject(), dirs[i]); | |||
for (String d : extdirs.list()) { | |||
File dir = resolveFile(getProject(), d); | |||
if (dir.exists() && dir.isDirectory()) { | |||
FileSet fs = new FileSet(); | |||
fs.setDir(dir); | |||
@@ -266,13 +266,13 @@ public class PatternSet extends DataType implements Cloneable { | |||
String[] nestedExcludes = p.getExcludePatterns(getProject()); | |||
if (nestedIncludes != null) { | |||
for (int i = 0; i < nestedIncludes.length; i++) { | |||
createInclude().setName(nestedIncludes[i]); | |||
for (String nestedInclude : nestedIncludes) { | |||
createInclude().setName(nestedInclude); | |||
} | |||
} | |||
if (nestedExcludes != null) { | |||
for (int i = 0; i < nestedExcludes.length; i++) { | |||
createExclude().setName(nestedExcludes[i]); | |||
for (String nestedExclude : nestedExcludes) { | |||
createExclude().setName(nestedExclude); | |||
} | |||
} | |||
} | |||
@@ -447,14 +447,14 @@ public class PatternSet extends DataType implements Cloneable { | |||
dieOnCircularReference(p); | |||
String[] incl = other.getIncludePatterns(p); | |||
if (incl != null) { | |||
for (int i = 0; i < incl.length; i++) { | |||
createInclude().setName(incl[i]); | |||
for (String include : incl) { | |||
createInclude().setName(include); | |||
} | |||
} | |||
String[] excl = other.getExcludePatterns(p); | |||
if (excl != null) { | |||
for (int i = 0; i < excl.length; i++) { | |||
createExclude().setName(excl[i]); | |||
for (String exclude : excl) { | |||
createExclude().setName(exclude); | |||
} | |||
} | |||
} | |||
@@ -120,8 +120,8 @@ public class Quantifier extends EnumeratedAttribute { | |||
*/ | |||
public boolean evaluate(boolean[] b) { | |||
int t = 0; | |||
for (int i = 0; i < b.length; i++) { | |||
if (b[i]) { | |||
for (boolean bn : b) { | |||
if (bn) { | |||
t++; | |||
} | |||
} | |||
@@ -573,12 +573,12 @@ public class RedirectorElement extends DataType { | |||
} | |||
//remove any null elements | |||
ArrayList<File> list = new ArrayList<File>(name.length); | |||
for (int i = 0; i < name.length; i++) { | |||
if (name[i] != null) { | |||
list.add(getProject().resolveFile(name[i])); | |||
for (String n : name) { | |||
if (n != null) { | |||
list.add(getProject().resolveFile(n)); | |||
} | |||
} | |||
return (File[]) (list.toArray(new File[list.size()])); | |||
return list.toArray(new File[list.size()]); | |||
} | |||
/** | |||
@@ -596,11 +596,10 @@ public class RedirectorElement extends DataType { | |||
if (isReference()) { | |||
super.dieOnCircularReference(stk, p); | |||
} else { | |||
Mapper[] m = new Mapper[] {inputMapper, outputMapper, errorMapper}; | |||
for (int i = 0; i < m.length; i++) { | |||
if (m[i] != null) { | |||
stk.push(m[i]); | |||
m[i].dieOnCircularReference(stk, p); | |||
for (Mapper m : Arrays.asList(inputMapper, outputMapper, errorMapper)) { | |||
if (m != null) { | |||
stk.push(m); | |||
m.dieOnCircularReference(stk, p); | |||
stk.pop(); | |||
} | |||
} | |||
@@ -1105,14 +1105,13 @@ public class XMLCatalog extends DataType | |||
if (catPath != null) { | |||
log("Using catalogpath '" + getCatalogPath() + "'", | |||
Project.MSG_DEBUG); | |||
String[] catPathList = getCatalogPath().list(); | |||
for (int i = 0; i < catPathList.length; i++) { | |||
File catFile = new File(catPathList[i]); | |||
for (String catFileName : getCatalogPath().list()) { | |||
File catFile = new File(catFileName); | |||
log("Parsing " + catFile, Project.MSG_DEBUG); | |||
try { | |||
parseCatalog.invoke(resolverImpl, | |||
new Object[] {catFile.getPath()}); | |||
new Object[]{catFile.getPath()}); | |||
} catch (Exception ex) { | |||
throw new BuildException(ex); | |||
} | |||
@@ -129,10 +129,9 @@ public class ClassfileSet extends FileSet { | |||
for (FileSet additionalRootSet : rootFileSets) { | |||
DirectoryScanner additionalScanner | |||
= additionalRootSet.getDirectoryScanner(p); | |||
String[] files = additionalScanner.getIncludedFiles(); | |||
for (int i = 0; i < files.length; ++i) { | |||
if (files[i].endsWith(".class")) { | |||
String classFilePath = StringUtils.removeSuffix(files[i], ".class"); | |||
for (String file : additionalScanner.getIncludedFiles()) { | |||
if (file.endsWith(".class")) { | |||
String classFilePath = StringUtils.removeSuffix(file, ".class"); | |||
String className | |||
= classFilePath.replace('/', '.').replace('\\', '.'); | |||
allRootClasses.addElement(className); | |||
@@ -54,8 +54,8 @@ public class BZip2Resource extends CompressedResource { | |||
* @throws IOException if there is a problem. | |||
*/ | |||
protected InputStream wrapStream(InputStream in) throws IOException { | |||
for (int i = 0; i < MAGIC.length; i++) { | |||
if (in.read() != MAGIC[i]) { | |||
for (char ch : MAGIC) { | |||
if (in.read() != ch) { | |||
throw new IOException("Invalid bz2 stream."); | |||
} | |||
} | |||
@@ -69,8 +69,8 @@ public class BZip2Resource extends CompressedResource { | |||
* @throws IOException if there is a problem. | |||
*/ | |||
protected OutputStream wrapStream(OutputStream out) throws IOException { | |||
for (int i = 0; i < MAGIC.length; i++) { | |||
out.write(MAGIC[i]); | |||
for (char ch : MAGIC) { | |||
out.write(ch); | |||
} | |||
return new CBZip2OutputStream(out); | |||
} | |||
@@ -181,8 +181,8 @@ public class Files extends AbstractSelectorContainer | |||
public synchronized void appendIncludes(String[] includes) { | |||
checkAttributesAllowed(); | |||
if (includes != null) { | |||
for (int i = 0; i < includes.length; i++) { | |||
defaultPatterns.createInclude().setName(includes[i]); | |||
for (String include : includes) { | |||
defaultPatterns.createInclude().setName(include); | |||
} | |||
ds = null; | |||
} | |||
@@ -211,8 +211,8 @@ public class Files extends AbstractSelectorContainer | |||
public synchronized void appendExcludes(String[] excludes) { | |||
checkAttributesAllowed(); | |||
if (excludes != null) { | |||
for (int i = 0; i < excludes.length; i++) { | |||
defaultPatterns.createExclude().setName(excludes[i]); | |||
for (String exclude : excludes) { | |||
defaultPatterns.createExclude().setName(exclude); | |||
} | |||
ds = null; | |||
} | |||
@@ -119,17 +119,16 @@ public class ContainsRegexpSelector extends BaseExtendSelector | |||
public void setParameters(Parameter[] parameters) { | |||
super.setParameters(parameters); | |||
if (parameters != null) { | |||
for (int i = 0; i < parameters.length; i++) { | |||
String paramname = parameters[i].getName(); | |||
for (Parameter parameter : parameters) { | |||
String paramname = parameter.getName(); | |||
if (EXPRESSION_KEY.equalsIgnoreCase(paramname)) { | |||
setExpression(parameters[i].getValue()); | |||
setExpression(parameter.getValue()); | |||
} else if (CS_KEY.equalsIgnoreCase(paramname)) { | |||
setCaseSensitive(Project | |||
.toBoolean(parameters[i].getValue())); | |||
setCaseSensitive(Project.toBoolean(parameter.getValue())); | |||
} else if (ML_KEY.equalsIgnoreCase(paramname)) { | |||
setMultiLine(Project.toBoolean(parameters[i].getValue())); | |||
setMultiLine(Project.toBoolean(parameter.getValue())); | |||
} else if (SL_KEY.equalsIgnoreCase(paramname)) { | |||
setSingleLine(Project.toBoolean(parameters[i].getValue())); | |||
setSingleLine(Project.toBoolean(parameter.getValue())); | |||
} else { | |||
setError("Invalid parameter " + paramname); | |||
} | |||
@@ -120,16 +120,16 @@ public class ContainsSelector extends BaseExtendSelector implements ResourceSele | |||
public void setParameters(Parameter[] parameters) { | |||
super.setParameters(parameters); | |||
if (parameters != null) { | |||
for (int i = 0; i < parameters.length; i++) { | |||
String paramname = parameters[i].getName(); | |||
for (Parameter parameter : parameters) { | |||
String paramname = parameter.getName(); | |||
if (CONTAINS_KEY.equalsIgnoreCase(paramname)) { | |||
setText(parameters[i].getValue()); | |||
setText(parameter.getValue()); | |||
} else if (CASE_KEY.equalsIgnoreCase(paramname)) { | |||
setCasesensitive(Project.toBoolean( | |||
parameters[i].getValue())); | |||
parameter.getValue())); | |||
} else if (WHITESPACE_KEY.equalsIgnoreCase(paramname)) { | |||
setIgnorewhitespace(Project.toBoolean( | |||
parameters[i].getValue())); | |||
parameter.getValue())); | |||
} else { | |||
setError("Invalid parameter " + paramname); | |||
} | |||
@@ -169,30 +169,30 @@ public class DateSelector extends BaseExtendSelector { | |||
public void setParameters(Parameter[] parameters) { | |||
super.setParameters(parameters); | |||
if (parameters != null) { | |||
for (int i = 0; i < parameters.length; i++) { | |||
String paramname = parameters[i].getName(); | |||
for (Parameter parameter : parameters) { | |||
String paramname = parameter.getName(); | |||
if (MILLIS_KEY.equalsIgnoreCase(paramname)) { | |||
try { | |||
setMillis(Long.parseLong(parameters[i].getValue())); | |||
setMillis(Long.parseLong(parameter.getValue())); | |||
} catch (NumberFormatException nfe) { | |||
setError("Invalid millisecond setting " | |||
+ parameters[i].getValue()); | |||
+ parameter.getValue()); | |||
} | |||
} else if (DATETIME_KEY.equalsIgnoreCase(paramname)) { | |||
setDatetime(parameters[i].getValue()); | |||
setDatetime(parameter.getValue()); | |||
} else if (CHECKDIRS_KEY.equalsIgnoreCase(paramname)) { | |||
setCheckdirs(Project.toBoolean(parameters[i].getValue())); | |||
setCheckdirs(Project.toBoolean(parameter.getValue())); | |||
} else if (GRANULARITY_KEY.equalsIgnoreCase(paramname)) { | |||
try { | |||
setGranularity(Integer.parseInt(parameters[i].getValue())); | |||
setGranularity(Integer.parseInt(parameter.getValue())); | |||
} catch (NumberFormatException nfe) { | |||
setError("Invalid granularity setting " | |||
+ parameters[i].getValue()); | |||
+ parameter.getValue()); | |||
} | |||
} else if (WHEN_KEY.equalsIgnoreCase(paramname)) { | |||
setWhen(new TimeComparison(parameters[i].getValue())); | |||
setWhen(new TimeComparison(parameter.getValue())); | |||
} else if (PATTERN_KEY.equalsIgnoreCase(paramname)) { | |||
setPattern(parameters[i].getValue()); | |||
setPattern(parameter.getValue()); | |||
} else { | |||
setError("Invalid parameter " + paramname); | |||
} | |||
@@ -92,21 +92,21 @@ public class DepthSelector extends BaseExtendSelector { | |||
public void setParameters(Parameter[] parameters) { | |||
super.setParameters(parameters); | |||
if (parameters != null) { | |||
for (int i = 0; i < parameters.length; i++) { | |||
String paramname = parameters[i].getName(); | |||
for (Parameter parameter : parameters) { | |||
String paramname = parameter.getName(); | |||
if (MIN_KEY.equalsIgnoreCase(paramname)) { | |||
try { | |||
setMin(Integer.parseInt(parameters[i].getValue())); | |||
setMin(Integer.parseInt(parameter.getValue())); | |||
} catch (NumberFormatException nfe1) { | |||
setError("Invalid minimum value " | |||
+ parameters[i].getValue()); | |||
+ parameter.getValue()); | |||
} | |||
} else if (MAX_KEY.equalsIgnoreCase(paramname)) { | |||
try { | |||
setMax(Integer.parseInt(parameters[i].getValue())); | |||
setMax(Integer.parseInt(parameter.getValue())); | |||
} catch (NumberFormatException nfe1) { | |||
setError("Invalid maximum value " | |||
+ parameters[i].getValue()); | |||
+ parameter.getValue()); | |||
} | |||
} else { | |||
setError("Invalid parameter " + paramname); | |||