Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Hammer2019-11-19 20:44:12 +0000
committerAlexander Kurtakov2019-12-12 07:43:16 +0000
commit1d97e1ec56c03051e9c82392cf34bf09bcfc2f66 (patch)
tree946cf9cb024261a5a7b6f64205488b096cff6e1d
parent3a7f1998cf34fb5c54803683ef3fa4be936ab5c6 (diff)
downloadrt.equinox.bundles-1d97e1ec56c03051e9c82392cf34bf09bcfc2f66.tar.gz
rt.equinox.bundles-1d97e1ec56c03051e9c82392cf34bf09bcfc2f66.tar.xz
rt.equinox.bundles-1d97e1ec56c03051e9c82392cf34bf09bcfc2f66.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: I396e882bf1dad9f82231c90f95532162051c3d3b Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de>
-rw-r--r--bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/AppPersistence.java7
-rw-r--r--bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseAppContainer.java4
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/StructuredTextTypesCollector.java16
-rw-r--r--bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationDictionary.java5
-rw-r--r--bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationStore.java12
-rw-r--r--bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/EventDispatcher.java3
-rw-r--r--bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ManagedServiceFactoryTracker.java22
-rw-r--r--bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/PluginManager.java8
-rw-r--r--bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/reliablefile/ReliableFile.java18
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/AdapterManager.java3
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/ReferenceHashSet.java7
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Path.java3
12 files changed, 51 insertions, 57 deletions
diff --git a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/AppPersistence.java b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/AppPersistence.java
index cf18f42f6..1fe0c63d6 100644
--- a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/AppPersistence.java
+++ b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/AppPersistence.java
@@ -299,8 +299,8 @@ public class AppPersistence implements ServiceTrackerCustomizer {
try (ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(locksData))) {
out.writeInt(DATA_VERSION);
out.writeInt(locks.size());
- for (Iterator<String> iterLocks = locks.iterator(); iterLocks.hasNext();)
- out.writeUTF(iterLocks.next());
+ for (String lock : locks)
+ out.writeUTF(lock);
}
}
@@ -309,8 +309,7 @@ public class AppPersistence implements ServiceTrackerCustomizer {
try (ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(schedulesData))) {
out.writeInt(DATA_VERSION);
out.writeInt(scheduledApps.size());
- for (Iterator<EclipseScheduledApplication> apps = scheduledApps.values().iterator(); apps.hasNext();) {
- EclipseScheduledApplication app = apps.next();
+ for (EclipseScheduledApplication app : scheduledApps.values()) {
writeStringOrNull(out, app.getScheduleId());
writeStringOrNull(out, app.getAppPid());
writeStringOrNull(out, app.getTopic());
diff --git a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseAppContainer.java b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseAppContainer.java
index 6ad86589e..5e5773a22 100644
--- a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseAppContainer.java
+++ b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseAppContainer.java
@@ -472,8 +472,8 @@ public class EclipseAppContainer implements IRegistryEventListener, SynchronousB
private void refreshAppDescriptors() {
synchronized (lock) {
- for (Iterator<EclipseAppDescriptor> allApps = apps.values().iterator(); allApps.hasNext();)
- allApps.next().refreshProperties();
+ for (EclipseAppDescriptor eclipseAppDescriptor : apps.values())
+ eclipseAppDescriptor.refreshProperties();
}
}
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 4ba133306..622b897e6 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
@@ -94,22 +94,22 @@ public class StructuredTextTypesCollector implements IRegistryEventListener {
IExtensionPoint extPoint = registry.getExtensionPoint(EXT_POINT);
IExtension[] extensions = extPoint.getExtensions();
- for (int i = 0; i < extensions.length; i++) {
- IConfigurationElement[] confElements = extensions[i].getConfigurationElements();
- for (int j = 0; j < confElements.length; j++) {
- if (!CE_NAME.equals(confElements[j].getName()))
- StructuredTextActivator.logError("BiDi types: unexpected element name " + confElements[j].getName(), new IllegalArgumentException()); //$NON-NLS-1$
- String type = confElements[j].getAttribute(ATTR_TYPE);
+ for (IExtension extension : extensions) {
+ IConfigurationElement[] confElements = extension.getConfigurationElements();
+ for (IConfigurationElement confElement : confElements) {
+ 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);
Object handler;
try {
- handler = confElements[j].createExecutableExtension(ATTR_HANDLER);
+ handler = confElement.createExecutableExtension(ATTR_HANDLER);
} catch (CoreException e) {
StructuredTextActivator.logError("BiDi types: unable to create handler for " + type, e); //$NON-NLS-1$
continue;
}
if (handler instanceof StructuredTextTypeHandler) {
types.put(type, (StructuredTextTypeHandler) handler);
- factories.put(type, confElements[j]);
+ factories.put(type, confElement);
}
}
}
diff --git a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationDictionary.java b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationDictionary.java
index 3465f73e2..1f009ea00 100644
--- a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationDictionary.java
+++ b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationDictionary.java
@@ -55,9 +55,8 @@ public class ConfigurationDictionary extends Dictionary<String, Object> implemen
// Is it a Collection of simples
if (value instanceof Collection) {
- Collection<?> valueCollection = (Collection<?>) value;
- for (Iterator<?> it = valueCollection.iterator(); it.hasNext();) {
- Class<?> containedClazz = it.next().getClass();
+ for (Object simple : (Collection<?>) value) {
+ Class<?> containedClazz = simple.getClass();
if (!simples.contains(containedClazz)) {
throw new IllegalArgumentException(containedClazz.getName() + " in " + clazz.getName()); //$NON-NLS-1$
}
diff --git a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationStore.java b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationStore.java
index 08e04544e..16f385eb7 100644
--- a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationStore.java
+++ b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationStore.java
@@ -46,8 +46,8 @@ class ConfigurationStore {
store.mkdir();
File[] configurationFiles = store.listFiles();
- for (int i = 0; i < configurationFiles.length; ++i) {
- String configurationFileName = configurationFiles[i].getName();
+ for (File configurationFile : configurationFiles) {
+ String configurationFileName = configurationFile.getName();
if (!configurationFileName.endsWith(CFG_EXT))
continue;
@@ -55,7 +55,7 @@ class ConfigurationStore {
ObjectInputStream ois = null;
boolean deleteFile = false;
try {
- ris = new ReliableFileInputStream(configurationFiles[i]);
+ ris = new ReliableFileInputStream(configurationFile);
ois = new ObjectInputStream(ris);
@SuppressWarnings("unchecked")
Dictionary<String, Object> dictionary = (Dictionary<String, Object>) ois.readObject();
@@ -67,7 +67,7 @@ class ConfigurationStore {
dictionary.remove(ConfigurationAdmin.SERVICE_BUNDLELOCATION);
}
}
- ConfigurationImpl config = new ConfigurationImpl(configurationAdminFactory, this, dictionary, configurationFiles[i]);
+ ConfigurationImpl config = new ConfigurationImpl(configurationAdminFactory, this, dictionary, configurationFile);
configurations.put(config.getPid(), config);
} catch (IOException e) {
String message = e.getMessage();
@@ -94,8 +94,8 @@ class ConfigurationStore {
}
}
if (deleteFile) {
- ReliableFile.delete(configurationFiles[i]);
- configurationFiles[i].delete();
+ ReliableFile.delete(configurationFile);
+ configurationFile.delete();
}
}
}
diff --git a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/EventDispatcher.java b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/EventDispatcher.java
index c1ba3b4cb..cda557bda 100644
--- a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/EventDispatcher.java
+++ b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/EventDispatcher.java
@@ -80,8 +80,7 @@ public class EventDispatcher {
if (refs == null)
return;
- for (int i = 0; i < refs.length; ++i) {
- final ServiceReference<ConfigurationListener> ref = refs[i];
+ for (final ServiceReference<ConfigurationListener> ref : refs) {
queue.put(new Runnable() {
@Override
public void run() {
diff --git a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ManagedServiceFactoryTracker.java b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ManagedServiceFactoryTracker.java
index 04bea731b..b6c40efdd 100644
--- a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ManagedServiceFactoryTracker.java
+++ b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ManagedServiceFactoryTracker.java
@@ -203,24 +203,24 @@ class ManagedServiceFactoryTracker extends ServiceTracker<ManagedServiceFactory,
qualifiedPids: for (String qualifiedPid : qualifiedPids) {
ConfigurationImpl[] configs = configurationStore.getFactoryConfigurations(qualifiedPid);
try {
- for (int i = 0; i < configs.length; ++i) {
- configs[i].lock();
+ for (ConfigurationImpl config : configs) {
+ config.lock();
}
boolean foundConfig = false;
- for (int i = 0; i < configs.length; ++i) {
- if (configs[i].isDeleted()) {
+ for (ConfigurationImpl config : configs) {
+ if (config.isDeleted()) {
// ignore this config
} else {
- String location = configs[i].getLocation();
+ String location = config.getLocation();
boolean shouldBind = location == null || !location.startsWith("?"); //$NON-NLS-1$
boolean hasLocPermission = configurationAdminFactory.checkTargetPermission(location, reference);
if (hasLocPermission) {
- if (shouldBind && configs[i].bind(ConfigurationAdminImpl.getLocation(reference.getBundle())) || !shouldBind) {
- Dictionary<String, Object> properties = configurationAdminFactory.modifyConfiguration(reference, configs[i]);
- asynchUpdated(serviceFactory, configs[i].getPid(), properties);
+ if (shouldBind && config.bind(ConfigurationAdminImpl.getLocation(reference.getBundle())) || !shouldBind) {
+ Dictionary<String, Object> properties = configurationAdminFactory.modifyConfiguration(reference, config);
+ asynchUpdated(serviceFactory, config.getPid(), properties);
foundConfig = true;
} else {
- configurationAdminFactory.log(LogService.LOG_WARNING, "Configuration for " + Constants.SERVICE_PID + "=" + configs[i].getPid() + " could not be bound to " + ConfigurationAdminImpl.getLocation(reference.getBundle())); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+ configurationAdminFactory.log(LogService.LOG_WARNING, "Configuration for " + Constants.SERVICE_PID + "=" + config.getPid() + " could not be bound to " + ConfigurationAdminImpl.getLocation(reference.getBundle())); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
}
}
}
@@ -229,8 +229,8 @@ class ManagedServiceFactoryTracker extends ServiceTracker<ManagedServiceFactory,
break qualifiedPids;
}
} finally {
- for (int i = 0; i < configs.length; ++i)
- configs[i].unlock();
+ for (ConfigurationImpl config : configs)
+ config.unlock();
}
}
}
diff --git a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/PluginManager.java b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/PluginManager.java
index 0704b9367..9b749c8b8 100644
--- a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/PluginManager.java
+++ b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/PluginManager.java
@@ -44,8 +44,8 @@ public class PluginManager {
return null;
ServiceReference<ConfigurationPlugin>[] references = pluginTracker.getServiceReferences();
- for (int i = 0; i < references.length; ++i) {
- Collection<?> pids = getStringProperty(references[i].getProperty(ConfigurationPlugin.CM_TARGET));
+ for (ServiceReference<ConfigurationPlugin> reference : references) {
+ Collection<?> pids = getStringProperty(reference.getProperty(ConfigurationPlugin.CM_TARGET));
if (pids != null) {
String pid = config.getFactoryPid();
if (pid == null) {
@@ -54,9 +54,9 @@ public class PluginManager {
if (!pids.contains(pid))
continue;
}
- ConfigurationPlugin plugin = pluginTracker.getService(references[i]);
+ ConfigurationPlugin plugin = pluginTracker.getService(reference);
if (plugin != null) {
- int rank = getRank(references[i]);
+ int rank = getRank(reference);
if (rank < 0 || rank > 1000) {
plugin.modifyConfiguration(managedReference, ((ConfigurationDictionary) properties).copy());
} else {
diff --git a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/reliablefile/ReliableFile.java b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/reliablefile/ReliableFile.java
index 9ed2445d0..8d8e3c492 100644
--- a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/reliablefile/ReliableFile.java
+++ b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/reliablefile/ReliableFile.java
@@ -256,14 +256,14 @@ public class ReliableFile {
File textFile = null;
InputStream textIS = null;
- for (int idx = 0; idx < generations.length; idx++) {
+ for (int generation2 : generations) {
if (generation != 0) {
- if (generations[idx] > generation || (failOnPrimary && generations[idx] != generation))
+ if (generation2 > generation || (failOnPrimary && generation2 != generation))
continue;
}
File file;
- if (generations[idx] != 0)
- file = new File(parent, name + '.' + generations[idx]);
+ if (generation2 != 0)
+ file = new File(parent, name + '.' + generation2);
else
file = referenceFile;
InputStream is = null;
@@ -604,11 +604,11 @@ public class ReliableFile {
String name = deleteFile.getName();
File parent = new File(deleteFile.getParent());
synchronized (cacheFiles) {
- for (int idx = 0; idx < generations.length; idx++) {
+ for (int generation : generations) {
// base files (.0 in generations[]) will never be deleted
- if (generations[idx] == 0)
+ if (generation == 0)
continue;
- File file = new File(parent, name + '.' + generations[idx]);
+ File file = new File(parent, name + '.' + generation);
if (file.exists()) {
file.delete();
}
@@ -647,8 +647,8 @@ public class ReliableFile {
}
files = new String[list.size()];
int idx = 0;
- for (Iterator<String> iter = list.iterator(); iter.hasNext();) {
- files[idx++] = iter.next();
+ for (String string : list) {
+ files[idx++] = string;
}
return files;
}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/AdapterManager.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/AdapterManager.java
index 7a1f881f4..f03be7e86 100644
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/AdapterManager.java
+++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/AdapterManager.java
@@ -103,8 +103,7 @@ public final class AdapterManager implements IAdapterManager {
List<IAdapterFactory> factoryList = getFactories().get(typeName);
if (factoryList == null)
return;
- for (int i = 0, imax = factoryList.size(); i < imax; i++) {
- IAdapterFactory factory = factoryList.get(i);
+ for (IAdapterFactory factory : factoryList) {
if (factory instanceof IAdapterFactoryExt) {
String[] adapters = ((IAdapterFactoryExt) factory).getAdapterNames();
for (String adapter : adapters) {
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/ReferenceHashSet.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/ReferenceHashSet.java
index 83c0be1ff..8a17df038 100644
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/ReferenceHashSet.java
+++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/ReferenceHashSet.java
@@ -269,8 +269,8 @@ public class ReferenceHashSet<T> {
ReferenceHashSet<T> newHashSet = new ReferenceHashSet<>(this.elementSize * 2); // double the number of expected elements
newHashSet.referenceQueue = this.referenceQueue;
HashedReference<T> currentValue;
- for (int i = 0, length = this.values.length; i < length; i++)
- if ((currentValue = this.values[i]) != null)
+ for (HashedReference<T> value : this.values)
+ if ((currentValue = value) != null)
newHashSet.addValue(currentValue);
this.values = newHashSet.values;
@@ -307,8 +307,7 @@ public class ReferenceHashSet<T> {
@Override
public String toString() {
StringBuilder buffer = new StringBuilder("{"); //$NON-NLS-1$
- for (int i = 0, length = this.values.length; i < length; i++) {
- HashedReference<T> value = this.values[i];
+ for (HashedReference<T> value : this.values) {
if (value != null) {
Object ref = value.get();
if (ref != null) {
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Path.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Path.java
index dee69a3a0..42b19f560 100644
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Path.java
+++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Path.java
@@ -351,8 +351,7 @@ public class Path implements IPath, Cloneable {
*/
private boolean canonicalize() {
//look for segments that need canonicalizing
- for (int i = 0, max = segments.length; i < max; i++) {
- String segment = segments[i];
+ for (String segment : segments) {
if (segment.charAt(0) == '.' && (segment.equals("..") || segment.equals("."))) { //$NON-NLS-1$ //$NON-NLS-2$
//path needs to be canonicalized
collapseParentReferences();

Back to the top