From 2bcad99a06945190c7baff4268f9fc459bc34dfd Mon Sep 17 00:00:00 2001 From: Lars Vogel Date: Fri, 5 Jul 2019 14:23:11 +0200 Subject: Use StringBuilder in org.eclipse.equinox.p2.core Javadoc of StringBuffer recommends to switch to StringBuilder Change-Id: I7858c29dc7ce12570e960370991296955554361e Signed-off-by: Lars Vogel --- .../p2/core/helpers/OrderedProperties.java | 12 +++++------ .../internal/p2/core/helpers/TarInputStream.java | 24 +++++++++++----------- .../equinox/internal/p2/core/helpers/Tracing.java | 6 +++--- .../equinox/internal/p2/core/helpers/URLUtil.java | 2 +- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/OrderedProperties.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/OrderedProperties.java index 4919a1cff..d68425fd2 100644 --- a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/OrderedProperties.java +++ b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/OrderedProperties.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -20,13 +20,13 @@ import java.util.*; *

* This class is used to store properties similar to {@link java.util.Properties}. * In particular both keys and values are strings and must be not null. - * However this class is somewhat simplified and does not implement Cloneable, + * However this class is somewhat simplified and does not implement Cloneable, * Serializable and Hashtable. *

- * In contrast to java.util.Properties this class maintains the order by which + * In contrast to java.util.Properties this class maintains the order by which * properties are added. This is implemented using a {@link LinkedHashMap}. *

- * The class does not support default properties as they can be expressed by + * The class does not support default properties as they can be expressed by * creating java.util.Properties hierarchies. */ public class OrderedProperties extends Dictionary implements Map { @@ -58,7 +58,7 @@ public class OrderedProperties extends Dictionary implements Map * If a property with the key already exists, the previous * value is replaced. Otherwise a new property is added at * the end collection. - * + * * @param key must not be null * @param value must not be null * @return previous value associated with specified key, or null @@ -173,7 +173,7 @@ public class OrderedProperties extends Dictionary implements Map @Override public String toString() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append(propertyMap); return sb.toString(); } diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/TarInputStream.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/TarInputStream.java index 6eacf35a1..381f4e020 100644 --- a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/TarInputStream.java +++ b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/TarInputStream.java @@ -1,13 +1,13 @@ /******************************************************************************* * Copyright (c) 2008, 2017 IBM Corporation and others. * - * This program and the accompanying materials + * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -28,7 +28,7 @@ public class TarInputStream extends FilterInputStream { /** * Creates a new tar input stream on the given input stream. - * + * * @param in input stream * @throws TarException * @throws IOException @@ -44,7 +44,7 @@ public class TarInputStream extends FilterInputStream { /** * Create a new tar input stream, skipping ahead to the given entry * in the file. - * + * * @param in input stream * @param entry skips to this entry in the file * @throws TarException @@ -58,7 +58,7 @@ public class TarInputStream extends FilterInputStream { /** * The checksum of a tar file header is simply the sum of the bytes in * the header. - * + * * @param header * @return checksum */ @@ -72,7 +72,7 @@ public class TarInputStream extends FilterInputStream { /** * Skips ahead to the position of the given entry in the file. - * + * * @param entry * @returns false if the entry has already been passed * @throws TarException @@ -101,7 +101,7 @@ public class TarInputStream extends FilterInputStream { /** * Returns true if the header checksum is correct. - * + * * @param header * @return true if this header has a valid checksum */ @@ -110,7 +110,7 @@ public class TarInputStream extends FilterInputStream { int pos, i; pos = 148; - StringBuffer checksumString = new StringBuffer(); + StringBuilder checksumString = new StringBuilder(); for (i = 0; i < 8; i++) { if (header[pos + i] == ' ') { continue; @@ -145,7 +145,7 @@ public class TarInputStream extends FilterInputStream { /** * Returns the next entry in the tar file. Does not handle * GNU @LongLink extensions. - * + * * @return the next entry in the tar file * @throws TarException * @throws IOException @@ -222,7 +222,7 @@ public class TarInputStream extends FilterInputStream { } pos = 100; - StringBuffer mode = new StringBuffer(); + StringBuilder mode = new StringBuilder(); for (i = 0; i < 8; i++) { if (header[pos + i] == 0) { break; @@ -243,7 +243,7 @@ public class TarInputStream extends FilterInputStream { } pos = 100 + 24; - StringBuffer size = new StringBuffer(); + StringBuilder size = new StringBuilder(); for (i = 0; i < 12; i++) { if (header[pos + i] == 0) { break; @@ -277,7 +277,7 @@ public class TarInputStream extends FilterInputStream { /** * Moves ahead to the next file in the tar archive and returns * a TarEntry object describing it. - * + * * @return the next entry in the tar file * @throws TarException * @throws IOException diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/Tracing.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/Tracing.java index f1cbe4854..36731a504 100644 --- a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/Tracing.java +++ b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/Tracing.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM Corporation - initial API and implementation * Red Hat Inc. - Bug 460967 @@ -68,11 +68,11 @@ public class Tracing { } /** - * Prints a debug message on stdout. Callers should first ensure their specific + * Prints a debug message on stdout. Callers should first ensure their specific * debug option is enabled. */ public static void debug(String message) { - StringBuffer buffer = new StringBuffer(); + StringBuilder buffer = new StringBuilder(); buffer.append("[p2] "); //$NON-NLS-1$ buffer.append(new Date(System.currentTimeMillis())); buffer.append(" - ["); //$NON-NLS-1$ diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/URLUtil.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/URLUtil.java index 0aae19602..ac6e9183c 100644 --- a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/URLUtil.java +++ b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/URLUtil.java @@ -60,7 +60,7 @@ public class URLUtil { */ private static String ensureUNCPath(String path) { int len = path.length(); - StringBuffer result = new StringBuffer(len); + StringBuilder result = new StringBuilder(len); for (int i = 0; i < 4; i++) { // if we have hit the first non-slash character, add another leading slash if (i >= len || result.length() > 0 || path.charAt(i) != '/') -- cgit v1.2.3