diff options
author | Carsten Hammer | 2019-11-19 21:04:42 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2019-12-13 19:01:10 +0000 |
commit | 42ba761663d1e2ec1df351ba96e586837f5509c6 (patch) | |
tree | 954d7f419ca5cf6935fbeb5946a2f4dfb061c57a | |
parent | 42e3fcc319b639637559276fa037d25599302be5 (diff) | |
download | rt.equinox.bundles-I20200104-0625.tar.gz rt.equinox.bundles-I20200104-0625.tar.xz rt.equinox.bundles-I20200104-0625.zip |
Use jdk 5 for-each loopY20200103-2350Y20191217-0600I20200105-1800I20200105-0955I20200105-0600I20200104-1800I20200104-0625I20200104-0600I20200103-1800I20200102-1800I20200101-1800I20191231-1800I20191230-1800I20191229-2200I20191229-1800I20191228-1800I20191227-1800I20191226-1800I20191225-1800I20191224-1800I20191223-1800I20191222-1800I20191221-2205I20191221-1800I20191220-1805I20191219-1800I20191218-1805I20191218-0015I20191217-1800I20191216-1805I20191215-1800I20191214-1800I20191213-1805
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>
8 files changed, 46 insertions, 58 deletions
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 622b897e6..4fecb9f44 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 @@ public class StructuredTextTypesCollector implements IRegistryEventListener { } 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 205b92d6c..bffe3009e 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 @@ public class SortedProperties extends Properties { 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 951891399..186434770 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 @@ public class TableWriter { 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 @@ public class TableWriter { 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 0ec2d8e40..1ede6fa77 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 @@ public class StorageAbstractTest { @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 258a5526f..23365f9b6 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 @@ public class X509CertificateAttributeContentProvider implements IStructuredConte 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 e6c5aa018..972b5a808 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 @@ public class TabAdvanced { // 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 07bd6b9bd..31433f105 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 @@ public class TabPassword { 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 eea5252b8..7a1cae8ac 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.Collections; 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 @@ import org.osgi.service.packageadmin.PackageAdmin; /** * 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 @@ public class SupplementerRegistry implements ISupplementerRegistry { * 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 @@ public class SupplementerRegistry implements ISupplementerRegistry { * 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 @@ public class SupplementerRegistry implements ISupplementerRegistry { * 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 @@ public class SupplementerRegistry implements ISupplementerRegistry { 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 @@ public class SupplementerRegistry implements ISupplementerRegistry { * 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 @@ public class SupplementerRegistry implements ISupplementerRegistry { || 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 @@ public class SupplementerRegistry implements ISupplementerRegistry { 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 @@ public class SupplementerRegistry implements ISupplementerRegistry { 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 @@ public class SupplementerRegistry implements ISupplementerRegistry { /** * Refreshes the given bundles - * + * * @param bundles The bundles to refresh */ @Override @@ -306,13 +303,12 @@ public class SupplementerRegistry implements ISupplementerRegistry { 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 @@ public class SupplementerRegistry implements ISupplementerRegistry { 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 @@ public class SupplementerRegistry implements ISupplementerRegistry { } } - // 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 @@ public class SupplementerRegistry implements ISupplementerRegistry { } 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 @@ public class SupplementerRegistry implements ISupplementerRegistry { 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 @@ public class SupplementerRegistry implements ISupplementerRegistry { this.supplementersByBundle.put(bundle.getBundleId(), enhancedSupplementerList - .toArray(new Supplementer[0])); + .toArray(new Supplementer[0])); } } - }catch (final BundleException e) { + } catch (final BundleException e) { e.printStackTrace(); } } |