From e8dbcc1f420471e3e4a5e8a73adf54ade5633e8d Mon Sep 17 00:00:00 2001 From: Alexander Kurtakov Date: Wed, 23 Jan 2019 13:09:15 +0200 Subject: Code cleanup in frameworkadmin. * Format. * StringBuffer to StringBuilder * forEach conversion Change-Id: Id43871ac22efac8a83e4a47a1c272badd8de7d65 Signed-off-by: Alexander Kurtakov --- .../eclipse/equinox/frameworkadmin/BundleInfo.java | 96 +++++++++---- .../frameworkadmin/utils/SimpleBundlesState.java | 153 +++++++++++---------- .../provisional/frameworkadmin/ConfigData.java | 29 ++-- .../provisional/frameworkadmin/LauncherData.java | 28 ++-- 4 files changed, 174 insertions(+), 132 deletions(-) diff --git a/bundles/org.eclipse.equinox.frameworkadmin/src/org/eclipse/equinox/frameworkadmin/BundleInfo.java b/bundles/org.eclipse.equinox.frameworkadmin/src/org/eclipse/equinox/frameworkadmin/BundleInfo.java index 71f4b53a1..6e9db6268 100644 --- a/bundles/org.eclipse.equinox.frameworkadmin/src/org/eclipse/equinox/frameworkadmin/BundleInfo.java +++ b/bundles/org.eclipse.equinox.frameworkadmin/src/org/eclipse/equinox/frameworkadmin/BundleInfo.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 IBM Corporation and others. + * Copyright (c) 2007, 2019 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -18,7 +18,8 @@ import org.eclipse.core.runtime.URIUtil; import org.osgi.framework.Version; /** - * This object represents information of a bundle. + * This object represents information of a bundle. + * * @since 2.0 */ public class BundleInfo { @@ -47,7 +48,9 @@ public class BundleInfo { /** * Create a new BundleInfo object - * @param location - the location of the bundle + * + * @param location + * - the location of the bundle */ public BundleInfo(URI location) { this.location = location; @@ -55,9 +58,13 @@ public class BundleInfo { /** * Create a new BundleInfo object - * @param location - the location of the bundle - * @param startLevel - the start to be used or {@link BundleInfo#NO_LEVEL} - * @param started - whether or not the bundle should be started + * + * @param location + * - the location of the bundle + * @param startLevel + * - the start to be used or {@link BundleInfo#NO_LEVEL} + * @param started + * - whether or not the bundle should be started */ public BundleInfo(URI location, int startLevel, boolean started) { this.location = location; @@ -67,11 +74,19 @@ public class BundleInfo { /** * Create a new BundleInfo object - * @param symbolic The Bundle-SymbolicName name for this bundle - * @param version - The version for this bundle, this must be a valid {@link Version} string, if null is passed {@link #EMPTY_VERSION} will be used instead - * @param location - the location of the bundle - * @param startLevel - the start level of the bundle or {@link BundleInfo#NO_LEVEL} - * @param started - whether or not the bundle should be started + * + * @param symbolic + * The Bundle-SymbolicName name for this bundle + * @param version + * - The version for this bundle, this must be a valid + * {@link Version} string, if null is passed {@link #EMPTY_VERSION} + * will be used instead + * @param location + * - the location of the bundle + * @param startLevel + * - the start level of the bundle or {@link BundleInfo#NO_LEVEL} + * @param started + * - whether or not the bundle should be started */ public BundleInfo(String symbolic, String version, URI location, int startLevel, boolean started) { this.symbolicName = symbolic; @@ -83,6 +98,7 @@ public class BundleInfo { /** * Get the bundle id + * * @return the bundle id or {@link #NO_BUNDLEID} */ public long getBundleId() { @@ -90,8 +106,9 @@ public class BundleInfo { } /** - * The base location - * An absolute URI which may be used to resolve relative {@link #getLocation()} URIs + * The base location An absolute URI which may be used to resolve relative + * {@link #getLocation()} URIs + * * @return absolute URI or null if not set */ public URI getBaseLocation() { @@ -99,8 +116,9 @@ public class BundleInfo { } /** - * The location of this bundle. - * A location is required if this bundle will be persisted into a configuration file + * The location of this bundle. A location is required if this bundle will be + * persisted into a configuration file + * * @return URI location or null if not set */ public URI getLocation() { @@ -109,6 +127,7 @@ public class BundleInfo { /** * The manifest for this bundle + * * @return the manifest or null if not set */ public String getManifest() { @@ -117,6 +136,7 @@ public class BundleInfo { /** * The start level for this bundle + * * @return the start level or {@link #NO_LEVEL} */ public int getStartLevel() { @@ -124,8 +144,9 @@ public class BundleInfo { } /** - * The Bundle-SymbolicName for this bundle. - * A symbolic name is required if this bundle will be persisted into a configuration file + * The Bundle-SymbolicName for this bundle. A symbolic name is required if this + * bundle will be persisted into a configuration file + * * @return the symbolic name or null if not set */ public String getSymbolicName() { @@ -134,7 +155,8 @@ public class BundleInfo { /** * Return the version - * @return an {@link Version} string, or "0.0.0" if not set + * + * @return an {@link Version} string, or "0.0.0" if not set */ public String getVersion() { if (version == null) @@ -144,6 +166,7 @@ public class BundleInfo { /** * Return the host if this bundle is a fragment + * * @return the host, or null if this is not a fragment */ public String getFragmentHost() { @@ -151,8 +174,8 @@ public class BundleInfo { } /** - * Whether or not this bundle is marked to be started - * Default is false + * Whether or not this bundle is marked to be started Default is false + * * @return boolean */ public boolean isMarkedAsStarted() { @@ -160,8 +183,8 @@ public class BundleInfo { } /** - * Whether or not this bundle is resolved - * Default is false + * Whether or not this bundle is resolved Default is false + * * @return boolean */ public boolean isResolved() { @@ -170,6 +193,7 @@ public class BundleInfo { /** * Set the bundle id + * * @param bundleId */ public void setBundleId(long bundleId) { @@ -177,8 +201,11 @@ public class BundleInfo { } /** - * Set a base location against which relative {@link #getLocation()} URIs may be resolved - * @param baseLocation - an absolute URI + * Set a base location against which relative {@link #getLocation()} URIs may be + * resolved + * + * @param baseLocation + * - an absolute URI */ public void setBaseLocation(URI baseLocation) { this.baseLocation = baseLocation; @@ -186,6 +213,7 @@ public class BundleInfo { /** * Set the location for this bundle. + * * @param location */ public void setLocation(URI location) { @@ -194,6 +222,7 @@ public class BundleInfo { /** * Set the manifest for this bundle + * * @param manifest */ public void setManifest(String manifest) { @@ -202,14 +231,16 @@ public class BundleInfo { /** * Set whether or not this bundle should be started + * * @param markedAsStarted */ public void setMarkedAsStarted(boolean markedAsStarted) { this.markedAsStarted = markedAsStarted; } - /** + /** * Set whether or not the bundle is resolved + * * @param resolved */ public void setResolved(boolean resolved) { @@ -218,7 +249,10 @@ public class BundleInfo { /** * Set the start level. - * @param level if a value < 0 is passed, the start level will be set to {@link #NO_LEVEL} + * + * @param level + * if a value < 0 is passed, the start level will be set to + * {@link #NO_LEVEL} */ public void setStartLevel(int level) { this.startLevel = level < 0 ? NO_LEVEL : level; @@ -226,6 +260,7 @@ public class BundleInfo { /** * Set the Bundle-SymbolicName + * * @param symbolicName */ public void setSymbolicName(String symbolicName) { @@ -234,6 +269,7 @@ public class BundleInfo { /** * Set the version, should be a valid {@link Version} string + * * @param value */ public void setVersion(String value) { @@ -245,6 +281,7 @@ public class BundleInfo { /** * Set the host if this bundle is a fragment + * * @param fragmentHost */ public void setFragmentHost(String fragmentHost) { @@ -253,7 +290,7 @@ public class BundleInfo { @Override public String toString() { - StringBuffer buffer = new StringBuffer(); + StringBuilder buffer = new StringBuilder(); buffer.append("BundleInfo("); //$NON-NLS-1$ if (symbolicName != null) buffer.append(symbolicName); @@ -278,7 +315,8 @@ public class BundleInfo { buffer.append(", resolved="); //$NON-NLS-1$ buffer.append(resolved); buffer.append(", id="); //$NON-NLS-1$ - buffer.append(this.bundleId);// buffer.append(',').append(manifest == null ? "no manifest" : "manifest available"); + buffer.append(this.bundleId);// buffer.append(',').append(manifest == null ? "no manifest" : "manifest + // available"); buffer.append(',').append(manifest == null ? "no manifest" : "manifest available"); //$NON-NLS-1$ //$NON-NLS-2$ buffer.append(')'); return buffer.toString(); @@ -317,7 +355,7 @@ public class BundleInfo { if (location == null || other.location == null) return true; - //compare absolute location URIs + // compare absolute location URIs URI absoluteLocation = null; if (location.isAbsolute() || baseLocation == null) absoluteLocation = location; diff --git a/bundles/org.eclipse.equinox.frameworkadmin/src/org/eclipse/equinox/internal/frameworkadmin/utils/SimpleBundlesState.java b/bundles/org.eclipse.equinox.frameworkadmin/src/org/eclipse/equinox/internal/frameworkadmin/utils/SimpleBundlesState.java index f76ca3e8e..6245c3e5c 100644 --- a/bundles/org.eclipse.equinox.frameworkadmin/src/org/eclipse/equinox/internal/frameworkadmin/utils/SimpleBundlesState.java +++ b/bundles/org.eclipse.equinox.frameworkadmin/src/org/eclipse/equinox/internal/frameworkadmin/utils/SimpleBundlesState.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2017 IBM Corporation and others. + * Copyright (c) 2007, 2019 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -22,14 +22,11 @@ import org.eclipse.equinox.internal.provisional.frameworkadmin.*; import org.osgi.framework.Constants; /** - * This implementation of BundlesState doesn't support any of - * - resolving bundles, - * - retrieving fw persistent data. + * This implementation of BundlesState doesn't support any of - resolving + * bundles, - retrieving fw persistent data. * * This implementation can be used for those cases. - * */ - public class SimpleBundlesState implements BundlesState { public static final BundleInfo[] NULL_BUNDLEINFOS = new BundleInfo[0]; @@ -41,14 +38,15 @@ public class SimpleBundlesState implements BundlesState { */ public static void checkAvailability(FrameworkAdmin fwAdmin) throws FrameworkAdminRuntimeException { if (!fwAdmin.isActive()) - throw new FrameworkAdminRuntimeException("FrameworkAdmin creates this object is no more available.", FrameworkAdminRuntimeException.FRAMEWORKADMIN_UNAVAILABLE); //$NON-NLS-1$ + throw new FrameworkAdminRuntimeException("FrameworkAdmin creates this object is no more available.", //$NON-NLS-1$ + FrameworkAdminRuntimeException.FRAMEWORKADMIN_UNAVAILABLE); } /** - * + * * @param launcherData * @return File of fwJar to be used. - * @throws IOException + * @throws IOException */ static File getFwJar(LauncherData launcherData) { if (launcherData.getFwJar() != null) @@ -68,17 +66,19 @@ public class SimpleBundlesState implements BundlesState { Manipulator manipulator = null; /** - * If the manifest of the target fw implementation has Constants.BUNDLE_SYMBOLICNAME header, - * this constructor should be used. + * If the manifest of the target fw implementation has + * Constants.BUNDLE_SYMBOLICNAME header, this constructor should be used. * * @param ManipulatorAdmin * @param Manipulator * @param systemBundleSymbolicName */ - public SimpleBundlesState(FrameworkAdmin ManipulatorAdmin, Manipulator Manipulator, String systemBundleSymbolicName) { + public SimpleBundlesState(FrameworkAdmin ManipulatorAdmin, Manipulator Manipulator, + String systemBundleSymbolicName) { super(); this.fwAdmin = ManipulatorAdmin; - // copy Manipulator object for avoiding modifying the parameters of the Manipulator. + // copy Manipulator object for avoiding modifying the parameters of the + // Manipulator. this.manipulator = ManipulatorAdmin.getManipulator(); this.manipulator.setConfigData(Manipulator.getConfigData()); this.manipulator.setLauncherData(Manipulator.getLauncherData()); @@ -89,19 +89,21 @@ public class SimpleBundlesState implements BundlesState { } /** - * If the manifest of the target fw implementation has not Constants.BUNDLE_SYMBOLICNAME header - * but , Constants.BUNDLE_NAME and BUNDLE_VERSION, - * this constructor should be used. + * If the manifest of the target fw implementation has not + * Constants.BUNDLE_SYMBOLICNAME header but , Constants.BUNDLE_NAME and + * BUNDLE_VERSION, this constructor should be used. * * @param ManipulatorAdmin * @param Manipulator * @param systemBundleName * @param systemBundleVender */ - public SimpleBundlesState(FrameworkAdmin ManipulatorAdmin, Manipulator Manipulator, String systemBundleName, String systemBundleVender) { + public SimpleBundlesState(FrameworkAdmin ManipulatorAdmin, Manipulator Manipulator, String systemBundleName, + String systemBundleVender) { super(); this.fwAdmin = ManipulatorAdmin; - // copy Manipulator object for avoiding modifying the parameters of the Manipulator. + // copy Manipulator object for avoiding modifying the parameters of the + // Manipulator. this.manipulator = ManipulatorAdmin.getManipulator(); this.manipulator.setConfigData(Manipulator.getConfigData()); this.manipulator.setLauncherData(Manipulator.getLauncherData()); @@ -114,38 +116,40 @@ public class SimpleBundlesState implements BundlesState { @Override public BundleInfo[] getExpectedState() throws FrameworkAdminRuntimeException { if (!fwAdmin.isActive()) - throw new FrameworkAdminRuntimeException("FrameworkAdmin creates this object is no more available.", FrameworkAdminRuntimeException.FRAMEWORKADMIN_UNAVAILABLE); //$NON-NLS-1$ + throw new FrameworkAdminRuntimeException("FrameworkAdmin creates this object is no more available.", //$NON-NLS-1$ + FrameworkAdminRuntimeException.FRAMEWORKADMIN_UNAVAILABLE); return Utils.getBundleInfosFromList(this.bundleInfosList); } - /* + /* * Just return required bundles. * - * @see org.eclipse.equinox.internal.provisional.frameworkadmin.BundlesState#getPrerequisteBundles(org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo) + * @see org.eclipse.equinox.internal.provisional.frameworkadmin.BundlesState# + * getPrerequisteBundles(org.eclipse.equinox.internal.provisional.frameworkadmin + * .BundleInfo) */ @Override public BundleInfo[] getPrerequisteBundles(BundleInfo bInfo) { URI location = bInfo.getLocation(); final String requiredBundles = Utils.getManifestMainAttributes(location, Constants.REQUIRE_BUNDLE); if (requiredBundles == null) - return new BundleInfo[] {this.getSystemBundle()}; + return new BundleInfo[] { this.getSystemBundle() }; String[] clauses = Utils.getClauses(requiredBundles); List list = new LinkedList<>(); - for (int i = 0; i < clauses.length; i++) - list.add(Utils.getPathFromClause(clauses[i])); + for (String clause : clauses) + list.add(Utils.getPathFromClause(clause)); List ret = new LinkedList<>(); ret.add(this.getSystemBundle()); - for (Iterator ite = this.bundleInfosList.iterator(); ite.hasNext();) { - BundleInfo currentBInfo = ite.next(); + for (BundleInfo currentBInfo : this.bundleInfosList) { URI currentLocation = currentBInfo.getLocation(); - String currentSymbolicName = Utils.getManifestMainAttributes(currentLocation, Constants.BUNDLE_SYMBOLICNAME); + String currentSymbolicName = Utils.getManifestMainAttributes(currentLocation, + Constants.BUNDLE_SYMBOLICNAME); if (currentSymbolicName == null) continue; currentSymbolicName = Utils.getPathFromClause(currentSymbolicName); - for (Iterator ite2 = list.iterator(); ite2.hasNext();) { - String symbolicName = ite2.next(); + for (String symbolicName : list) { if (symbolicName.equals(currentSymbolicName)) { ret.add(currentBInfo); break; @@ -158,10 +162,9 @@ public class SimpleBundlesState implements BundlesState { @Override public BundleInfo getSystemBundle() { if (this.systemBundleSymbolicName == null) { - for (Iterator ite = this.bundleInfosList.iterator(); ite.hasNext();) { - BundleInfo bInfo = ite.next(); - // if (bInfo.getStartLevel() != 1) - // return null;; + for (BundleInfo bInfo : this.bundleInfosList) { + // if (bInfo.getStartLevel() != 1) + // return null;; URI location = bInfo.getLocation(); String bundleName = Utils.getManifestMainAttributes(location, Constants.BUNDLE_NAME); if (systemBundleName.equals(bundleName)) { @@ -172,8 +175,7 @@ public class SimpleBundlesState implements BundlesState { } return null; } - for (Iterator ite = this.bundleInfosList.iterator(); ite.hasNext();) { - BundleInfo bInfo = ite.next(); + for (BundleInfo bInfo : this.bundleInfosList) { URI location = bInfo.getLocation(); String symbolicName = Utils.getManifestMainAttributes(location, Constants.BUNDLE_SYMBOLICNAME); symbolicName = Utils.getPathFromClause(symbolicName); @@ -192,8 +194,7 @@ public class SimpleBundlesState implements BundlesState { @SuppressWarnings("rawtypes") List list = new LinkedList(); - for (Iterator ite = this.bundleInfosList.iterator(); ite.hasNext();) { - BundleInfo bInfo = ite.next(); + for (BundleInfo bInfo : this.bundleInfosList) { URI location = bInfo.getLocation(); String manifestVersion = Utils.getManifestMainAttributes(location, Constants.BUNDLE_MANIFESTVERSION); if (manifestVersion == null) @@ -221,7 +222,9 @@ public class SimpleBundlesState implements BundlesState { @Override public String[] getUnsatisfiedConstraints(BundleInfo bInfo) throws FrameworkAdminRuntimeException { - throw new FrameworkAdminRuntimeException("getUnsatisfiedConstraints(BundleInfo bInfo) is not supported in this implementation", FrameworkAdminRuntimeException.UNSUPPORTED_OPERATION); //$NON-NLS-1$ + throw new FrameworkAdminRuntimeException( + "getUnsatisfiedConstraints(BundleInfo bInfo) is not supported in this implementation", //$NON-NLS-1$ + FrameworkAdminRuntimeException.UNSUPPORTED_OPERATION); } private void initialize() { @@ -235,8 +238,8 @@ public class SimpleBundlesState implements BundlesState { // No fw persistent data location is taken into consideration. BundleInfo[] bInfos = configData.getBundles(); - for (int j = 0; j < bInfos.length; j++) - this.installBundle(bInfos[j]); + for (BundleInfo bInfo : bInfos) + this.installBundle(bInfo); if (getSystemBundle() == null) { BundleInfo sysBInfo = new BundleInfo(launcherData.getFwJar().toURI(), 0, true); @@ -256,10 +259,10 @@ public class SimpleBundlesState implements BundlesState { } String newSymbolicName = newManifest.get(Constants.BUNDLE_SYMBOLICNAME); String newVersion = newManifest.get(Constants.BUNDLE_VERSION); - //System.out.println("> currentInstalledBundles.length=" + currentInstalledBundles.length); + // System.out.println("> currentInstalledBundles.length=" + + // currentInstalledBundles.length); boolean found = false; - for (Iterator ite = this.bundleInfosList.iterator(); ite.hasNext();) { - BundleInfo currentBInfo = ite.next(); + for (BundleInfo currentBInfo : this.bundleInfosList) { URI location = currentBInfo.getLocation(); if (newLocation.equals(location)) { found = true; @@ -279,32 +282,32 @@ public class SimpleBundlesState implements BundlesState { } } - // public String toString() { - // if (state == null) - // return null; - // StringBuffer sb = new StringBuffer(); - // BundleDescription[] bundleDescriptions = state.getBundles(); - // for (int i = 0; i < bundleDescriptions.length; i++) { - // sb.append(bundleDescriptions[i].getBundleId() + ":"); - // sb.append(bundleDescriptions[i].toString() + "("); - // sb.append(bundleDescriptions[i].isResolved() + ")"); - // String[] ees = bundleDescriptions[i].getExecutionEnvironments(); - // for (int j = 0; j < ees.length; j++) - // sb.append(ees[j] + " "); - // sb.append("\n"); - // } - // sb.append("PlatformProperties:\n"); - // Dictionary[] dics = state.getPlatformProperties(); - // for (int i = 0; i < dics.length; i++) { - // for (Enumeration enum = dics[i].keys(); enum.hasMoreElements();) { - // String key = (String) enum.nextElement(); - // String value = (String) dics[i].get(key); - // sb.append(" (" + key + "," + value + ")\n"); - // } - // } - // sb.append("\n"); - // return sb.toString(); - // } + // public String toString() { + // if (state == null) + // return null; + // StringBuffer sb = new StringBuffer(); + // BundleDescription[] bundleDescriptions = state.getBundles(); + // for (int i = 0; i < bundleDescriptions.length; i++) { + // sb.append(bundleDescriptions[i].getBundleId() + ":"); + // sb.append(bundleDescriptions[i].toString() + "("); + // sb.append(bundleDescriptions[i].isResolved() + ")"); + // String[] ees = bundleDescriptions[i].getExecutionEnvironments(); + // for (int j = 0; j < ees.length; j++) + // sb.append(ees[j] + " "); + // sb.append("\n"); + // } + // sb.append("PlatformProperties:\n"); + // Dictionary[] dics = state.getPlatformProperties(); + // for (int i = 0; i < dics.length; i++) { + // for (Enumeration enum = dics[i].keys(); enum.hasMoreElements();) { + // String key = (String) enum.nextElement(); + // String value = (String) dics[i].get(key); + // sb.append(" (" + key + "," + value + ")\n"); + // } + // } + // sb.append("\n"); + // return sb.toString(); + // } @Override public boolean isFullySupported() { @@ -313,26 +316,28 @@ public class SimpleBundlesState implements BundlesState { @Override public boolean isResolved() throws FrameworkAdminRuntimeException { - throw new FrameworkAdminRuntimeException("isResolved() is not supported in this implementation", FrameworkAdminRuntimeException.UNSUPPORTED_OPERATION); //$NON-NLS-1$ + throw new FrameworkAdminRuntimeException("isResolved() is not supported in this implementation", //$NON-NLS-1$ + FrameworkAdminRuntimeException.UNSUPPORTED_OPERATION); } @Override public boolean isResolved(BundleInfo bInfo) throws FrameworkAdminRuntimeException { - throw new FrameworkAdminRuntimeException("isResolved(BundleInfo bInfo) is not supported in this implementation", FrameworkAdminRuntimeException.UNSUPPORTED_OPERATION); //$NON-NLS-1$ + throw new FrameworkAdminRuntimeException("isResolved(BundleInfo bInfo) is not supported in this implementation", //$NON-NLS-1$ + FrameworkAdminRuntimeException.UNSUPPORTED_OPERATION); } @Override public void resolve(boolean increment) throws FrameworkAdminRuntimeException { - throw new FrameworkAdminRuntimeException("resolve(boolean increment) is not supported in this implementation", FrameworkAdminRuntimeException.UNSUPPORTED_OPERATION); //$NON-NLS-1$ + throw new FrameworkAdminRuntimeException("resolve(boolean increment) is not supported in this implementation", //$NON-NLS-1$ + FrameworkAdminRuntimeException.UNSUPPORTED_OPERATION); } @Override public void uninstallBundle(BundleInfo bInfo) throws FrameworkAdminRuntimeException { URI targetLocation = bInfo.getLocation(); int index = -1; - for (Iterator ite = this.bundleInfosList.iterator(); ite.hasNext();) { + for (BundleInfo currentBInfo : this.bundleInfosList) { index++; - BundleInfo currentBInfo = ite.next(); URI location = currentBInfo.getLocation(); if (targetLocation.equals(location)) { break; diff --git a/bundles/org.eclipse.equinox.frameworkadmin/src/org/eclipse/equinox/internal/provisional/frameworkadmin/ConfigData.java b/bundles/org.eclipse.equinox.frameworkadmin/src/org/eclipse/equinox/internal/provisional/frameworkadmin/ConfigData.java index 5a7a114b5..d0220cf3c 100644 --- a/bundles/org.eclipse.equinox.frameworkadmin/src/org/eclipse/equinox/internal/provisional/frameworkadmin/ConfigData.java +++ b/bundles/org.eclipse.equinox.frameworkadmin/src/org/eclipse/equinox/internal/provisional/frameworkadmin/ConfigData.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2017 IBM Corporation and others. + * Copyright (c) 2007, 2019 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -14,15 +14,15 @@ package org.eclipse.equinox.internal.provisional.frameworkadmin; -import java.util.*; +import java.util.LinkedHashSet; +import java.util.Properties; import org.eclipse.equinox.frameworkadmin.BundleInfo; /** - * This object is instantiated by {@link Manipulator#getConfigData()}; - * The class that keeps some parameters of the {@link Manipulator} - * created this object. The manipulating of the parameters will affect - * the {@link Manipulator}. - * + * This object is instantiated by {@link Manipulator#getConfigData()}; The class + * that keeps some parameters of the {@link Manipulator} created this object. + * The manipulating of the parameters will affect the {@link Manipulator}. + * * @see Manipulator */ public class ConfigData { @@ -112,8 +112,8 @@ public class ConfigData { public void setBundles(BundleInfo[] bundleInfos) { bundlesList.clear(); if (bundleInfos != null) - for (int i = 0; i < bundleInfos.length; i++) - bundlesList.add(bundleInfos[i]); + for (BundleInfo bundleInfo : bundleInfos) + bundlesList.add(bundleInfo); } public void setProperty(String key, String value) { @@ -138,7 +138,7 @@ public class ConfigData { @Override public String toString() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append("Class:" + getClass().getName() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$ sb.append("============Independent===============\n"); //$NON-NLS-1$ sb.append("fwName=" + fwName + "\n"); //$NON-NLS-1$ //$NON-NLS-2$ @@ -152,8 +152,8 @@ public class ConfigData { else { sb.append("bundlesList=\n"); //$NON-NLS-1$ int i = 0; - for (Iterator iter = bundlesList.iterator(); iter.hasNext();) { - sb.append("\tbundlesList[" + i + "]=" + iter.next().toString() + "\n"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ + for (BundleInfo bundleInfo : bundlesList) { + sb.append("\tbundlesList[" + i + "]=" + bundleInfo.toString() + "\n"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ i++; } } @@ -164,11 +164,10 @@ public class ConfigData { return sb.toString(); } - private static void setPropsStrings(StringBuffer sb, Properties props) { + private static void setPropsStrings(StringBuilder sb, Properties props) { if (props.size() > 0) { sb.append("\n"); //$NON-NLS-1$ - for (Enumeration enumeration = props.keys(); enumeration.hasMoreElements();) { - String key = (String) enumeration.nextElement(); + for (String key : props.stringPropertyNames()) { String value = props.getProperty(key); if (value == null || value.equals("")) //$NON-NLS-1$ continue; diff --git a/bundles/org.eclipse.equinox.frameworkadmin/src/org/eclipse/equinox/internal/provisional/frameworkadmin/LauncherData.java b/bundles/org.eclipse.equinox.frameworkadmin/src/org/eclipse/equinox/internal/provisional/frameworkadmin/LauncherData.java index cd9cc0725..ece7e5848 100644 --- a/bundles/org.eclipse.equinox.frameworkadmin/src/org/eclipse/equinox/internal/provisional/frameworkadmin/LauncherData.java +++ b/bundles/org.eclipse.equinox.frameworkadmin/src/org/eclipse/equinox/internal/provisional/frameworkadmin/LauncherData.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2017 IBM Corporation and others. + * Copyright (c) 2007, 2019 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -17,11 +17,11 @@ import java.io.File; import java.util.*; /** - * This object is instantiated by {@link Manipulator#getLauncherData()}; - * The class that keeps some parameters of the {@link Manipulator} - * created this object. The manipulating of the parameters will affect - * the {@link Manipulator}. - * + * This object is instantiated by {@link Manipulator#getLauncherData()}; The + * class that keeps some parameters of the {@link Manipulator} created this + * object. The manipulating of the parameters will affect the + * {@link Manipulator}. + * * * @see Manipulator */ @@ -141,10 +141,10 @@ public class LauncherData { } public void removeProgramArg(String arg) { - // We want to handle program args as key/value pairs subsequently - // a key MUST start with a "-", all other args are ignored. For - // backwards compatibility we remove all program args until the - // next program arg key + // We want to handle program args as key/value pairs subsequently + // a key MUST start with a "-", all other args are ignored. For + // backwards compatibility we remove all program args until the + // next program arg key // (see bug 253862) if (!arg.startsWith("-")) //$NON-NLS-1$ return; @@ -190,8 +190,8 @@ public class LauncherData { jvmArgs.clear(); return; } - for (int i = 0; i < args.length; i++) - this.addJvmArg(args[i]); + for (String arg : args) + this.addJvmArg(arg); } public void setLauncher(File launcherFile) { @@ -215,8 +215,8 @@ public class LauncherData { programArgs.clear(); return; } - for (int i = 0; i < args.length; i++) - this.addProgramArg(args[i]); + for (String arg : args) + this.addProgramArg(arg); } @Override -- cgit v1.2.3