From c99990ea4f80b2d915fc66f53b5a0bba5292548f Mon Sep 17 00:00:00 2001 From: lsiepel Date: Mon, 16 Oct 2023 23:27:31 +0200 Subject: [PATCH] [sonos] adapt to core StringUtils (#15765) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * adapt to core StringUtils --------- Signed-off-by: Leo Siepel Signed-off-by: Jørgen Austvik --- .../binding/sonos/internal/SonosEntry.java | 5 +- .../sonos/internal/SonosXMLParser.java | 2 +- .../sonos/internal/util/StringUtils.java | 70 ------------------- 3 files changed, 4 insertions(+), 73 deletions(-) delete mode 100644 bundles/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/util/StringUtils.java diff --git a/bundles/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/SonosEntry.java b/bundles/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/SonosEntry.java index 6acea10587e79..ba7385331f1c7 100644 --- a/bundles/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/SonosEntry.java +++ b/bundles/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/SonosEntry.java @@ -13,10 +13,11 @@ package org.openhab.binding.sonos.internal; import java.io.Serializable; +import java.util.Objects; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; -import org.openhab.binding.sonos.internal.util.StringUtils; +import org.openhab.core.util.StringUtils; /** * The {@link SonosEntry} is a datastructure to describe @@ -120,7 +121,7 @@ public String getAlbum() { * @return the URI for the album art. */ public String getAlbumArtUri() { - return StringUtils.unEscapeXml(albumArtUri); + return Objects.requireNonNull(StringUtils.unEscapeXml(albumArtUri)); } /** diff --git a/bundles/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/SonosXMLParser.java b/bundles/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/SonosXMLParser.java index 5812e594f5938..f4bfc5d96386c 100644 --- a/bundles/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/SonosXMLParser.java +++ b/bundles/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/SonosXMLParser.java @@ -27,7 +27,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; -import org.openhab.binding.sonos.internal.util.StringUtils; +import org.openhab.core.util.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.xml.sax.Attributes; diff --git a/bundles/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/util/StringUtils.java b/bundles/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/util/StringUtils.java deleted file mode 100644 index 26eaa4d2a49bd..0000000000000 --- a/bundles/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/util/StringUtils.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Copyright (c) 2010-2023 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.sonos.internal.util; - -import org.eclipse.jdt.annotation.NonNullByDefault; - -/** - * The {@link StringUtils} class defines some static string utility methods - * - * @author Leo Siepel - Initial contribution - */ -@NonNullByDefault -public class StringUtils { - - /** - * Simple method to escape XML special characters in String. - * There are five XML Special characters which needs to be escaped: - * - *
-     * {@code
-     * & - &
-     * < - <
-     * > - >
-     * " - "
-     * ' - '
-     * }
-     * 
- */ - public static String escapeXml(String xml) { - xml = xml.replace("&", "&"); - xml = xml.replace("<", "<"); - xml = xml.replace(">", ">"); - xml = xml.replace("\"", """); - xml = xml.replace("'", "'"); - return xml; - } - - /** - * Simple method to un escape XML special characters in String. - * There are five XML Special characters which needs to be escaped : - * - *
-     * {@code
-     * & - &
-     * < - <
-     * > - >
-     * " - "
-     * ' - '
-     * }
-     * 
- */ - public static String unEscapeXml(String xml) { - xml = xml.replace("&", "&"); - xml = xml.replace("<", "<"); - xml = xml.replace(">", ">"); - xml = xml.replace(""", "\""); - xml = xml.replace("'", "'"); - return xml; - } -}