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: I85b389f0fcd3fdb8e77ccb282bb0b4c7015db8fd
Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de>
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/StructuredTextTypesCollector.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/StructuredTextTypesCollector.java
index 622b897..4fecb9f 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/StructuredTextTypesCollector.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/StructuredTextTypesCollector.java
@@ -92,11 +92,9 @@
}
IExtensionPoint extPoint = registry.getExtensionPoint(EXT_POINT);
- IExtension[] extensions = extPoint.getExtensions();
- for (IExtension extension : extensions) {
- IConfigurationElement[] confElements = extension.getConfigurationElements();
- for (IConfigurationElement confElement : confElements) {
+ for (IExtension extension : extPoint.getExtensions()) {
+ for (IConfigurationElement confElement : extension.getConfigurationElements()) {
if (!CE_NAME.equals(confElement.getName()))
StructuredTextActivator.logError("BiDi types: unexpected element name " + confElement.getName(), new IllegalArgumentException()); //$NON-NLS-1$
String type = confElement.getAttribute(ATTR_TYPE);
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/SortedProperties.java b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/SortedProperties.java
index 205b92d..bffe300 100644
--- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/SortedProperties.java
+++ b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/SortedProperties.java
@@ -49,8 +49,8 @@
String s2 = (String) e2.getKey();
return s1.compareTo(s2);
});
- for (Iterator<Entry<Object, Object>> i = super.entrySet().iterator(); i.hasNext();) {
- set.add(i.next());
+ for (java.util.Map.Entry<Object, Object> entry : super.entrySet()) {
+ set.add(entry);
}
return set;
}
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/TableWriter.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/TableWriter.java
index 9518913..1864347 100644
--- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/TableWriter.java
+++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/TableWriter.java
@@ -244,8 +244,8 @@
Collection<?> entries = contributors.values();
outputContributors.writeInt(entries.size());
- for (Iterator<?> i = entries.iterator(); i.hasNext();) {
- RegistryContributor contributor = (RegistryContributor) i.next();
+ for (Object entry : entries) {
+ RegistryContributor contributor = (RegistryContributor) entry;
writeStringOrNull(contributor.getActualId(), outputContributors);
writeStringOrNull(contributor.getActualName(), outputContributors);
writeStringOrNull(contributor.getId(), outputContributors);
@@ -291,8 +291,8 @@
return;
}
out.writeInt(array.length);
- for (int i = 0; i < array.length; i++) {
- out.writeInt(array[i]);
+ for (int element : array) {
+ out.writeInt(element);
}
}
diff --git a/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/internal/security/tests/storage/StorageAbstractTest.java b/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/internal/security/tests/storage/StorageAbstractTest.java
index 0ec2d8e..1ede6fa 100644
--- a/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/internal/security/tests/storage/StorageAbstractTest.java
+++ b/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/internal/security/tests/storage/StorageAbstractTest.java
@@ -42,8 +42,7 @@
@After
public void tearDown() throws Exception {
synchronized (openPreferences) {
- for (Iterator<ISecurePreferences> i = openPreferences.iterator(); i.hasNext();) {
- ISecurePreferences root = i.next();
+ for (ISecurePreferences root : openPreferences) {
SecurePreferencesMapper.close((((SecurePreferencesWrapper) root).getContainer().getRootData()));
URL location = ((SecurePreferencesWrapper) root).getContainer().getLocation();
StorageUtils.delete(location);
diff --git a/bundles/org.eclipse.equinox.security.ui/src/org/eclipse/equinox/internal/security/ui/X509CertificateAttributeContentProvider.java b/bundles/org.eclipse.equinox.security.ui/src/org/eclipse/equinox/internal/security/ui/X509CertificateAttributeContentProvider.java
index 258a552..23365f9 100644
--- a/bundles/org.eclipse.equinox.security.ui/src/org/eclipse/equinox/internal/security/ui/X509CertificateAttributeContentProvider.java
+++ b/bundles/org.eclipse.equinox.security.ui/src/org/eclipse/equinox/internal/security/ui/X509CertificateAttributeContentProvider.java
@@ -180,8 +180,8 @@
exKeyUsg = theCert.getExtendedKeyUsage();
StringBuilder exKeyUsgBfr = new StringBuilder();
if (exKeyUsg != null && exKeyUsg.size() > 0) {
- for (Iterator<String> exKeyUsgIter = exKeyUsg.iterator(); exKeyUsgIter.hasNext();) {
- exKeyUsgBfr.append((exKeyUsgIter.next()) + listDelim);
+ for (String string : exKeyUsg) {
+ exKeyUsgBfr.append((string) + listDelim);
}
X509CertificateAttribute exKeyUsgProp = new X509CertificateAttribute(SecurityUIMsg.CERTPROP_X509_EXKEY_USAGE, (exKeyUsgBfr.toString()).substring(0, exKeyUsgBfr.length() - 2), theCert.getExtendedKeyUsage());
diff --git a/bundles/org.eclipse.equinox.security.ui/src/org/eclipse/equinox/internal/security/ui/storage/TabAdvanced.java b/bundles/org.eclipse.equinox.security.ui/src/org/eclipse/equinox/internal/security/ui/storage/TabAdvanced.java
index e6c5aa0..972b5a8 100644
--- a/bundles/org.eclipse.equinox.security.ui/src/org/eclipse/equinox/internal/security/ui/storage/TabAdvanced.java
+++ b/bundles/org.eclipse.equinox.security.ui/src/org/eclipse/equinox/internal/security/ui/storage/TabAdvanced.java
@@ -13,7 +13,6 @@
*******************************************************************************/
package org.eclipse.equinox.internal.security.ui.storage;
-import java.util.Iterator;
import java.util.Map;
import org.eclipse.core.runtime.preferences.ConfigurationScope;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
@@ -58,8 +57,7 @@
// fill cipher selector
int position = 0;
- for (Iterator<String> i = availableCiphers.keySet().iterator(); i.hasNext();) {
- String cipherAlgorithm = i.next();
+ for (String cipherAlgorithm : availableCiphers.keySet()) {
cipherSelector.add(cipherAlgorithm, position);
if (defaultCipherAlgorithm.equals(cipherAlgorithm))
cipherSelector.select(position);
diff --git a/bundles/org.eclipse.equinox.security.ui/src/org/eclipse/equinox/internal/security/ui/storage/TabPassword.java b/bundles/org.eclipse.equinox.security.ui/src/org/eclipse/equinox/internal/security/ui/storage/TabPassword.java
index 07bd6b9..31433f1 100644
--- a/bundles/org.eclipse.equinox.security.ui/src/org/eclipse/equinox/internal/security/ui/storage/TabPassword.java
+++ b/bundles/org.eclipse.equinox.security.ui/src/org/eclipse/equinox/internal/security/ui/storage/TabPassword.java
@@ -13,8 +13,8 @@
*******************************************************************************/
package org.eclipse.equinox.internal.security.ui.storage;
-import java.util.*;
-import java.util.List;
+import java.util.HashSet;
+import java.util.Set;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.*;
import org.eclipse.equinox.internal.security.storage.friends.*;
@@ -194,10 +194,8 @@
TableColumn priorityColumn = new TableColumn(providerTable, SWT.CENTER);
priorityColumn.setText(SecUIMessages.priorityColumn);
- List<PasswordProviderDescription> availableModules = InternalExchangeUtils.passwordProvidersFind();
HashSet<String> disabledModules = getDisabledModules();
- for (Iterator<PasswordProviderDescription> i = availableModules.iterator(); i.hasNext();) {
- PasswordProviderDescription module = i.next();
+ for (PasswordProviderDescription module : InternalExchangeUtils.passwordProvidersFind()) {
TableItem item = new TableItem(providerTable, SWT.NONE);
item.setText(new String[] {module.getName(), Integer.toString(module.getPriority())});
item.setData(module);
diff --git a/bundles/org.eclipse.equinox.weaving.hook/src/org/eclipse/equinox/weaving/hooks/SupplementerRegistry.java b/bundles/org.eclipse.equinox.weaving.hook/src/org/eclipse/equinox/weaving/hooks/SupplementerRegistry.java
index eea5252..7a1cae8 100644
--- a/bundles/org.eclipse.equinox.weaving.hook/src/org/eclipse/equinox/weaving/hooks/SupplementerRegistry.java
+++ b/bundles/org.eclipse.equinox.weaving.hook/src/org/eclipse/equinox/weaving/hooks/SupplementerRegistry.java
@@ -7,11 +7,11 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* Matthew Webster initial implementation
- * Martin Lippert supplementing mechanism reworked
- * Heiko Seeberger Enhancements for service dynamics
+ * Martin Lippert supplementing mechanism reworked
+ * Heiko Seeberger Enhancements for service dynamics
* Martin Lippert fragment handling fixed
*******************************************************************************/
@@ -23,7 +23,6 @@
import java.util.Dictionary;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -42,7 +41,7 @@
/**
* The supplementer registry controls the set of installed supplementer bundles
* and calculates which other bundles are supplemented by them.
- *
+ *
* @author mlippert
*/
public class SupplementerRegistry implements ISupplementerRegistry {
@@ -52,7 +51,7 @@
* names (and optionally, version numbers) of any bundles supplemented by
* this bundle. All supplemented bundles will have all the exported packages
* of this bundle added to their imports list
- *
+ *
* <p>
* The attribute value may be retrieved from the <code>Dictionary</code>
* object returned by the <code>Bundle.getHeaders</code> method.
@@ -64,7 +63,7 @@
* names (and optionally, version numbers) of the packages that the bundle
* supplements. All exporters of one of these packages will have the
* exported packages of this bundle added to their imports list.
- *
+ *
* <p>
* The attribute value may be retrieved from the <code>Dictionary</code>
* object returned by the <code>Bundle.getHeaders</code> method.
@@ -76,7 +75,7 @@
* names (and optionally, version numbers) of the packages that the bundle
* supplements. All importers of one of these packages will have the
* exported packages of this bundle added to their imports in addition.
- *
+ *
* <p>
* The attribute value may be retrieved from the <code>Dictionary</code>
* object returned by the <code>Bundle.getHeaders</code> method.
@@ -155,9 +154,7 @@
private void addSupplementedBundle(final Bundle supplementedBundle,
final List<Supplementer> supplementers) {
- for (final Iterator<Supplementer> iterator = supplementers.iterator(); iterator
- .hasNext();) {
- final Supplementer supplementer = iterator.next();
+ for (final Supplementer supplementer : supplementers) {
supplementer.addSupplementedBundle(supplementedBundle);
}
}
@@ -167,7 +164,8 @@
* boolean)
*/
@Override
- public void addSupplementer(final Bundle bundle, final boolean updateBundles) {
+ public void addSupplementer(final Bundle bundle,
+ final boolean updateBundles) {
try {
final Dictionary<?, ?> manifest = bundle.getHeaders(""); //$NON-NLS-1$
final ManifestElement[] supplementBundle = ManifestElement
@@ -184,7 +182,8 @@
|| supplementExporter != null) {
final Bundle[] hosts = this.packageAdmin.getHosts(bundle);
- final Bundle host = hosts != null && hosts.length == 1 ? hosts[0]
+ final Bundle host = hosts != null && hosts.length == 1
+ ? hosts[0]
: null;
final Supplementer newSupplementer = new Supplementer(bundle,
@@ -215,9 +214,7 @@
if (supplementers.size() > 0
&& !this.dontWeaveTheseBundles.contains(symbolicName)) {
result = new LinkedList<Supplementer>();
- for (final Iterator<Supplementer> i = supplementers.values()
- .iterator(); i.hasNext();) {
- final Supplementer supplementer = i.next();
+ for (Supplementer supplementer : supplementers.values()) {
if (isSupplementerMatching(symbolicName, imports, exports,
supplementer)) {
result.add(supplementer);
@@ -262,8 +259,8 @@
final String supplementerName = supplementer.getSymbolicName();
if (!supplementerName.equals(symbolicName)) {
if (supplementer.matchSupplementer(symbolicName)
- || (imports != null && supplementer
- .matchesSupplementImporter(imports))
+ || (imports != null
+ && supplementer.matchesSupplementImporter(imports))
|| (exports != null && supplementer
.matchesSupplementExporter(exports))) {
return true;
@@ -274,7 +271,7 @@
/**
* Refreshes the given bundles
- *
+ *
* @param bundles The bundles to refresh
*/
@Override
@@ -306,13 +303,12 @@
if (supplementers.containsKey(bundle.getSymbolicName())) {
// remove the supplementer from the list of supplementers
- final Supplementer supplementer = supplementers.get(bundle
- .getSymbolicName());
+ final Supplementer supplementer = supplementers
+ .get(bundle.getSymbolicName());
supplementers.remove(bundle.getSymbolicName());
- if (AbstractWeavingHook.verbose)
- System.err
- .println("[org.eclipse.equinox.weaving.hook] info removing supplementer " //$NON-NLS-1$
- + bundle.getSymbolicName());
+ if (AbstractWeavingHook.verbose) System.err.println(
+ "[org.eclipse.equinox.weaving.hook] info removing supplementer " //$NON-NLS-1$
+ + bundle.getSymbolicName());
// refresh bundles that where supplemented by this bundle
final Bundle[] supplementedBundles = supplementer
@@ -321,8 +317,8 @@
final List<Bundle> bundlesToRefresh = new ArrayList<Bundle>(
supplementedBundles.length);
for (final Bundle bundleToRefresh : supplementedBundles) {
- if (this.adaptorProvider.getAdaptor(bundleToRefresh
- .getBundleId()) != null) {
+ if (this.adaptorProvider.getAdaptor(
+ bundleToRefresh.getBundleId()) != null) {
bundlesToRefresh.add(bundleToRefresh);
}
}
@@ -333,11 +329,12 @@
}
}
- // remove this supplementer from the list of supplementers per other bundle
+ // remove this supplementer from the list of supplementers per other bundle
for (Bundle supplementedBundle : supplementedBundles) {
final long bundleId = supplementedBundle.getBundleId();
final List<Supplementer> supplementerList = new ArrayList<Supplementer>(
- Arrays.asList(this.supplementersByBundle.get(bundleId)));
+ Arrays.asList(
+ this.supplementersByBundle.get(bundleId)));
supplementerList.remove(supplementer);
this.supplementersByBundle.put(bundleId,
supplementerList.toArray(new Supplementer[0]));
@@ -346,9 +343,7 @@
}
private void removeSupplementedBundle(final Bundle bundle) {
- for (final Iterator<Supplementer> iterator = this.supplementers
- .values().iterator(); iterator.hasNext();) {
- final Supplementer supplementer = iterator.next();
+ for (final Supplementer supplementer : this.supplementers.values()) {
supplementer.removeSupplementedBundle(bundle);
}
}
@@ -362,8 +357,8 @@
try {
final Bundle bundle = installedBundle;
// skip the bundle itself, just resupplement already installed bundles
- if (bundle.getSymbolicName().equals(
- supplementer.getSymbolicName())) {
+ if (bundle.getSymbolicName()
+ .equals(supplementer.getSymbolicName())) {
continue;
}
// skip bundles that should not be woven
@@ -401,10 +396,10 @@
this.supplementersByBundle.put(bundle.getBundleId(),
enhancedSupplementerList
- .toArray(new Supplementer[0]));
+ .toArray(new Supplementer[0]));
}
}
- }catch (final BundleException e) {
+ } catch (final BundleException e) {
e.printStackTrace();
}
}