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: Ie81b4e50a64094ed372fd24938ab76d7f1d05a01
Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de>
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 a02815c..14cde8a 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 @@
 		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 @@
 		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 @@
 		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 @@
 			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 @@
 			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 78795d4..bd1fc21 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 @@
 
 		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 ecbe732..3944082 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 @@
 		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 2264fd2..e45a9c3 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 @@
 			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 0bbb21e..427e40b 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 @@
 		}
 		// 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 @@
 			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 684f878..7796109 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 @@
 		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$