Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Hammer2019-09-25 16:01:27 -0400
committerCarsten Hammer2019-10-17 15:17:49 -0400
commitf0a65a97da4a2c355ab58e7ba26a6838b88fd38f (patch)
tree5cdb133890774c48b915971960751a85dacae6c1
parentd312e0b88e54d9277d335ba1d8fe9f54cfd9721e (diff)
downloadrt.equinox.p2-f0a65a97da4a2c355ab58e7ba26a6838b88fd38f.tar.gz
rt.equinox.p2-f0a65a97da4a2c355ab58e7ba26a6838b88fd38f.tar.xz
rt.equinox.p2-f0a65a97da4a2c355ab58e7ba26a6838b88fd38f.zip
Use jdk 5 for-each loopI20191018-1800I20191018-0720
Replace simple uses of Iterator with a corresponding for-loop. Also add missing braces on loops as necessary. Change-Id: Ie81b4e50a64094ed372fd24938ab76d7f1d05a01 Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de>
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/BackupStore.java24
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/NativePackageExtractionApplication.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/BlockMacUpdate.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/ChmodAction.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/CopyAction.java10
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/UnzipAction.java5
6 files changed, 31 insertions, 24 deletions
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/BackupStore.java b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/BackupStore.java
index a02815cec..14cde8ab4 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/BackupStore.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/BackupStore.java
@@ -347,8 +347,9 @@ public class BackupStore implements IBackupStore {
if (file.isDirectory()) {
File[] files = file.listFiles();
if (files != null)
- for (int i = 0; i < files.length; i++)
- backupAll(files[i]);
+ for (File f : files) {
+ backupAll(f);
+ }
}
backup(file);
}
@@ -367,8 +368,9 @@ public class BackupStore implements IBackupStore {
if (file.isDirectory()) {
File[] files = file.listFiles();
if (files != null)
- for (int i = 0; i < files.length; i++)
- backupCopyAll(files[i]);
+ for (File f : files) {
+ backupCopyAll(f);
+ }
// if directory was empty, it needs to be backed up and then recreated
//
if (files == null || files.length == 0) {
@@ -588,9 +590,9 @@ public class BackupStore implements IBackupStore {
if (file.isDirectory()) {
File[] children = file.listFiles();
if (children != null) {
- for (int i = 0; i < children.length; i++) {
+ for (File child : children) {
// we will not stop even if some deletion failed
- fullyDelete(new File(file, children[i].getName()));
+ fullyDelete(new File(file, child.getName()));
}
}
}
@@ -608,8 +610,8 @@ public class BackupStore implements IBackupStore {
unrestorable.add(buRoot);
return;
}
- for (int i = 0; i < children.length; i++) {
- File bu = new File(buRoot, children[i].getName());
+ for (File child : children) {
+ File bu = new File(buRoot, child.getName());
File target = new File(root, bu.getName());
if (bu.isDirectory()) {
if (!target.exists() && !target.mkdir()) {
@@ -675,9 +677,9 @@ public class BackupStore implements IBackupStore {
unrestorable.add(buRoot);
return;
}
- for (int i = 0; i < children.length; i++) {
- // Names are root-chars, or drive letters in the root bu directory
- String name = children[i].getName();
+ for (File child : children) {
+ // Names are root-chars, or drive letters in the root bu directory
+ String name = child.getName();
String rName = name;
String prefix = ""; //$NON-NLS-1$
while (rName.startsWith(ROOTCHAR)) {
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/NativePackageExtractionApplication.java b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/NativePackageExtractionApplication.java
index 78795d43f..bd1fc2198 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/NativePackageExtractionApplication.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/NativePackageExtractionApplication.java
@@ -289,8 +289,9 @@ public class NativePackageExtractionApplication implements IApplication {
if (status.isMultiStatus()) {
IStatus[] children = status.getChildren();
- for (int i = 0; i < children.length; i++)
- deeplyPrint(children[i], strm, level + 1);
+ for (IStatus child : children) {
+ deeplyPrint(child, strm, level + 1);
+ }
}
}
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/BlockMacUpdate.java b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/BlockMacUpdate.java
index ecbe73204..394408299 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/BlockMacUpdate.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/BlockMacUpdate.java
@@ -55,9 +55,9 @@ public class BlockMacUpdate extends ProvisioningAction {
if (bundles == null)
return null;
//Return the first bundle that is not installed or uninstalled
- for (int i = 0; i < bundles.length; i++) {
- if ((bundles[i].getState() & (Bundle.INSTALLED | Bundle.UNINSTALLED)) == 0) {
- return bundles[i].getVersion();
+ for (Bundle bundle : bundles) {
+ if ((bundle.getState() & (Bundle.INSTALLED | Bundle.UNINSTALLED)) == 0) {
+ return bundle.getVersion();
}
}
return null;
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/ChmodAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/ChmodAction.java
index 2264fd22e..e45a9c36e 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/ChmodAction.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/ChmodAction.java
@@ -193,8 +193,9 @@ public class ChmodAction extends ProvisioningAction {
int i = 0;
args[i++] = "chmod"; //$NON-NLS-1$
if (options != null) {
- for (int j = 0; j < options.length; j++)
- args[i++] = options[j];
+ for (String option : options) {
+ args[i++] = option;
+ }
}
args[i++] = perms;
args[i] = fileToChmod;
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/CopyAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/CopyAction.java
index 0bbb21edb..427e40bd4 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/CopyAction.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/CopyAction.java
@@ -82,8 +82,9 @@ public class CopyAction extends ProvisioningAction {
}
// keep copied file in the profile as memento for CleanupCopy
StringBuffer copiedFileNameBuffer = new StringBuffer();
- for (int i = 0; i < copiedFiles.length; i++)
- copiedFileNameBuffer.append(copiedFiles[i].getAbsolutePath()).append(ActionConstants.PIPE);
+ for (File copiedFile : copiedFiles) {
+ copiedFileNameBuffer.append(copiedFile.getAbsolutePath()).append(ActionConstants.PIPE);
+ }
profile.setInstallableUnitProperty(iu, "copied" + ActionConstants.PIPE + originalSource + ActionConstants.PIPE + target, copiedFileNameBuffer.toString()); //$NON-NLS-1$
@@ -135,8 +136,9 @@ public class CopyAction extends ProvisioningAction {
File[] children = source.listFiles();
if (children == null)
throw new IOException("Error while retrieving children of directory: " + source); //$NON-NLS-1$
- for (int i = 0; i < children.length; i++)
- xcopy(copiedFiles, children[i], new File(target, children[i].getName()), overwrite, backupStore);
+ for (File child : children) {
+ xcopy(copiedFiles, child, new File(target, child.getName()), overwrite, backupStore);
+ }
return;
}
if (target.exists() && !overwrite)
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/UnzipAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/UnzipAction.java
index 684f8786d..77961095b 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/UnzipAction.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/UnzipAction.java
@@ -83,8 +83,9 @@ public class UnzipAction extends ProvisioningAction {
result = new Value<>(filesAsString);
StringBuffer unzippedFileNameBuffer = new StringBuffer();
- for (int i = 0; i < unzippedFiles.length; i++)
- unzippedFileNameBuffer.append(unzippedFiles[i].getAbsolutePath()).append(ActionConstants.PIPE);
+ for (File unzippedFile : unzippedFiles) {
+ unzippedFileNameBuffer.append(unzippedFile.getAbsolutePath()).append(ActionConstants.PIPE);
+ }
profile.setInstallableUnitProperty(iu, "unzipped" + ActionConstants.PIPE + originalSource + ActionConstants.PIPE + target, unzippedFileNameBuffer.toString()); //$NON-NLS-1$

Back to the top