diff options
author | Alexander Kurtakov | 2017-09-09 08:58:20 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2017-09-09 08:58:20 +0000 |
commit | ce8888e5faa2bd53fc1219b76e178bd436bd1b65 (patch) | |
tree | f3605cd035960c0a63f550d14860164100cdc8a2 | |
parent | e68d8740242fc3d667d6108ff939fa371e427692 (diff) | |
download | eclipse.platform.ua-ce8888e5faa2bd53fc1219b76e178bd436bd1b65.tar.gz eclipse.platform.ua-ce8888e5faa2bd53fc1219b76e178bd436bd1b65.tar.xz eclipse.platform.ua-ce8888e5faa2bd53fc1219b76e178bd436bd1b65.zip |
Bug 522083 - Simplify StringUtils classesI20170909-1500I20170909-0920I20170909-0800I20170909-0510
Make concat return String directly as it opens the door for moving to
StringBuilder for concatenation and it was not used as buffer anywhere.
Change-Id: Ie81c3995694437ee84806fc9f4d372b2c2f78d80
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
8 files changed, 36 insertions, 44 deletions
diff --git a/org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/util/BundleUtil.java b/org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/util/BundleUtil.java index 53b1eee36..591dd084e 100644 --- a/org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/util/BundleUtil.java +++ b/org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/util/BundleUtil.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2006 IBM Corporation and others. + * Copyright (c) 2004, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -41,12 +41,11 @@ public class BundleUtil { if (bundle == null) Log.error("Universal Welcome tried accessing a NULL bundle.", null); //$NON-NLS-1$ else { - String msg = StringUtil - .concat("Universal Welcome tried accessing Bundle: ", getBundleHeader( //$NON-NLS-1$ - bundle, Constants.BUNDLE_NAME), " vendor: ", //$NON-NLS-1$ - getBundleHeader(bundle, Constants.BUNDLE_VENDOR), - " bundle state: ", String.valueOf(bundle.getState())).toString(); //$NON-NLS-1$ - Log.error(msg, null); + String msg = StringUtil.concat("Universal Welcome tried accessing Bundle: ", getBundleHeader( //$NON-NLS-1$ + bundle, Constants.BUNDLE_NAME), " vendor: ", //$NON-NLS-1$ + getBundleHeader(bundle, Constants.BUNDLE_VENDOR), " bundle state: ", //$NON-NLS-1$ + String.valueOf(bundle.getState())); + Log.error(msg, null); } return false; } @@ -155,9 +154,9 @@ public class BundleUtil { // localLocation can be null if the passed resource could not // be found relative to the plugin. log fact, return resource, // as is. - String msg = StringUtil.concat("Could not find resource: ", //$NON-NLS-1$ - resource, " in ", getBundleHeader( //$NON-NLS-1$ - bundle, Constants.BUNDLE_NAME)).toString(); + String msg = StringUtil.concat("Could not find resource: ", //$NON-NLS-1$ + resource, " in ", getBundleHeader( //$NON-NLS-1$ + bundle, Constants.BUNDLE_NAME)); Log.warning(msg); return resource; } @@ -167,9 +166,9 @@ public class BundleUtil { */ return toExternalForm(localLocation); } catch (Exception e) { - String msg = StringUtil.concat("Failed to load resource: ", //$NON-NLS-1$ - resource, " from ", getBundleHeader(bundle, //$NON-NLS-1$ - Constants.BUNDLE_NAME)).toString(); + String msg = StringUtil.concat("Failed to load resource: ", //$NON-NLS-1$ + resource, " from ", getBundleHeader(bundle, //$NON-NLS-1$ + Constants.BUNDLE_NAME)); Log.error(msg, e); return resource; } diff --git a/org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/util/StringUtil.java b/org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/util/StringUtil.java index 77eccf017..1d2148b82 100644 --- a/org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/util/StringUtil.java +++ b/org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/util/StringUtil.java @@ -12,11 +12,11 @@ package org.eclipse.ui.internal.intro.universal.util; public class StringUtil { - public static StringBuffer concat(String... strings) { - StringBuffer buffer = new StringBuffer(); + public static String concat(String... strings) { + StringBuilder buffer = new StringBuilder(); for (String string : strings) { buffer.append(string); } - return buffer; + return buffer.toString(); } } diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/url/IntroURL.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/url/IntroURL.java index 5c30bed89..7a008e268 100644 --- a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/url/IntroURL.java +++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/url/IntroURL.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2016 IBM Corporation and others. + * Copyright (c) 2004, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -147,7 +147,7 @@ public class IntroURL implements IIntroURL { protected boolean doExecute() { if (Log.logInfo) { String msg = StringUtil.concat("Running Intro URL action ", action, //$NON-NLS-1$ - " with parameters: ", parameters.toString()).toString(); //$NON-NLS-1$ + " with parameters: ", parameters.toString()); //$NON-NLS-1$ Log.info(msg); } diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/util/BundleUtil.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/util/BundleUtil.java index c2fdc3af9..331f5eced 100644 --- a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/util/BundleUtil.java +++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/util/BundleUtil.java @@ -44,11 +44,10 @@ public class BundleUtil { if (bundle == null) Log.error("Intro tried accessing a NULL bundle.", null); //$NON-NLS-1$ else { - String msg = StringUtil - .concat("Intro tried accessing Bundle: ", getBundleHeader( //$NON-NLS-1$ - bundle, Constants.BUNDLE_NAME), " vendor: ", //$NON-NLS-1$ - getBundleHeader(bundle, Constants.BUNDLE_VENDOR), - " bundle state: ", String.valueOf(bundle.getState())).toString(); //$NON-NLS-1$ + String msg = StringUtil.concat("Intro tried accessing Bundle: ", getBundleHeader( //$NON-NLS-1$ + bundle, Constants.BUNDLE_NAME), " vendor: ", //$NON-NLS-1$ + getBundleHeader(bundle, Constants.BUNDLE_VENDOR), " bundle state: ", //$NON-NLS-1$ + String.valueOf(bundle.getState())); Log.error(msg, null); } return false; @@ -182,9 +181,8 @@ public class BundleUtil { // localLocation can be null if the passed resource could not // be found relative to the plugin. log fact, return resource, // as is. - String msg = StringUtil.concat("Could not find resource: ", //$NON-NLS-1$ - resource, " in ", getBundleHeader( //$NON-NLS-1$ - bundle, Constants.BUNDLE_NAME)).toString(); + String msg = StringUtil.concat("Could not find resource: ", //$NON-NLS-1$ + resource, " in ", getBundleHeader(bundle, Constants.BUNDLE_NAME)); //$NON-NLS-1$ Log.warning(msg); return resource; } @@ -194,9 +192,8 @@ public class BundleUtil { */ return toExternalForm(localLocation); } catch (Exception e) { - String msg = StringUtil.concat("Failed to load resource: ", //$NON-NLS-1$ - resource, " from ", getBundleHeader(bundle, //$NON-NLS-1$ - Constants.BUNDLE_NAME)).toString(); + String msg = StringUtil.concat("Failed to load resource: ", //$NON-NLS-1$ + resource, " from ", getBundleHeader(bundle, Constants.BUNDLE_NAME)); //$NON-NLS-1$ Log.error(msg, e); return resource; } diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/parts/StandbyPart.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/parts/StandbyPart.java index 9c7e276b5..0c133a5d4 100644 --- a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/parts/StandbyPart.java +++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/parts/StandbyPart.java @@ -288,10 +288,8 @@ public class StandbyPart implements IIntroConstants { if (controlKey.getControl() == null) { // control is null. This means that interface was not // implemented properly. log fact. - String message = StringUtil - .concat("Standby Content part: ", partId, //$NON-NLS-1$ - " has a null Control defined. This prevents the part from being displayed.") //$NON-NLS-1$ - .toString(); + String message = StringUtil.concat("Standby Content part: ", partId, //$NON-NLS-1$ + " has a null Control defined. This prevents the part from being displayed."); //$NON-NLS-1$ Log.error(message, null); return null; } diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/swt/PageWidgetFactory.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/swt/PageWidgetFactory.java index 8da253c09..62641f7ce 100644 --- a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/swt/PageWidgetFactory.java +++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/swt/PageWidgetFactory.java @@ -154,11 +154,10 @@ public class PageWidgetFactory { String embddedLink = html.getSrc(); if (embddedLink == null) break; - String linkText = StringUtil - .concat( - "<p><a href=\"http://org.eclipse.ui.intro/openBrowser?url=", //$NON-NLS-1$ - embddedLink, "\">", //$NON-NLS-1$ - Messages.HTML_embeddedLink, "</a></p>").toString(); //$NON-NLS-1$ + String linkText = StringUtil.concat( + "<p><a href=\"http://org.eclipse.ui.intro/openBrowser?url=", //$NON-NLS-1$ + embddedLink, "\">", //$NON-NLS-1$ + Messages.HTML_embeddedLink, "</a></p>"); //$NON-NLS-1$ linkText = generateFormText(linkText); c = createFormText(parent, linkText, null); } diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/swt/RootPageForm.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/swt/RootPageForm.java index 18f01b636..dd6a8f28e 100644 --- a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/swt/RootPageForm.java +++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/swt/RootPageForm.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2016 IBM Corporation and others. + * Copyright (c) 2004, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -323,8 +323,7 @@ public class RootPageForm implements IIntroConstants { */ private Label createHoverLabel(Composite body) { Label label = toolkit.createLabel(body, "", SWT.WRAP); //$NON-NLS-1$ - String key = StringUtil.concat(rootPage.getId(), ".", "hover-text.fg") //$NON-NLS-1$ //$NON-NLS-2$ - .toString(); + String key = StringUtil.concat(rootPage.getId(), ".", "hover-text.fg"); //$NON-NLS-1$ //$NON-NLS-2$ Color fg = rootPageStyleManager.getColor(toolkit, key); if (fg == null) fg = toolkit.getColors().getColor(IFormColors.TITLE); diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/util/StringUtil.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/util/StringUtil.java index b26831888..abce3b23e 100644 --- a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/util/StringUtil.java +++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/util/StringUtil.java @@ -15,12 +15,12 @@ import java.net.URLDecoder; public class StringUtil { - public static StringBuffer concat(String... strings) { - StringBuffer buffer = new StringBuffer(); + public static String concat(String... strings) { + StringBuilder buffer = new StringBuilder(); for (String string : strings) { buffer.append(string); } - return buffer; + return buffer.toString(); } public static String decode(String s, String enc) throws UnsupportedEncodingException { |