aboutsummaryrefslogtreecommitdiffstats
path: root/build/src/main/java
diff options
context:
space:
mode:
authorAndy Clement <aclement@pivotal.io>2020-08-12 15:20:45 -0700
committerGitHub <noreply@github.com>2020-08-12 15:20:45 -0700
commitb6eee2e1052116aa22ebbd3c2baf05c2b709bee5 (patch)
tree01fb5493dc348d42e4fb9fb6ce1cd41e361d666b /build/src/main/java
parentcacc9d5602b7bbe6192d5ff1351605dc180cc108 (diff)
parent29f947156e58f3f0c60e721d42e7f3e98de7180a (diff)
downloadaspectj-b6eee2e1052116aa22ebbd3c2baf05c2b709bee5.tar.gz
aspectj-b6eee2e1052116aa22ebbd3c2baf05c2b709bee5.zip
Merge pull request #1 from larsgrefer/feature/java5
Update the code to Java 5 features
Diffstat (limited to 'build/src/main/java')
-rw-r--r--build/src/main/java/$installer$/org/aspectj/Main.java11
-rw-r--r--build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AJInstaller.java29
-rw-r--r--build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java23
-rw-r--r--build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/Checklics.java4
-rw-r--r--build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/ConditionalTask.java10
-rw-r--r--build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/StripNonBodyHtml.java14
-rw-r--r--build/src/main/java/org/aspectj/internal/tools/build/Builder.java115
-rw-r--r--build/src/main/java/org/aspectj/internal/tools/build/Module.java104
-rw-r--r--build/src/main/java/org/aspectj/internal/tools/build/SampleGatherer.java124
-rw-r--r--build/src/main/java/org/aspectj/internal/tools/build/Util.java44
10 files changed, 230 insertions, 248 deletions
diff --git a/build/src/main/java/$installer$/org/aspectj/Main.java b/build/src/main/java/$installer$/org/aspectj/Main.java
index 6ecebae63..2ffc8b889 100644
--- a/build/src/main/java/$installer$/org/aspectj/Main.java
+++ b/build/src/main/java/$installer$/org/aspectj/Main.java
@@ -707,8 +707,8 @@ class InstallContext {
public boolean isTextFile(File file) {
String name = file.getName();
- for (int i = 0; i < TEXT_EXTENSIONS.length; i++) {
- if (name.endsWith(TEXT_EXTENSIONS[i])) {
+ for (String textExtension : TEXT_EXTENSIONS) {
+ if (name.endsWith(textExtension)) {
return true;
}
}
@@ -1243,10 +1243,9 @@ class ConfigureLauncherPane extends WizardPane {
paths = unixPaths;
}
- for (int suffixIndex = 0; suffixIndex < suffixes.length; suffixIndex++) {
- String suffix = suffixes[suffixIndex];
- for (int prefixIndex = 0; prefixIndex < paths.length; prefixIndex++) {
- String prefix = paths[prefixIndex];
+ for (String suffix : suffixes) {
+ for (String path : paths) {
+ String prefix = path;
prefix = applyProperties(prefix);
File test = new File(prefix + suffix);
if (isLegalJavaHome(test)) {
diff --git a/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AJInstaller.java b/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AJInstaller.java
index 2428e66d9..809ac1cbb 100644
--- a/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AJInstaller.java
+++ b/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AJInstaller.java
@@ -152,11 +152,10 @@ public class AJInstaller extends MatchingTask {
StringBuffer buf = new StringBuffer();
buf.append(contentsBytes);
buf.append(NEWLINE);
- for (Iterator<String> i = contentsNames.iterator(); i.hasNext(); ) {
- String name = i.next();
- buf.append(name);
- buf.append(NEWLINE);
- }
+ for (String name : contentsNames) {
+ buf.append(name);
+ buf.append(NEWLINE);
+ }
zipFile(new StringBufferInputStream(buf.toString()), zOut, CONTENTS_FILE, System.currentTimeMillis());
}
@@ -347,19 +346,19 @@ public class AJInstaller extends MatchingTask {
}
protected void writeDirs(ZipOutputStream zOut, String[] dirs) throws IOException {
- for (int i = 0; i < dirs.length; i++) {
- File f = new File(baseDir,dirs[i]);
- String name = dirs[i].replace(File.separatorChar,'/')+"/";
- zipDir(f, zOut, name);
- }
+ for (String dir : dirs) {
+ File f = new File(baseDir, dir);
+ String name = dir.replace(File.separatorChar, '/') + "/";
+ zipDir(f, zOut, name);
+ }
}
protected void writeFiles(ZipOutputStream zOut, String[] files) throws IOException {
- for (int i = 0; i < files.length; i++) {
- File f = new File(baseDir,files[i]);
- String name = files[i].replace(File.separatorChar,'/');
- zipFile(f, zOut, name);
- }
+ for (String file : files) {
+ File f = new File(baseDir, file);
+ String name = file.replace(File.separatorChar, '/');
+ zipFile(f, zOut, name);
+ }
}
}
diff --git a/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java b/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java
index c4f8848d8..12286748e 100644
--- a/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java
+++ b/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java
@@ -61,10 +61,10 @@ public class AntBuilder extends Builder {
boolean useEclipseCompiles = false;
boolean verbose = false;
if (null != config) {
- if (-1 != config.indexOf("useEclipseCompiles")) {
+ if (config.contains("useEclipseCompiles")) {
useEclipseCompiles = true;
}
- if (-1 != config.indexOf("verbose")) {
+ if (config.contains("verbose")) {
verbose = true;
}
}
@@ -95,8 +95,7 @@ public class AntBuilder extends Builder {
Result[] reqs = result.getRequired();
StringBuffer depends = new StringBuffer();
boolean first = true;
- for (int i = 0; i < reqs.length; i++) {
- Result reqResult = reqs[i];
+ for (Result reqResult : reqs) {
if (!first) {
depends.append(",");
} else {
@@ -110,8 +109,7 @@ public class AntBuilder extends Builder {
targets.put(resultTargetName, target);
// then recursively add any required results
- for (int i = 0; i < reqs.length; i++) {
- Result reqResult = reqs[i];
+ for (Result reqResult : reqs) {
makeTargetsForResult(reqResult, targets);
}
}
@@ -311,8 +309,7 @@ public class AntBuilder extends Builder {
public boolean setupClasspath(Result result, Path classpath) { // XXX fix test access
boolean hasLibraries = false;
// required libraries
- for (Iterator<File> iter = result.getLibJars().iterator(); iter.hasNext();) {
- File file = iter.next();
+ for (File file : result.getLibJars()) {
classpath.createPathElement().setLocation(file);
if (!hasLibraries) {
hasLibraries = true;
@@ -321,16 +318,15 @@ public class AntBuilder extends Builder {
// Westodo Kind kind = result.getKind();
Result[] reqs = result.getRequired();
// required modules and their exported libraries
- for (int i = 0; i < reqs.length; i++) {
- Result requiredResult = reqs[i];
+ for (Result requiredResult : reqs) {
classpath.createPathElement().setLocation(requiredResult.getOutputFile());
if (!hasLibraries) {
hasLibraries = true;
}
// also put on classpath libraries exported from required module
// XXX exported modules not supported
- for (Iterator<File> iterator = requiredResult.getExportedLibJars().iterator(); iterator.hasNext();) {
- classpath.createPathElement().setLocation(iterator.next());
+ for (File file : requiredResult.getExportedLibJars()) {
+ classpath.createPathElement().setLocation(file);
}
}
return hasLibraries;
@@ -424,8 +420,7 @@ public class AntBuilder extends Builder {
return new Result[0];
}
ArrayList<String> toReturn = new ArrayList<String>();
- for (Iterator<Target> iter = result.iterator(); iter.hasNext();) {
- Target target = iter.next();
+ for (Target target : result) {
String name = target.getName();
if (null == name) {
throw new Error("null name?");
diff --git a/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/Checklics.java b/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/Checklics.java
index afa3c71d3..aa0c35e35 100644
--- a/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/Checklics.java
+++ b/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/Checklics.java
@@ -422,7 +422,7 @@ public class Checklics extends MatchingTask {
if ((null == line) || (0 == line.length())) {
return;
}
- if (!gotLicense && (null != license) && (-1 != line.indexOf(license))) {
+ if (!gotLicense && (null != license) && (line.contains(license))) {
gotLicense = true;
}
if (!gotCopyright && (null != copyright)) {
@@ -670,7 +670,7 @@ class Header {
start = loc + 4;
}
- return (-1 != line.indexOf("*/"));
+ return (line.contains("*/"));
}
} // class Header
diff --git a/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/ConditionalTask.java b/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/ConditionalTask.java
index ccb9c2149..e71795912 100644
--- a/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/ConditionalTask.java
+++ b/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/ConditionalTask.java
@@ -145,11 +145,11 @@ public abstract class ConditionalTask extends Task {
return isOneOf(prop, trues) || isOneOf(prop, complement(falses));
}
private boolean isOneOf(String prop, String[] strings) {
- for (int i = 0; i < strings.length; i++) {
- if (strings[i].equals(prop)) {
- return true;
- }
- }
+ for (String string : strings) {
+ if (string.equals(prop)) {
+ return true;
+ }
+ }
return false;
}
private String[] complement(String[] strings) {
diff --git a/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/StripNonBodyHtml.java b/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/StripNonBodyHtml.java
index a33505d95..61e29f3b3 100644
--- a/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/StripNonBodyHtml.java
+++ b/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/StripNonBodyHtml.java
@@ -81,13 +81,13 @@ public class StripNonBodyHtml extends MatchingTask {
log("stripping " + files.length + " files");
int stripped = 0;
- for (int i = 0, len = files.length; i < len; i++) {
- if (processFile(files[i])) {
- stripped++;
- } else {
- log(files[i] + " not stripped");
- }
- }
+ for (String file : files) {
+ if (processFile(file)) {
+ stripped++;
+ } else {
+ log(file + " not stripped");
+ }
+ }
log(stripped + " files successfully stripped");
}
diff --git a/build/src/main/java/org/aspectj/internal/tools/build/Builder.java b/build/src/main/java/org/aspectj/internal/tools/build/Builder.java
index 8efea662a..fe80190ad 100644
--- a/build/src/main/java/org/aspectj/internal/tools/build/Builder.java
+++ b/build/src/main/java/org/aspectj/internal/tools/build/Builder.java
@@ -251,7 +251,7 @@ public abstract class Builder {
*/
protected Result specifyResultFor(BuildSpec buildSpec) {
if (buildSpec.trimTesting
- && (-1 != buildSpec.module.indexOf("testing"))) { // XXXNameLiteral
+ && (buildSpec.module.contains("testing"))) { // XXXNameLiteral
String warning = "Warning - cannot trimTesting for testing modules: ";
handler.log(warning + buildSpec.module);
}
@@ -281,10 +281,10 @@ public abstract class Builder {
} finally {
if (0 < errors.size()) {
String label = "error building " + buildSpec + ": ";
- for (Iterator<String> iter = errors.iterator(); iter.hasNext();) {
- String m = label + iter.next();
- handler.error(m);
- }
+ for (String error : errors) {
+ String m = label + error;
+ handler.error(m);
+ }
}
}
}
@@ -294,15 +294,15 @@ public abstract class Builder {
*/
public boolean cleanup() {
boolean noErr = true;
- for (ListIterator iter = tempFiles.listIterator(); iter.hasNext();) {
- File file = (File) iter.next();
- if (!Util.deleteContents(file) || !file.delete()) {
- if (noErr) {
- noErr = false;
- }
- handler.log("unable to clean up " + file);
- }
- }
+ for (Object tempFile : tempFiles) {
+ File file = (File) tempFile;
+ if (!Util.deleteContents(file) || !file.delete()) {
+ if (noErr) {
+ noErr = false;
+ }
+ handler.log("unable to clean up " + file);
+ }
+ }
return noErr;
}
@@ -345,19 +345,18 @@ public abstract class Builder {
if (isLogging()) {
handler.log("modules to build: " + Arrays.asList(buildList));
}
- for (int i = 0; i < buildList.length; i++) {
- Result required = buildList[i];
- if (!buildingEnabled) {
- return false;
- }
- String requiredName = required.getName();
- if (!doneList.contains(requiredName)) {
- doneList.add(requiredName);
- if (!buildOnly(required, errors)) {
- return false;
- }
- }
- }
+ for (Result required : buildList) {
+ if (!buildingEnabled) {
+ return false;
+ }
+ String requiredName = required.getName();
+ if (!doneList.contains(requiredName)) {
+ doneList.add(requiredName);
+ if (!buildOnly(required, errors)) {
+ return false;
+ }
+ }
+ }
}
return true;
}
@@ -439,14 +438,14 @@ public abstract class Builder {
handler);
ProductModule[] productModules = discoverModules(buildSpec.productDir,
modules);
- for (int i = 0; i < productModules.length; i++) {
- if (buildSpec.verbose) {
- handler.log("building product module " + productModules[i]);
- }
- if (!buildProductModule(productModules[i])) {
- return false;
- }
- }
+ for (ProductModule module : productModules) {
+ if (buildSpec.verbose) {
+ handler.log("building product module " + module);
+ }
+ if (!buildProductModule(module)) {
+ return false;
+ }
+ }
if (buildSpec.verbose) {
handler.log("assembling product module for " + buildSpec);
}
@@ -476,12 +475,12 @@ public abstract class Builder {
String excludes = null;
{
StringBuffer buf = new StringBuffer();
- for (int i = 0; i < productModules.length; i++) {
- if (0 < buf.length()) {
- buf.append(",");
- }
- buf.append(productModules[i].relativePath);
- }
+ for (ProductModule productModule : productModules) {
+ if (0 < buf.length()) {
+ buf.append(",");
+ }
+ buf.append(productModule.relativePath);
+ }
if (0 < buf.length()) {
excludes = buf.toString();
}
@@ -492,14 +491,13 @@ public abstract class Builder {
}
// copy binaries associated with module flag files
- for (int i = 0; i < productModules.length; i++) {
- final ProductModule product = productModules[i];
- final Kind kind = Result.kind(Result.NORMAL, product.assembleAll);
- Result result = product.module.getResult(kind);
- String targPath = Util.path(targDirPath, product.relativePath);
- File jarFile = result.getOutputFile();
- copyFile(jarFile, new File(targPath), FILTER_OFF);
- }
+ for (final ProductModule product : productModules) {
+ final Kind kind = Result.kind(Result.NORMAL, product.assembleAll);
+ Result result = product.module.getResult(kind);
+ String targPath = Util.path(targDirPath, product.relativePath);
+ File jarFile = result.getOutputFile();
+ copyFile(jarFile, new File(targPath), FILTER_OFF);
+ }
handler.log("created product in " + targDir);
// ---- create installer
@@ -533,9 +531,9 @@ public abstract class Builder {
Result result = module.module.getResult(productKind);
return buildAll(result, errors);
} finally {
- for (Iterator<String> iter = errors.iterator(); iter.hasNext();) {
- handler.error("error building " + module + ": " + iter.next());
- }
+ for (String error : errors) {
+ handler.error("error building " + module + ": " + error);
+ }
}
}
@@ -595,13 +593,12 @@ public abstract class Builder {
File library = liter.next();
final String fname = library.getName();
if (null != fname) {
- for (Iterator<String> iter = SKIP_LIBRARIES.iterator(); iter.hasNext();) {
- String name = iter.next();
- if (fname.equals(name)) {
- liter.remove();
- break;
- }
- }
+ for (String name : SKIP_LIBRARIES) {
+ if (fname.equals(name)) {
+ liter.remove();
+ break;
+ }
+ }
}
}
}
diff --git a/build/src/main/java/org/aspectj/internal/tools/build/Module.java b/build/src/main/java/org/aspectj/internal/tools/build/Module.java
index 58789424f..65d929707 100644
--- a/build/src/main/java/org/aspectj/internal/tools/build/Module.java
+++ b/build/src/main/java/org/aspectj/internal/tools/build/Module.java
@@ -79,13 +79,13 @@ public class Module {
return;
}
File[] files = srcDir.listFiles();
- for (int i = 0; i < files.length; i++) {
- if (files[i].isDirectory()) {
- sourceFiles(files[i], result);
- } else if (isSourceFile(files[i])) {
- result.add(files[i]);
- }
- }
+ for (File file : files) {
+ if (file.isDirectory()) {
+ sourceFiles(file, result);
+ } else if (isSourceFile(file)) {
+ result.add(file);
+ }
+ }
}
private static void addIfNew(List<File> source, List<File> sink) {
@@ -107,14 +107,13 @@ public class Module {
addIfNew(result.getLibJars(), known);
addIfNew(result.getExportedLibJars(), known);
Result[] reqs = result.getRequired();
- for (int i = 0; i < reqs.length; i++) {
- Result requiredResult = reqs[i];
- File requiredJar = requiredResult.getOutputFile();
- if (!known.contains(requiredJar)) {
- known.add(requiredJar);
- doFindJarRequirements(requiredResult, known);
- }
- }
+ for (Result requiredResult : reqs) {
+ File requiredJar = requiredResult.getOutputFile();
+ if (!known.contains(requiredJar)) {
+ known.add(requiredJar);
+ doFindJarRequirements(requiredResult, known);
+ }
+ }
}
/** @return true if this is a source file */
@@ -238,31 +237,29 @@ public class Module {
}
final long time = outputFile.lastModified();
File file;
- for (Iterator<File> iter = result.getSrcDirs().iterator(); iter.hasNext();) {
- File srcDir = iter.next();
- for (Iterator<File> srcFiles = sourceFiles(srcDir); srcFiles.hasNext();) {
- file = srcFiles.next();
- if (outOfDate(time, file)) {
- return true;
- }
- }
- }
+ for (File srcDir : result.getSrcDirs()) {
+ for (Iterator<File> srcFiles = sourceFiles(srcDir); srcFiles.hasNext(); ) {
+ file = srcFiles.next();
+ if (outOfDate(time, file)) {
+ return true;
+ }
+ }
+ }
// required modules
Result[] reqs = result.getRequired();
- for (int i = 0; i < reqs.length; i++) {
- Result requiredResult = reqs[i];
- file = requiredResult.getOutputFile();
- if (outOfDate(time, file)) {
- return true;
- }
- }
+ for (Result requiredResult : reqs) {
+ file = requiredResult.getOutputFile();
+ if (outOfDate(time, file)) {
+ return true;
+ }
+ }
// libraries
- for (Iterator<File> iter = result.getLibJars().iterator(); iter.hasNext();) {
- file = iter.next();
- if (outOfDate(time, file)) {
- return true;
- }
- }
+ for (File value : result.getLibJars()) {
+ file = value;
+ if (outOfDate(time, file)) {
+ return true;
+ }
+ }
return false;
}
@@ -345,14 +342,13 @@ public class Module {
Util.closeSilently(fin);
}
RequiredBundle[] bundles = bundle.getRequiredBundles();
- for (int i = 0; i < bundles.length; i++) {
- RequiredBundle required = bundles[i];
- update("src", "/" + required.name, required.text, false);
- }
+ for (RequiredBundle required : bundles) {
+ update("src", "/" + required.name, required.text, false);
+ }
String[] libs = bundle.getClasspath();
- for (int i = 0; i < libs.length; i++) {
- update("lib", libs[i], libs[i], false);
- }
+ for (String lib : libs) {
+ update("lib", lib, lib, false);
+ }
return true;
}
@@ -448,7 +444,7 @@ public class Module {
if (path.equals("org.eclipse.ajdt.core.ASPECTJRT_CONTAINER")) {
classpathVariables.add("ASPECTJRT_LIB");
} else {
- if (-1 == path.indexOf("JRE")) { // warn non-JRE containers
+ if (!path.contains("JRE")) { // warn non-JRE containers
messager.log("cannot handle con yet: " + toString);
}
}
@@ -478,11 +474,11 @@ public class Module {
private void warnVariable(String path, String toString) {
String[] known = { "JRE_LIB", "ASPECTJRT_LIB", "JRE15_LIB" };
- for (int i = 0; i < known.length; i++) {
- if (known[i].equals(path)) {
- return;
- }
- }
+ for (String s : known) {
+ if (s.equals(path)) {
+ return;
+ }
+ }
messager.log("Module cannot handle var yet: " + toString);
}
@@ -618,7 +614,7 @@ public class Module {
boolean inQuote = false;
while (st.hasMoreTokens()) {
String s = st.nextToken();
- if ((1 == s.length()) && (-1 != DELIM.indexOf(s))) {
+ if ((1 == s.length()) && (DELIM.contains(s))) {
if ("\"".equals(s)) { // end quote (or escaped)
if (inQuote) {
inQuote = false;
@@ -645,9 +641,9 @@ public class Module {
public void acceptLine(String line) {
String[] tokens = tokenize(line);
- for (int i = 0; i < tokens.length; i++) {
- next(tokens[i]);
- }
+ for (String token : tokens) {
+ next(token);
+ }
}
private Properties attributesToProperties() {
diff --git a/build/src/main/java/org/aspectj/internal/tools/build/SampleGatherer.java b/build/src/main/java/org/aspectj/internal/tools/build/SampleGatherer.java
index 4e9f59011..4df90dbbe 100644
--- a/build/src/main/java/org/aspectj/internal/tools/build/SampleGatherer.java
+++ b/build/src/main/java/org/aspectj/internal/tools/build/SampleGatherer.java
@@ -89,9 +89,9 @@ public class SampleGatherer {
return;
}
Samples result = new Samples();
- for (int i = 0; i < args.length; i++) {
- result = gather(new File(args[i]), result);
- }
+ for (String arg : args) {
+ result = gather(new File(arg), result);
+ }
StringBuffer sb = HTMLSamplesRenderer.ME.render(result, null);
@@ -144,9 +144,9 @@ public class SampleGatherer {
}
} else if (source.isDirectory() && source.canRead()) {
File[] files = source.listFiles();
- for (int i = 0; i < files.length; i++) {
- doGather(files[i], sink);
- }
+ for (File file : files) {
+ doGather(file, sink);
+ }
}
}
@@ -156,11 +156,11 @@ public class SampleGatherer {
}
String path = file.getName().toLowerCase();
String[] suffixes = Sample.Kind.SOURCE_SUFFIXES;
- for (int i = 0; i < suffixes.length; i++) {
- if (path.endsWith(suffixes[i])) {
- return true;
- }
- }
+ for (String suffix : suffixes) {
+ if (path.endsWith(suffix)) {
+ return true;
+ }
+ }
return false;
}
@@ -451,7 +451,8 @@ class SamplesRenderer {
public static final String COPYRIGHT =
"<p><small>Copyright 2003 Contributors. All Rights Reserved. "
- + "This sample code is made available under the Common Public " + "License version 1.0 available at "
+ + "This sample code is made available under the Common Public "
+ + "License version 1.0 available at "
+ "<a href=\"http://www.eclipse.org/legal/epl-v10.html\">"
+ "http://www.eclipse.org/legal/epl-v10.html</a>."
+ "Contributors are listed in this document as authors. "
@@ -473,18 +474,16 @@ class SamplesRenderer {
startList(samples, sink);
List<Sample> list = samples.getSortedSamples();
String anchorName = null;
- for (ListIterator<Sample> iter = list.listIterator();
- iter.hasNext();) {
- Sample sample = iter.next();
- String newAnchorName = sample.anchorName;
- if ((null == anchorName)
- || (!anchorName.equals(newAnchorName))) {
- endAnchorName(anchorName, sink);
- startAnchorName(newAnchorName, sample.anchorTitle, sink);
- anchorName = newAnchorName;
- }
- render(sample, sink);
- }
+ for (Sample sample : list) {
+ String newAnchorName = sample.anchorName;
+ if ((null == anchorName)
+ || (!anchorName.equals(newAnchorName))) {
+ endAnchorName(anchorName, sink);
+ startAnchorName(newAnchorName, sample.anchorTitle, sink);
+ anchorName = newAnchorName;
+ }
+ render(sample, sink);
+ }
endAnchorName(anchorName, sink);
endList(samples, sink);
return sink;
@@ -605,17 +604,16 @@ class HTMLSamplesRenderer extends SamplesRenderer {
sampleSection.append(EOL);
if (doFlags) {
boolean flagHeaderDone = false;
- for (Iterator iter = sample.flags.iterator(); iter.hasNext();) {
- String flag = (String) iter.next();
- if (!flagHeaderDone) {
- sampleSection.append("<p>Comments flagged:<ul>");
- sampleSection.append(EOL);
- flagHeaderDone = true;
- }
- sampleSection.append("<li>");
- sampleSection.append(flag);
- sampleSection.append("</li>");
- }
+ for (String flag : sample.flags) {
+ if (!flagHeaderDone) {
+ sampleSection.append("<p>Comments flagged:<ul>");
+ sampleSection.append(EOL);
+ flagHeaderDone = true;
+ }
+ sampleSection.append("<li>");
+ sampleSection.append(flag);
+ sampleSection.append("</li>");
+ }
if (flagHeaderDone) {
sampleSection.append("</ul>");
sampleSection.append(EOL);
@@ -779,30 +777,29 @@ class HTMLSamplesRenderer extends SamplesRenderer {
sink.append("<h2><a name=\"authorIndex\"></a>Author Index</h2>");
List<Sample> list = samples.getSortedSamples(Sample.AUTHOR_NAME_SOURCE_COMPARER);
String lastAuthor = null;
- for (ListIterator<Sample> iter = list.listIterator(); iter.hasNext();) {
- Sample sample = iter.next();
- String author = sample.author;
- if (!author.equals(lastAuthor)) {
- if (null != lastAuthor) {
- sink.append("</li></ul>");
- }
- sink.append("<li>");
- sink.append(author);
- sink.append(EOL);
- sink.append("<ul>");
- sink.append(EOL);
- lastAuthor = author;
- }
- sink.append(" <li><a href=\"#");
- sink.append(sample.anchorName);
- sink.append("\">");
- if (null == sample.anchorTitle) {
- sink.append(sample.anchorName);
- } else {
- sink.append(sample.anchorTitle);
- }
- sink.append("</a></li>");
- }
+ for (Sample sample : list) {
+ String author = sample.author;
+ if (!author.equals(lastAuthor)) {
+ if (null != lastAuthor) {
+ sink.append("</li></ul>");
+ }
+ sink.append("<li>");
+ sink.append(author);
+ sink.append(EOL);
+ sink.append("<ul>");
+ sink.append(EOL);
+ lastAuthor = author;
+ }
+ sink.append(" <li><a href=\"#");
+ sink.append(sample.anchorName);
+ sink.append("\">");
+ if (null == sample.anchorTitle) {
+ sink.append(sample.anchorName);
+ } else {
+ sink.append(sample.anchorTitle);
+ }
+ sink.append("</a></li>");
+ }
}
}
@@ -812,11 +809,10 @@ class SampleUtil {
public static void simpleRender(Samples result, StringBuffer sink) {
List sortedSamples = result.getSortedSamples();
int i = 0;
- for (ListIterator iter = sortedSamples.listIterator();
- iter.hasNext();) {
- Sample sample = (Sample) iter.next();
- sink.append(i++ + ": " + sample);
- }
+ for (Object sortedSample : sortedSamples) {
+ Sample sample = (Sample) sortedSample;
+ sink.append(i++ + ": " + sample);
+ }
}
/** result struct for getPackagePath */
diff --git a/build/src/main/java/org/aspectj/internal/tools/build/Util.java b/build/src/main/java/org/aspectj/internal/tools/build/Util.java
index 9a1eb9abc..dd393ce45 100644
--- a/build/src/main/java/org/aspectj/internal/tools/build/Util.java
+++ b/build/src/main/java/org/aspectj/internal/tools/build/Util.java
@@ -193,10 +193,10 @@ public class Util {
return false;
} else if (dir.isDirectory()) {
File[] files = dir.listFiles();
- for (int i = 0; i < files.length; i++) {
- if (!deleteContents(files[i]) || !files[i].delete()) {
- return false;
- }
+ for (File file : files) {
+ if (!deleteContents(file) || !file.delete()) {
+ return false;
+ }
}
}
return true;
@@ -293,26 +293,26 @@ public class Util {
if ((hits != expected.length) || (hits != actual.length)) {
sb.append("unexpected [");
String prefix = "";
- for (int i = 0; i < actual.length; i++) {
- if (null != actual[i]) {
- sb.append(prefix);
- prefix = ", ";
- sb.append("\"");
- sb.append(actual[i]);
- sb.append("\"");
- }
- }
+ for (String value : actual) {
+ if (null != value) {
+ sb.append(prefix);
+ prefix = ", ";
+ sb.append("\"");
+ sb.append(value);
+ sb.append("\"");
+ }
+ }
sb.append("] missing [");
prefix = "";
- for (int i = 0; i < expected.length; i++) {
- if (null != expected[i]) {
- sb.append(prefix);
- prefix = ", ";
- sb.append("\"");
- sb.append(expected[i]);
- sb.append("\"");
- }
- }
+ for (String s : expected) {
+ if (null != s) {
+ sb.append(prefix);
+ prefix = ", ";
+ sb.append("\"");
+ sb.append(s);
+ sb.append("\"");
+ }
+ }
sb.append("]");
return true;
}