]> git.basschouten.com Git - openhab-addons.git/commitdiff
adapt to core StringUtils (#15766)
authorlsiepel <leosiepel@gmail.com>
Mon, 16 Oct 2023 21:43:00 +0000 (23:43 +0200)
committerGitHub <noreply@github.com>
Mon, 16 Oct 2023 21:43:00 +0000 (23:43 +0200)
Signed-off-by: Leo Siepel <leosiepel@gmail.com>
bundles/org.openhab.binding.upnpcontrol/src/main/java/org/openhab/binding/upnpcontrol/internal/queue/UpnpEntry.java
bundles/org.openhab.binding.upnpcontrol/src/main/java/org/openhab/binding/upnpcontrol/internal/util/StringUtils.java [deleted file]
bundles/org.openhab.binding.upnpcontrol/src/main/java/org/openhab/binding/upnpcontrol/internal/util/UpnpXMLParser.java

index 2c25cd8a63be349784442cb0bcb81747a5d987b9..bde30da2ab621689ab25c94014a0a1dde5cbee57 100644 (file)
@@ -14,13 +14,14 @@ package org.openhab.binding.upnpcontrol.internal.queue;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Objects;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
-import org.openhab.binding.upnpcontrol.internal.util.StringUtils;
+import org.openhab.core.util.StringUtils;
 
 /**
  *
@@ -178,7 +179,7 @@ public class UpnpEntry {
      * @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.upnpcontrol/src/main/java/org/openhab/binding/upnpcontrol/internal/util/StringUtils.java b/bundles/org.openhab.binding.upnpcontrol/src/main/java/org/openhab/binding/upnpcontrol/internal/util/StringUtils.java
deleted file mode 100644 (file)
index 30c8cc6..0000000
+++ /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.upnpcontrol.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 :
-     *
-     * <pre>
-     * {@code
-     * & - &amp;
-     * < - &lt;
-     * > - &gt;
-     * " - &quot;
-     * ' - &apos;
-     * }
-     * </pre>
-     */
-    public static String escapeXml(String xml) {
-        xml = xml.replace("&", "&amp;");
-        xml = xml.replace("<", "&lt;");
-        xml = xml.replace(">", "&gt;");
-        xml = xml.replace("\"", "&quot;");
-        xml = xml.replace("'", "&apos;");
-        return xml;
-    }
-
-    /**
-     * Simple method to un escape XML special characters in String.
-     * There are five XML Special characters which needs to be escaped :
-     *
-     * <pre>
-     * {@code
-     * & - &amp;
-     * < - &lt;
-     * > - &gt;
-     * " - &quot;
-     * ' - &apos;
-     * }
-     * </pre>
-     */
-    public static String unEscapeXml(String xml) {
-        xml = xml.replace("&amp;", "&");
-        xml = xml.replace("&lt;", "<");
-        xml = xml.replace("&gt;", ">");
-        xml = xml.replace("&quot;", "\"");
-        xml = xml.replace("&apos;", "'");
-        return xml;
-    }
-}
index 89983602f107e7444bede4318d56e429d9339a67..b45ba75d2bd5ab8dfb2be2b2c122d753a4eeec3f 100644 (file)
@@ -29,6 +29,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.upnpcontrol.internal.queue.UpnpEntry;
 import org.openhab.binding.upnpcontrol.internal.queue.UpnpEntryRes;
+import org.openhab.core.util.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.xml.sax.Attributes;