Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Hammer2019-09-25 20:03:14 +0000
committerAlexander Kurtakov2019-10-15 18:36:25 +0000
commitb49385ec3fed567da7b579b1ffd2b6c577ba607e (patch)
tree42e89403147a95b16e819e0131bca7e01af8de22
parent81b0e1408b813d942846cac37f15ceb73601c71a (diff)
downloadrt.equinox.p2-I20191015-1800.tar.gz
rt.equinox.p2-I20191015-1800.tar.xz
rt.equinox.p2-I20191015-1800.zip
Use jdk 5 for-each loopI20191015-1800
Replace simple uses of Iterator with a corresponding for-loop. Also add missing braces on loops as necessary. Change-Id: I5af7e2968912396e364a47174e84bdd98ecc071e Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de>
-rw-r--r--bundles/org.eclipse.equinox.simpleconfigurator.manipulator/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.equinox.simpleconfigurator.manipulator/pom.xml2
-rw-r--r--bundles/org.eclipse.equinox.simpleconfigurator.manipulator/src/org/eclipse/equinox/internal/simpleconfigurator/manipulator/SimpleConfiguratorManipulatorImpl.java77
-rw-r--r--bundles/org.eclipse.equinox.simpleconfigurator.manipulator/src/org/eclipse/equinox/internal/simpleconfigurator/manipulator/SimpleConfiguratorManipulatorUtils.java10
-rw-r--r--bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/ConfigApplier.java7
-rw-r--r--bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/utils/Utils.java4
6 files changed, 54 insertions, 48 deletions
diff --git a/bundles/org.eclipse.equinox.simpleconfigurator.manipulator/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.simpleconfigurator.manipulator/META-INF/MANIFEST.MF
index 520a77fbf..1a4fc4d5e 100644
--- a/bundles/org.eclipse.equinox.simpleconfigurator.manipulator/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.simpleconfigurator.manipulator/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %bundleName
Bundle-SymbolicName: org.eclipse.equinox.simpleconfigurator.manipulator;singleton:=true
-Bundle-Version: 2.1.300.qualifier
+Bundle-Version: 2.1.400.qualifier
Bundle-Localization: plugin
Bundle-ActivationPolicy: lazy
Import-Package: org.eclipse.equinox.frameworkadmin;version="[2.0.0,3.0.0)",
diff --git a/bundles/org.eclipse.equinox.simpleconfigurator.manipulator/pom.xml b/bundles/org.eclipse.equinox.simpleconfigurator.manipulator/pom.xml
index 50b152c4e..8dab23d57 100644
--- a/bundles/org.eclipse.equinox.simpleconfigurator.manipulator/pom.xml
+++ b/bundles/org.eclipse.equinox.simpleconfigurator.manipulator/pom.xml
@@ -9,6 +9,6 @@
</parent>
<groupId>org.eclipse.equinox</groupId>
<artifactId>org.eclipse.equinox.simpleconfigurator.manipulator</artifactId>
- <version>2.1.300-SNAPSHOT</version>
+ <version>2.1.400-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/bundles/org.eclipse.equinox.simpleconfigurator.manipulator/src/org/eclipse/equinox/internal/simpleconfigurator/manipulator/SimpleConfiguratorManipulatorImpl.java b/bundles/org.eclipse.equinox.simpleconfigurator.manipulator/src/org/eclipse/equinox/internal/simpleconfigurator/manipulator/SimpleConfiguratorManipulatorImpl.java
index d9e1bf4e0..2013ac8af 100644
--- a/bundles/org.eclipse.equinox.simpleconfigurator.manipulator/src/org/eclipse/equinox/internal/simpleconfigurator/manipulator/SimpleConfiguratorManipulatorImpl.java
+++ b/bundles/org.eclipse.equinox.simpleconfigurator.manipulator/src/org/eclipse/equinox/internal/simpleconfigurator/manipulator/SimpleConfiguratorManipulatorImpl.java
@@ -100,11 +100,12 @@ public class SimpleConfiguratorManipulatorImpl implements SimpleConfiguratorMani
if (info.prerequisiteLocations == null)
return false;
- for (int i = 0; i < info.prerequisiteLocations.length; i++)
- if (location.equals(info.prerequisiteLocations[i])) {
+ for (URI prerequisiteLocation : info.prerequisiteLocations) {
+ if (location.equals(prerequisiteLocation)) {
ret = true;
break;
}
+ }
return ret;
}
@@ -121,17 +122,18 @@ public class SimpleConfiguratorManipulatorImpl implements SimpleConfiguratorMani
boolean ret = false;
if (info.systemFragmentedBundleLocations == null)
return false;
- for (int i = 0; i < info.systemFragmentedBundleLocations.length; i++)
- if (location.equals(info.systemFragmentedBundleLocations[i])) {
+ for (URI systemFragmentedBundleLocation : info.systemFragmentedBundleLocations) {
+ if (location.equals(systemFragmentedBundleLocation)) {
ret = true;
break;
}
+ }
return ret;
}
private static boolean isTargetConfiguratorBundle(BundleInfo[] bInfos) {
- for (int i = 0; i < bInfos.length; i++) {
- if (isTargetConfiguratorBundle(bInfos[i].getLocation())) {
+ for (BundleInfo bInfo : bInfos) {
+ if (isTargetConfiguratorBundle(bInfo.getLocation())) {
return true;
// TODO confirm that startlevel of configurator bundle must be no larger than
// beginning start level of fw. However, there is no way to know the start level
@@ -162,8 +164,7 @@ public class SimpleConfiguratorManipulatorImpl implements SimpleConfiguratorMani
}
}
- for (Iterator<Integer> ite = bslToList.keySet().iterator(); ite.hasNext();) {
- Integer sL = ite.next();
+ for (Integer sL : bslToList.keySet()) {
List<BundleInfo> list = bslToList.get(sL);
if (sL.intValue() < configuratorSL) {
@@ -176,7 +177,7 @@ public class SimpleConfiguratorManipulatorImpl implements SimpleConfiguratorMani
for (Iterator<BundleInfo> ite2 = list.iterator(); ite2.hasNext();) {
BundleInfo bInfo = ite2.next();
if (isPrerequisiteBundles(bInfo.getLocation(), info)
- || isSystemFragmentBundle(bInfo.getLocation(), info))
+ || isSystemFragmentBundle(bInfo.getLocation(), info))
if (!isSystemBundle(bInfo.getLocation(), info))
setToInitialConfig.add(bInfo);
setToSimpleConfig.add(bInfo);
@@ -188,7 +189,7 @@ public class SimpleConfiguratorManipulatorImpl implements SimpleConfiguratorMani
if (found) {
if (!isSystemBundle(bInfo.getLocation(), info))
if (isPrerequisiteBundles(bInfo.getLocation(), info)
- || isSystemFragmentBundle(bInfo.getLocation(), info))
+ || isSystemFragmentBundle(bInfo.getLocation(), info))
setToInitialConfig.add(bInfo);
setToSimpleConfig.add(bInfo);
continue;
@@ -229,10 +230,10 @@ public class SimpleConfiguratorManipulatorImpl implements SimpleConfiguratorMani
targetBundleInfos = manipulator.getConfigData().getBundles();
}
BundleInfo configuratorBInfo = null;
- for (int i = 0; i < targetBundleInfos.length; i++) {
- if (isTargetConfiguratorBundle(targetBundleInfos[i].getLocation())) {
- if (targetBundleInfos[i].isMarkedAsStarted()) {
- configuratorBInfo = targetBundleInfos[i];
+ for (BundleInfo targetBundleInfo : targetBundleInfos) {
+ if (isTargetConfiguratorBundle(targetBundleInfo.getLocation())) {
+ if (targetBundleInfo.isMarkedAsStarted()) {
+ configuratorBInfo = targetBundleInfo;
break;
}
}
@@ -265,8 +266,8 @@ public class SimpleConfiguratorManipulatorImpl implements SimpleConfiguratorMani
private SortedMap<Integer, List<BundleInfo>> getSortedMap(int initialSl, BundleInfo[] bInfos) {
SortedMap<Integer, List<BundleInfo>> bslToList = new TreeMap<>();
- for (int i = 0; i < bInfos.length; i++) {
- Integer sL = Integer.valueOf(bInfos[i].getStartLevel());
+ for (BundleInfo bInfo : bInfos) {
+ Integer sL = Integer.valueOf(bInfo.getStartLevel());
if (sL.intValue() == BundleInfo.NO_LEVEL)
sL = Integer.valueOf(initialSl);
List<BundleInfo> list = bslToList.get(sL);
@@ -274,7 +275,7 @@ public class SimpleConfiguratorManipulatorImpl implements SimpleConfiguratorMani
list = new LinkedList<>();
bslToList.put(sL, list);
}
- list.add(bInfos[i]);
+ list.add(bInfo);
}
return bslToList;
}
@@ -301,8 +302,9 @@ public class SimpleConfiguratorManipulatorImpl implements SimpleConfiguratorMani
StringBuffer sb = new StringBuffer();
sb.append("Missing constraints:\n"); //$NON-NLS-1$
String[] missings = state.getUnsatisfiedConstraints(bInfo);
- for (int i = 0; i < missings.length; i++)
- sb.append(" " + missings[i] + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
+ for (String missing : missings) {
+ sb.append(" " + missing + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
System.out.println(sb.toString());
}
}
@@ -569,12 +571,13 @@ public class SimpleConfiguratorManipulatorImpl implements SimpleConfiguratorMani
return;
Properties properties = new Properties();
String[] jvmArgs = manipulator.getLauncherData().getJvmArgs();
- for (int i = 0; i < jvmArgs.length; i++) {
- if (jvmArgs[i].startsWith("-D")) { //$NON-NLS-1$
- int index = jvmArgs[i].indexOf("="); //$NON-NLS-1$
- if (index > 0 && jvmArgs[i].length() > 2) {
- String key = jvmArgs[i].substring(2, index);
- String value = jvmArgs[i].substring(index + 1);
+ for (String jvmArg : jvmArgs) {
+ if (jvmArg.startsWith("-D")) {
+ //$NON-NLS-1$
+ int index = jvmArg.indexOf("="); //$NON-NLS-1$
+ if (index > 0 && jvmArg.length() > 2) {
+ String key = jvmArg.substring(2, index);
+ String value = jvmArg.substring(index + 1);
properties.setProperty(key, value);
}
}
@@ -602,21 +605,23 @@ public class SimpleConfiguratorManipulatorImpl implements SimpleConfiguratorMani
List<BundleInfo> toUninstall = new LinkedList<>();
if (exclusiveInstallation)
- for (int i = 0; i < currentBInfos.length; i++) {
+ for (BundleInfo currentBInfo : currentBInfos) {
boolean install = false;
- for (int j = 0; j < toInstall.length; j++)
- if (currentBInfos[i].getLocation().equals(toInstall[j].getLocation())) {
- install = true;
- break;
- }
- if (!install)
- toUninstall.add(currentBInfos[i]);
+ for (BundleInfo toInstall1 : toInstall) {
+ if (currentBInfo.getLocation().equals(toInstall1.getLocation())) {
+ install = true;
+ break;
+ }
}
+ if (!install) {
+ toUninstall.add(currentBInfo);
+ }
+ }
- for (int i = 0; i < toInstall.length; i++) {
+ for (BundleInfo toInstall1 : toInstall) {
try {
- bundleState.installBundle(toInstall[i]);
- } catch (RuntimeException e) {
+ bundleState.installBundle(toInstall1);
+ }catch (RuntimeException e) {
// Ignore
}
}
diff --git a/bundles/org.eclipse.equinox.simpleconfigurator.manipulator/src/org/eclipse/equinox/internal/simpleconfigurator/manipulator/SimpleConfiguratorManipulatorUtils.java b/bundles/org.eclipse.equinox.simpleconfigurator.manipulator/src/org/eclipse/equinox/internal/simpleconfigurator/manipulator/SimpleConfiguratorManipulatorUtils.java
index 73593678f..f258560cb 100644
--- a/bundles/org.eclipse.equinox.simpleconfigurator.manipulator/src/org/eclipse/equinox/internal/simpleconfigurator/manipulator/SimpleConfiguratorManipulatorUtils.java
+++ b/bundles/org.eclipse.equinox.simpleconfigurator.manipulator/src/org/eclipse/equinox/internal/simpleconfigurator/manipulator/SimpleConfiguratorManipulatorUtils.java
@@ -74,9 +74,9 @@ public class SimpleConfiguratorManipulatorUtils {
BufferedWriter writer = null;
boolean oldStyle = false;
boolean utf8 = true;
- for (int i = 0; i < simpleInfos.length; i++) {
- if (SimpleConfiguratorManipulator.SERVICE_PROP_VALUE_CONFIGURATOR_SYMBOLICNAME.equals(simpleInfos[i].getSymbolicName())) {
- Version version = new Version(simpleInfos[i].getVersion());
+ for (BundleInfo simpleInfo : simpleInfos) {
+ if (SimpleConfiguratorManipulator.SERVICE_PROP_VALUE_CONFIGURATOR_SYMBOLICNAME.equals(simpleInfo.getSymbolicName())) {
+ Version version = new Version(simpleInfo.getVersion());
if (version.compareTo(OLD_STYLE_SIMPLE_CONFIGURATOR_VERSION) < 0)
oldStyle = true;
if (version.compareTo(DEFAULT_ENCODING_CONFIGURATOR_VERSION) < 0)
@@ -97,8 +97,8 @@ public class SimpleConfiguratorManipulatorUtils {
writer.newLine();
// bundle info lines
- for (int i = 0; i < simpleInfos.length; i++) {
- writer.write(createBundleInfoLine(simpleInfos[i], oldStyle));
+ for (BundleInfo simpleInfo : simpleInfos) {
+ writer.write(createBundleInfoLine(simpleInfo, oldStyle));
writer.newLine();
}
writer.flush();
diff --git a/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/ConfigApplier.java b/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/ConfigApplier.java
index 92d488fa1..61999ce0b 100644
--- a/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/ConfigApplier.java
+++ b/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/ConfigApplier.java
@@ -458,10 +458,11 @@ class ConfigApplier {
//Build a set with all the bundles from the system
Set<Bundle> removedBundles = new HashSet<>(allBundles.length);
// configurator.setPrerequisiteBundles(allBundles);
- for (int i = 0; i < allBundles.length; i++) {
- if (allBundles[i].getBundleId() == 0)
+ for (Bundle allBundle : allBundles) {
+ if (allBundle.getBundleId() == 0) {
continue;
- removedBundles.add(allBundles[i]);
+ }
+ removedBundles.add(allBundle);
}
//Remove all the bundles appearing in the final list from the set of installed bundles
diff --git a/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/utils/Utils.java b/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/utils/Utils.java
index 31b029e46..c925546bf 100644
--- a/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/utils/Utils.java
+++ b/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/utils/Utils.java
@@ -53,8 +53,8 @@ public class Utils {
return;
}
File[] children = file.listFiles();
- for (int i = 0; i < children.length; i++) {
- deleteDir(children[i]);
+ for (File child : children) {
+ deleteDir(child);
}
if (!file.delete())
throw new IOException("Fail to delete Dir(" + file.getAbsolutePath() + ")");

Back to the top