adapt to core StringUtils (#15766)
Signed-off-by: Leo Siepel <leosiepel@gmail.com>
This commit is contained in:
parent
381d8ac93b
commit
43f5b216f1
|
@ -14,13 +14,14 @@ package org.openhab.binding.upnpcontrol.internal.queue;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
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.
|
* @return the URI for the album art.
|
||||||
*/
|
*/
|
||||||
public String getAlbumArtUri() {
|
public String getAlbumArtUri() {
|
||||||
return StringUtils.unEscapeXml(albumArtUri);
|
return Objects.requireNonNull(StringUtils.unEscapeXml(albumArtUri));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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
|
|
||||||
* & - &
|
|
||||||
* < - <
|
|
||||||
* > - >
|
|
||||||
* " - "
|
|
||||||
* ' - '
|
|
||||||
* }
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
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 :
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* {@code
|
|
||||||
* & - &
|
|
||||||
* < - <
|
|
||||||
* > - >
|
|
||||||
* " - "
|
|
||||||
* ' - '
|
|
||||||
* }
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
public static String unEscapeXml(String xml) {
|
|
||||||
xml = xml.replace("&", "&");
|
|
||||||
xml = xml.replace("<", "<");
|
|
||||||
xml = xml.replace(">", ">");
|
|
||||||
xml = xml.replace(""", "\"");
|
|
||||||
xml = xml.replace("'", "'");
|
|
||||||
return xml;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -29,6 +29,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
import org.openhab.binding.upnpcontrol.internal.queue.UpnpEntry;
|
import org.openhab.binding.upnpcontrol.internal.queue.UpnpEntry;
|
||||||
import org.openhab.binding.upnpcontrol.internal.queue.UpnpEntryRes;
|
import org.openhab.binding.upnpcontrol.internal.queue.UpnpEntryRes;
|
||||||
|
import org.openhab.core.util.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.xml.sax.Attributes;
|
import org.xml.sax.Attributes;
|
||||||
|
|
Loading…
Reference in New Issue