diff options
author | Carsten Hammer | 2019-09-25 19:56:04 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2019-10-14 17:32:56 +0000 |
commit | 6f7af22423d20d0eca47d33dc034525cbb446dc7 (patch) | |
tree | 67e8706b0f78de203152bd9790ae5fe8d7270c2e /bundles | |
parent | bd3a768e9e4d8cc7238025285cede988fcbe95be (diff) | |
download | rt.equinox.p2-6f7af22423d20d0eca47d33dc034525cbb446dc7.tar.gz rt.equinox.p2-6f7af22423d20d0eca47d33dc034525cbb446dc7.tar.xz rt.equinox.p2-6f7af22423d20d0eca47d33dc034525cbb446dc7.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: I1f2d6bc113d8e164f18cada8c8847feaab7a33d0
Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de>
Diffstat (limited to 'bundles')
10 files changed, 54 insertions, 57 deletions
diff --git a/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/internal/p2/garbagecollector/GarbageCollector.java b/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/internal/p2/garbagecollector/GarbageCollector.java index 719cdf642..2a169d3d2 100644 --- a/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/internal/p2/garbagecollector/GarbageCollector.java +++ b/bundles/org.eclipse.equinox.p2.garbagecollector/src/org/eclipse/equinox/internal/p2/garbagecollector/GarbageCollector.java @@ -192,15 +192,15 @@ public class GarbageCollector implements SynchronousProvisioningListener, IAgent IConfigurationElement[] configElts = registry.getConfigurationElementsFor(PT_MARKSET); //First we collect all repos and keys for the profile being GC'ed - for (int i = 0; i < configElts.length; i++) { - if (!(configElts[i].getName().equals("run"))) { //$NON-NLS-1$ + for (IConfigurationElement configElt : configElts) { + if (!(configElt.getName().equals("run"))) { + //$NON-NLS-1$ continue; } - IConfigurationElement runAttribute = configElts[i]; + IConfigurationElement runAttribute = configElt; if (runAttribute == null) { continue; } - contributeMarkSets(runAttribute, profile, true); } return true; @@ -209,20 +209,19 @@ public class GarbageCollector implements SynchronousProvisioningListener, IAgent private void traverseRegisteredProfiles() { IExtensionRegistry registry = RegistryFactory.getRegistry(); IConfigurationElement[] configElts = registry.getConfigurationElementsFor(PT_MARKSET); - for (int i = 0; i < configElts.length; i++) { - if (!(configElts[i].getName().equals("run"))) { //$NON-NLS-1$ + for (IConfigurationElement configElt : configElts) { + if (!(configElt.getName().equals("run"))) { + //$NON-NLS-1$ continue; } - IConfigurationElement runAttribute = configElts[i]; + IConfigurationElement runAttribute = configElt; if (runAttribute == null) { continue; } - IProfileRegistry profileRegistry = agent.getService(IProfileRegistry.class); if (profileRegistry == null) return; IProfile[] registeredProfiles = profileRegistry.getProfiles(); - for (IProfile registeredProfile : registeredProfiles) { contributeMarkSets(runAttribute, registeredProfile, false); } diff --git a/bundles/org.eclipse.equinox.p2.installer/src/org/eclipse/equinox/internal/p2/installer/InstallDescriptionParser.java b/bundles/org.eclipse.equinox.p2.installer/src/org/eclipse/equinox/internal/p2/installer/InstallDescriptionParser.java index a55048037..b19def06b 100644 --- a/bundles/org.eclipse.equinox.p2.installer/src/org/eclipse/equinox/internal/p2/installer/InstallDescriptionParser.java +++ b/bundles/org.eclipse.equinox.p2.installer/src/org/eclipse/equinox/internal/p2/installer/InstallDescriptionParser.java @@ -144,11 +144,11 @@ public class InstallDescriptionParser { if (rootSpec != null) { String[] rootList = getArrayFromString(rootSpec, ","); //$NON-NLS-1$ ArrayList<IVersionedId> roots = new ArrayList<>(rootList.length); - for (int i = 0; i < rootList.length; i++) { + for (String rootList1 : rootList) { try { - roots.add(VersionedId.parse(rootList[i])); + roots.add(VersionedId.parse(rootList1)); } catch (IllegalArgumentException e) { - LogHelper.log(new Status(IStatus.ERROR, InstallerActivator.PI_INSTALLER, "Invalid version in install description: " + rootList[i], e)); //$NON-NLS-1$ + LogHelper.log(new Status(IStatus.ERROR, InstallerActivator.PI_INSTALLER, "Invalid version in install description: " + rootList1, e)); //$NON-NLS-1$ } } if (!roots.isEmpty()) @@ -189,13 +189,13 @@ public class InstallDescriptionParser { private static URI[] getURIs(String spec, URI base) { String[] urlSpecs = getArrayFromString(spec, ","); //$NON-NLS-1$ ArrayList<URI> result = new ArrayList<>(urlSpecs.length); - for (int i = 0; i < urlSpecs.length; i++) { + for (String urlSpec : urlSpecs) { try { - URI uri = URIUtil.fromString(urlSpecs[i]); + URI uri = URIUtil.fromString(urlSpec); uri = URIUtil.makeAbsolute(uri, base); result.add(uri); } catch (URISyntaxException e) { - LogHelper.log(new Status(IStatus.ERROR, InstallerActivator.PI_INSTALLER, "Invalid URL in install description: " + urlSpecs[i], e)); //$NON-NLS-1$ + LogHelper.log(new Status(IStatus.ERROR, InstallerActivator.PI_INSTALLER, "Invalid URL in install description: " + urlSpec, e)); //$NON-NLS-1$ } } if (result.isEmpty()) diff --git a/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/PackStep.java b/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/PackStep.java index e5e372b84..da41e546a 100644 --- a/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/PackStep.java +++ b/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/PackStep.java @@ -36,12 +36,13 @@ public class PackStep extends CommandStep { } int result; - for (int i = 0; i < locations.length; i++) { - if (locations[i] == null) + for (String location : locations) { + if (location == null) { continue; - result = execute(new String[] {locations[i], "-V"}); //$NON-NLS-1$ + } + result = execute(new String[]{location, "-V"}); //$NON-NLS-1$ if (result == 0) { - packCommand = locations[i]; + packCommand = location; canPack = Boolean.TRUE; return true; } @@ -99,8 +100,7 @@ public class PackStep extends CommandStep { protected boolean shouldPack(File input, List<Properties> containers, Properties inf) { //1: exclude by containers // innermost jar is first on the list, it can override outer jars - for (Iterator<Properties> iterator = containers.iterator(); iterator.hasNext();) { - Properties container = iterator.next(); + for (Properties container : containers) { if (container.containsKey(Utils.MARK_EXCLUDE_CHILDREN_PACK)) { if (Boolean.parseBoolean(container.getProperty(Utils.MARK_EXCLUDE_CHILDREN_PACK))) { if (verbose) @@ -144,8 +144,7 @@ public class PackStep extends CommandStep { } //2: Defaults set in one of our containing jars - for (Iterator<Properties> iterator = containers.iterator(); iterator.hasNext();) { - Properties container = iterator.next(); + for (Properties container : containers) { if (container.containsKey(Utils.DEFAULT_PACK_ARGS)) { return container.getProperty(Utils.DEFAULT_PACK_ARGS); } diff --git a/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/UnpackStep.java b/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/UnpackStep.java index 76af1bcb0..894bf7c00 100644 --- a/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/UnpackStep.java +++ b/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/UnpackStep.java @@ -35,12 +35,13 @@ public class UnpackStep extends CommandStep { } int result; - for (int i = 0; i < locations.length; i++) { - if (locations[i] == null) + for (String location : locations) { + if (location == null) { continue; - result = execute(new String[] {locations[i], "-V"}); //$NON-NLS-1$ + } + result = execute(new String[]{location, "-V"}); //$NON-NLS-1$ if (result == 0) { - unpackCommand = locations[i]; + unpackCommand = location; canUnpack = Boolean.TRUE; return true; } diff --git a/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/Utils.java b/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/Utils.java index 57cf73fa3..1b75a563c 100644 --- a/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/Utils.java +++ b/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/Utils.java @@ -180,8 +180,9 @@ public class Utils { // for some unknown reason, list() can return null. // Just skip the children If it does. if (list != null) - for (int i = 0; i < list.length; i++) - result &= clear(new java.io.File(root, list[i])); + for (String list1 : list) { + result &= clear(new java.io.File(root, list1)); + } } return result; } @@ -194,8 +195,8 @@ public class Utils { if (packExcludes != null) { String[] excludes = toStringArray(packExcludes, ","); //$NON-NLS-1$ Set<String> packExclusions = new HashSet<>(); - for (int i = 0; i < excludes.length; i++) { - packExclusions.add(excludes[i]); + for (String exclude : excludes) { + packExclusions.add(exclude); } return packExclusions; } @@ -209,8 +210,8 @@ public class Utils { if (signExcludes != null) { String[] excludes = toStringArray(signExcludes, ","); //$NON-NLS-1$ Set<String> signExclusions = new HashSet<>(); - for (int i = 0; i < excludes.length; i++) { - signExclusions.add(excludes[i]); + for (String exclude : excludes) { + signExclusions.add(exclude); } return signExclusions; } diff --git a/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/unsigner/Unsigner.java b/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/unsigner/Unsigner.java index 89cd64660..ef6f5a5d8 100644 --- a/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/unsigner/Unsigner.java +++ b/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/unsigner/Unsigner.java @@ -40,9 +40,10 @@ public class Unsigner { jar = new ZipFile(file); if (signers != null) { - for (int i = 0; i < signers.length; i++) { - if (jar.getEntry((META_INF_PREFIX + signers[i] + SF_EXT).toUpperCase()) != null) + for (String signer : signers) { + if (jar.getEntry((META_INF_PREFIX + signer + SF_EXT).toUpperCase()) != null) { return true; + } } } else { Enumeration<? extends ZipEntry> entries = jar.entries(); @@ -133,9 +134,10 @@ public class Unsigner { return 1; } if (signers != null) { - for (int i = 0; i < signers.length; i++) { - if (entryName.equalsIgnoreCase(META_INF_PREFIX + signers[i] + SF_EXT) || entryName.equalsIgnoreCase(META_INF_PREFIX + signers[i] + RSA_EXT) || entryName.equalsIgnoreCase(META_INF_PREFIX + signers[i] + DSA_EXT)) + for (String signer : signers) { + if (entryName.equalsIgnoreCase(META_INF_PREFIX + signer + SF_EXT) || entryName.equalsIgnoreCase(META_INF_PREFIX + signer + RSA_EXT) || entryName.equalsIgnoreCase(META_INF_PREFIX + signer + DSA_EXT)) { return 2; + } } } else { if (entryName.startsWith(META_INF) && (entryName.endsWith(SF_EXT) || entryName.endsWith(RSA_EXT) || entryName.endsWith(DSA_EXT))) diff --git a/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/verifier/Verifier.java b/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/verifier/Verifier.java index db3174911..03f1c61fd 100644 --- a/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/verifier/Verifier.java +++ b/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/verifier/Verifier.java @@ -101,8 +101,8 @@ public class Verifier extends JarProcessorExecutor { }; verifier.setWorkingDirectory(workingDirectory.getAbsolutePath()); - for (int i = 0; i < input.length; i++) { - File inputFile = new File(input[i]); + for (String input1 : input) { + File inputFile = new File(input1); if (inputFile.exists()) { try { process(inputFile, Utils.PACK_GZ_FILTER, true, verifier, properties); diff --git a/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/internal/provisional/equinox/p2/jarprocessor/JarProcessor.java b/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/internal/provisional/equinox/p2/jarprocessor/JarProcessor.java index 6f3d7fc5f..19c0868c3 100644 --- a/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/internal/provisional/equinox/p2/jarprocessor/JarProcessor.java +++ b/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/internal/provisional/equinox/p2/jarprocessor/JarProcessor.java @@ -162,9 +162,7 @@ public class JarProcessor { private String recursionEffect(String entryName) { String result = null; - for (Iterator<IProcessStep> iter = steps.iterator(); iter.hasNext();) { - IProcessStep step = iter.next(); - + for (IProcessStep step : steps) { result = step.recursionEffect(entryName); if (result != null) entryName = result; @@ -239,8 +237,7 @@ public class JarProcessor { private File preProcess(File input, File tempDir) { File result = null; - for (Iterator<IProcessStep> iter = steps.iterator(); iter.hasNext();) { - IProcessStep step = iter.next(); + for (IProcessStep step : steps) { result = step.preProcess(input, tempDir, containingInfs); if (result != null) input = result; @@ -250,8 +247,7 @@ public class JarProcessor { private File postProcess(File input, File tempDir) { File result = null; - for (Iterator<IProcessStep> iter = steps.iterator(); iter.hasNext();) { - IProcessStep step = iter.next(); + for (IProcessStep step : steps) { result = step.postProcess(input, tempDir, containingInfs); if (result != null) input = result; @@ -261,8 +257,7 @@ public class JarProcessor { private boolean adjustInf(File input, Properties inf) { boolean adjusted = false; - for (Iterator<IProcessStep> iter = steps.iterator(); iter.hasNext();) { - IProcessStep step = iter.next(); + for (IProcessStep step : steps) { adjusted |= step.adjustInf(input, inf, containingInfs); } return adjusted; @@ -283,8 +278,7 @@ public class JarProcessor { System.out.println("Skipping " + input.getPath()); //$NON-NLS-1$ else { System.out.print("Running "); //$NON-NLS-1$ - for (Iterator<IProcessStep> iter = steps.iterator(); iter.hasNext();) { - IProcessStep step = iter.next(); + for (IProcessStep step : steps) { System.out.print(step.getStepName() + " "); //$NON-NLS-1$ } System.out.println("on " + input.getPath()); //$NON-NLS-1$ diff --git a/bundles/org.eclipse.equinox.p2.jarprocessor/src_ant/org/eclipse/equinox/internal/p2/jarprocessor/ant/AntBasedProcessorExecutor.java b/bundles/org.eclipse.equinox.p2.jarprocessor/src_ant/org/eclipse/equinox/internal/p2/jarprocessor/ant/AntBasedProcessorExecutor.java index 4ba687584..36ef393ec 100644 --- a/bundles/org.eclipse.equinox.p2.jarprocessor/src_ant/org/eclipse/equinox/internal/p2/jarprocessor/ant/AntBasedProcessorExecutor.java +++ b/bundles/org.eclipse.equinox.p2.jarprocessor/src_ant/org/eclipse/equinox/internal/p2/jarprocessor/ant/AntBasedProcessorExecutor.java @@ -53,9 +53,10 @@ public class AntBasedProcessorExecutor extends JarProcessorExecutor { protected void processDirectory(File input, FileFilter filter, boolean verbose, JarProcessor processor, Properties packProperties) throws FileNotFoundException { if (filterSet != null && filterSet.contains(input)) { File[] files = input.listFiles(); - for (int i = 0; i < files.length; i++) { - if (files[i].isDirectory() || baseFilter.accept(files[i])) - filterSet.add(files[i]); + for (File file : files) { + if (file.isDirectory() || baseFilter.accept(file)) { + filterSet.add(file); + } } } super.processDirectory(input, filter, verbose, processor, packProperties); diff --git a/bundles/org.eclipse.equinox.p2.jarprocessor/src_ant/org/eclipse/equinox/internal/p2/jarprocessor/ant/JarProcessorTask.java b/bundles/org.eclipse.equinox.p2.jarprocessor/src_ant/org/eclipse/equinox/internal/p2/jarprocessor/ant/JarProcessorTask.java index c2e07cca1..e70ffb4fe 100644 --- a/bundles/org.eclipse.equinox.p2.jarprocessor/src_ant/org/eclipse/equinox/internal/p2/jarprocessor/ant/JarProcessorTask.java +++ b/bundles/org.eclipse.equinox.p2.jarprocessor/src_ant/org/eclipse/equinox/internal/p2/jarprocessor/ant/JarProcessorTask.java @@ -124,12 +124,12 @@ public class JarProcessorTask extends Task { public void addConfiguredFile(FileSet fileset) { DirectoryScanner scanner = fileset.getDirectoryScanner(getProject()); String[] included = scanner.getIncludedFiles(); - for (int i = 0; i < included.length; i++) { - addInputFile(new File(scanner.getBasedir(), included[i])); + for (String included1 : included) { + addInputFile(new File(scanner.getBasedir(), included1)); } included = scanner.getIncludedDirectories(); - for (int i = 0; i < included.length; i++) { - addInputFile(new File(scanner.getBasedir(), included[i])); + for (String included1 : included) { + addInputFile(new File(scanner.getBasedir(), included1)); } } } |