Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Hammer2019-09-25 15:59:02 -0400
committerAlexander Kurtakov2019-10-16 01:07:28 -0400
commitc3e6490d91f762660b540236b6e45a963243df23 (patch)
treef6bab92a56651671460a7d2bc2e82cf604e2b4b8
parent69833cb735e950f05e57f3a76f795ad29e5787ae (diff)
downloadrt.equinox.p2-c3e6490d91f762660b540236b6e45a963243df23.tar.gz
rt.equinox.p2-c3e6490d91f762660b540236b6e45a963243df23.tar.xz
rt.equinox.p2-c3e6490d91f762660b540236b6e45a963243df23.zip
Use jdk 5 for-each loop
Replace simple uses of Iterator with a corresponding for-loop. Also add missing braces on loops as necessary. Change-Id: Ie1889d9dbff94017966e4118eb9a114ff4cc88a1 Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de>
-rw-r--r--bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/PlanAnalyzer.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/ResolutionResult.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/RepositoryTracker.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/UpdateOperation.java20
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AbstractPublisherAction.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AbstractPublisherApplication.java21
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/Publisher.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/JREAction.java17
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/MergeResultsAction.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/RootFilesAction.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/spi/p2/publisher/LocalizationHelper.java6
11 files changed, 47 insertions, 52 deletions
diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/PlanAnalyzer.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/PlanAnalyzer.java
index f61bb48b6..5b526c21a 100644
--- a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/PlanAnalyzer.java
+++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/PlanAnalyzer.java
@@ -79,8 +79,9 @@ public class PlanAnalyzer {
if (nothingToDo(originalRequest)) {
report.addSummaryStatus(getStatus(IStatusCodes.UNEXPECTED_NOTHING_TO_DO, null));
IStatus[] details = originalStatus.getChildren();
- for (int i = 0; i < details.length; i++)
- report.addSummaryStatus(details[i]);
+ for (IStatus detail : details) {
+ report.addSummaryStatus(detail);
+ }
return report;
}
diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/ResolutionResult.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/ResolutionResult.java
index 7c9926c01..73073d1e0 100644
--- a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/ResolutionResult.java
+++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/ResolutionResult.java
@@ -81,8 +81,8 @@ public class ResolutionResult {
// Answers null if there is nothing to say about the ius
public String getDetailedReport(IInstallableUnit[] ius) {
StringBuffer buffer = new StringBuffer();
- for (int i = 0; i < ius.length; i++) {
- MultiStatus iuStatus = iuToStatusMap.get(ius[i]);
+ for (IInstallableUnit iu : ius) {
+ MultiStatus iuStatus = iuToStatusMap.get(iu);
if (iuStatus != null)
appendDetailText(iuStatus, buffer, 0, true);
}
@@ -123,10 +123,10 @@ public class ResolutionResult {
}
// Now print the children status info (if there are children)
IStatus[] children = status.getChildren();
- for (int i = 0; i < children.length; i++) {
+ for (IStatus child : children) {
if (buffer.length() > 0)
buffer.append('\n');
- appendDetailText(children[i], buffer, indent + 1, true);
+ appendDetailText(child, buffer, indent + 1, true);
}
}
}
diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/RepositoryTracker.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/RepositoryTracker.java
index a1e85a126..6b50616a4 100644
--- a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/RepositoryTracker.java
+++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/RepositoryTracker.java
@@ -130,8 +130,8 @@ public abstract class RepositoryTracker {
// This is a fallback implementation in the absence of a repository tracker
// that would know what to do.
URI[] knownRepositories = getKnownRepositories(session);
- for (int i = 0; i < knownRepositories.length; i++) {
- if (URIUtil.sameURI(knownRepositories[i], location)) {
+ for (URI repository : knownRepositories) {
+ if (URIUtil.sameURI(repository, location)) {
return true;
}
}
diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/UpdateOperation.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/UpdateOperation.java
index 79a181f03..f562ff3b3 100644
--- a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/UpdateOperation.java
+++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/UpdateOperation.java
@@ -177,12 +177,11 @@ public class UpdateOperation extends ProfileChangeOperation {
for (IInstallableUnit iuToUpdate : iusToUpdate) {
SubMonitor iuMon = sub.newChild(100);
Update[] updates = updatesFor(iuToUpdate, profile, iuMon);
- for (int j = 0; j < updates.length; j++) {
+ for (Update update : updates) {
toBeUpdated.add(iuToUpdate);
- if (defaultUpdates != null && defaultUpdates.contains(updates[j])) {
- elementsToPlan.add(updates[j]);
+ if (defaultUpdates != null && defaultUpdates.contains(update)) {
+ elementsToPlan.add(update);
}
-
}
if (!selectionSpecified) {
// If no selection was specified, we must figure out the latest version to apply.
@@ -195,19 +194,20 @@ public class UpdateOperation extends ProfileChangeOperation {
HashMap<String, Update> latestVersions = new HashMap<>();
boolean foundUpdate = false;
boolean foundPatch = false;
- for (int j = 0; j < updates.length; j++) {
+ for (Update update : updates) {
String key;
- if (QueryUtil.isPatch(updates[j].replacement)) {
+ if (QueryUtil.isPatch(update.replacement)) {
foundPatch = true;
- key = updates[j].replacement.getId();
+ key = update.replacement.getId();
} else {
foundUpdate = true;
- key = updates[j].toUpdate.getId();
+ key = update.toUpdate.getId();
}
Update latestUpdate = latestVersions.get(key);
IInstallableUnit latestIU = latestUpdate == null ? null : latestUpdate.replacement;
- if (latestIU == null || updates[j].replacement.getVersion().compareTo(latestIU.getVersion()) > 0)
- latestVersions.put(key, updates[j]);
+ if (latestIU == null || update.replacement.getVersion().compareTo(latestIU.getVersion()) > 0) {
+ latestVersions.put(key, update);
+ }
}
// If there is a true update available, ignore any patches found
// Patches are keyed by their own id
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AbstractPublisherAction.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AbstractPublisherAction.java
index 0b740c650..f5d890b08 100644
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AbstractPublisherAction.java
+++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AbstractPublisherAction.java
@@ -379,8 +379,7 @@ public abstract class AbstractPublisherAction implements IPublisherAction {
Collection<IProvidedCapability> current = iu.getProvidedCapabilities();
Set<IProvidedCapability> resultProvidedCapabilities = new HashSet<>(current);
for (IProvidedCapability currentProvidedCapability : current) {
- for (int k = 0; k < providedAdvice.length; k++) {
- IProvidedCapability providedCapability = providedAdvice[k];
+ for (IProvidedCapability providedCapability : providedAdvice) {
if (providedCapability.getNamespace().equals(currentProvidedCapability.getNamespace()) && providedCapability.getName().equals(currentProvidedCapability.getName())) {
resultProvidedCapabilities.remove(currentProvidedCapability);
break;
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AbstractPublisherApplication.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AbstractPublisherApplication.java
index 653d8fe18..5a380a8e2 100644
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AbstractPublisherApplication.java
+++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AbstractPublisherApplication.java
@@ -120,8 +120,9 @@ public abstract class AbstractPublisherApplication implements IApplication {
if (contextMetadataRepositories != null && contextMetadataRepositories.length > 0) {
CompositeMetadataRepository contextMetadata = CompositeMetadataRepository.createMemoryComposite(agent);
if (contextMetadata != null) {
- for (int i = 0; i < contextMetadataRepositories.length; i++)
- contextMetadata.addChild(contextMetadataRepositories[i]);
+ for (URI repositoryuri : contextMetadataRepositories) {
+ contextMetadata.addChild(repositoryuri);
+ }
if (contextMetadata.getChildren().size() > 0)
publisherInfo.setContextMetadataRepository(contextMetadata);
}
@@ -129,8 +130,9 @@ public abstract class AbstractPublisherApplication implements IApplication {
if (contextArtifactRepositories != null && contextArtifactRepositories.length > 0) {
CompositeArtifactRepository contextArtifact = CompositeArtifactRepository.createMemoryComposite(agent);
if (contextArtifact != null) {
- for (int i = 0; i < contextArtifactRepositories.length; i++)
- contextArtifact.addChild(contextArtifactRepositories[i]);
+ for (URI repositoryuri : contextArtifactRepositories) {
+ contextArtifact.addChild(repositoryuri);
+ }
if (contextArtifact.getChildren().size() > 0)
publisherInfo.setContextArtifactRepository(contextArtifact);
@@ -199,10 +201,10 @@ public abstract class AbstractPublisherApplication implements IApplication {
List<URI> result = new ArrayList<>(list.length);
if (result != null) {
- for (int i = 0; i < list.length; i++) {
+ for (String uri : list) {
try {
- result.add(URIUtil.fromString(list[i]));
- } catch (URISyntaxException e) {
+ result.add(URIUtil.fromString(uri));
+ }catch (URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
@@ -259,8 +261,9 @@ public abstract class AbstractPublisherApplication implements IApplication {
Object result = run(info);
if (result != IApplication.EXIT_OK) {
System.out.println(NLS.bind(Messages.message_publisherArguments, null));
- for (int i = 0; i < args.length; i++)
- System.out.println(args[i]);
+ for (String arg : args) {
+ System.out.println(arg);
+ }
}
return result;
} catch (Exception e) {
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/Publisher.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/Publisher.java
index 6e41c73b3..9fcd96efd 100644
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/Publisher.java
+++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/Publisher.java
@@ -205,12 +205,12 @@ public class Publisher {
@Override
public void run(IProgressMonitor monitor) {
MultiStatus finalStatus = new MultiStatus("this", 0, "publishing result", null); //$NON-NLS-1$//$NON-NLS-2$
- for (int i = 0; i < actions.length; i++) {
+ for (IPublisherAction action : actions) {
if (monitor.isCanceled()) {
result = Status.CANCEL_STATUS;
return;
}
- IStatus status = actions[i].perform(publisherInfo, results, monitor);
+ IStatus status = action.perform(publisherInfo, results, monitor);
finalStatus.merge(status);
monitor.worked(1);
}
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/JREAction.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/JREAction.java
index 8ccd50590..55bf28314 100644
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/JREAction.java
+++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/JREAction.java
@@ -150,9 +150,9 @@ public class JREAction extends AbstractPublisherAction {
try {
ManifestElement[] jrePackages = ManifestElement.parseHeader(PROFILE_SYSTEM_PACKAGES, packages);
- for (int i = 0; i < jrePackages.length; i++) {
- String packageName = jrePackages[i].getValue();
- Version packageVersion = Version.create(jrePackages[i].getAttribute("version")); //$NON-NLS-1$
+ for (ManifestElement jrePackage : jrePackages) {
+ String packageName = jrePackage.getValue();
+ Version packageVersion = Version.create(jrePackage.getAttribute("version")); //$NON-NLS-1$
result.add(MetadataFactory.createProvidedCapability(PublisherHelper.CAPABILITY_NS_JAVA_PACKAGE, packageName, packageVersion));
}
} catch (BundleException e) {
@@ -189,14 +189,10 @@ public class JREAction extends AbstractPublisherAction {
}
private static void parseSystemCapabilities(ManifestElement[] systemCapabilities, MultiStatus parsingStatus, List<IProvidedCapability> parsingResult) {
- for (int capabilityIx = 0; capabilityIx < systemCapabilities.length; capabilityIx++) {
- ManifestElement systemCapability = systemCapabilities[capabilityIx];
-
+ for (ManifestElement systemCapability : systemCapabilities) {
// this is general manifest syntax: a "manifest element" can have multiple "value components" -> all attributes apply to each value component (=namespace)
String[] namespaces = systemCapability.getValueComponents();
- for (int namespaceIx = 0; namespaceIx < namespaces.length; namespaceIx++) {
- String namespace = namespaces[namespaceIx];
-
+ for (String namespace : namespaces) {
if (NAMESPACE_OSGI_EE.equals(namespace)) { // this is the OSGi capability namespace "osgi.ee"
parseEECapability(systemCapability, parsingStatus, parsingResult);
@@ -221,8 +217,7 @@ public class JREAction extends AbstractPublisherAction {
return;
}
- for (int versionIx = 0; versionIx < eeVersions.length; versionIx++) {
- String rawVersion = eeVersions[versionIx];
+ for (String rawVersion : eeVersions) {
try {
Version parsedVersion = Version.parseVersion(rawVersion);
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/MergeResultsAction.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/MergeResultsAction.java
index 7041104c5..c538b129e 100644
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/MergeResultsAction.java
+++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/MergeResultsAction.java
@@ -8,8 +8,8 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ *
+ * Contributors:
* Code 9 - initial API and implementation
* IBM - ongoing development
******************************************************************************/
@@ -31,10 +31,9 @@ public class MergeResultsAction extends AbstractPublisherAction {
@Override
public IStatus perform(IPublisherInfo publisherInfo, IPublisherResult results, IProgressMonitor monitor) {
MultiStatus finalStatus = new MultiStatus(MergeResultsAction.class.getName(), 0, "publishing result", null); //$NON-NLS-1$
- for (int i = 0; i < actions.length; i++) {
+ for (IPublisherAction action : actions) {
if (monitor.isCanceled())
return Status.CANCEL_STATUS;
- IPublisherAction action = actions[i];
IPublisherResult result = new PublisherResult();
finalStatus.merge(action.perform(publisherInfo, result, monitor));
results.merge(result, mode);
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/RootFilesAction.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/RootFilesAction.java
index 28ef22ab9..ae12987ce 100644
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/RootFilesAction.java
+++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/RootFilesAction.java
@@ -60,10 +60,10 @@ public class RootFilesAction extends AbstractPublisherAction {
// we have N platforms, generate a CU for each
// TODO try and find common properties across platforms
String[] configSpecs = publisherInfo.getConfigurations();
- for (int i = 0; i < configSpecs.length; i++) {
+ for (String configSpec : configSpecs) {
if (monitor.isCanceled())
return Status.CANCEL_STATUS;
- generateRootFileIUs(configSpecs[i], innerResult);
+ generateRootFileIUs(configSpec, innerResult);
}
// merge the IUs into the final result as non-roots and create a parent IU that captures them all
results.merge(innerResult, IPublisherResult.MERGE_ALL_NON_ROOT);
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/spi/p2/publisher/LocalizationHelper.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/spi/p2/publisher/LocalizationHelper.java
index 36b1640f8..f969d1766 100644
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/spi/p2/publisher/LocalizationHelper.java
+++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/spi/p2/publisher/LocalizationHelper.java
@@ -70,8 +70,7 @@ public final class LocalizationHelper {
if (localizationFiles != null && localizationFiles.length > 0) {
localizations = new HashMap<>(localizationFiles.length);
- for (int i = 0; i < localizationFiles.length; i++) {
- String nextFile = localizationFiles[i];
+ for (String nextFile : localizationFiles) {
Locale nextLocale = getLocale(LocalizationHelper.getLocaleString(nextFile, localizationFile));
try {
@@ -148,8 +147,7 @@ public final class LocalizationHelper {
// return a new property set with those keys and the localized values.
static public Map<String, String> getLocalizedProperties(String[] propertyKeys, Map<String, String> properties) {
Map<String, String> localizedProperties = new HashMap<>();
- for (int i = 0; i < propertyKeys.length; i++) {
- String key = propertyKeys[i];
+ for (String key : propertyKeys) {
if (key != null) {
String localizedValue = properties.get(key);
if (localizedValue != null)

Back to the top