]> git.basschouten.com Git - openhab-addons.git/commitdiff
adapt to core StringUtils (#15770)
authorlsiepel <leosiepel@gmail.com>
Thu, 19 Oct 2023 19:48:09 +0000 (21:48 +0200)
committerGitHub <noreply@github.com>
Thu, 19 Oct 2023 19:48:09 +0000 (21:48 +0200)
Signed-off-by: Leo Siepel <leosiepel@gmail.com>
bundles/org.openhab.binding.homematic/src/main/java/org/openhab/binding/homematic/internal/communicator/message/XmlRpcRequest.java

index af517dcf324c1ac0250a436ab6dca70b51fee9a2..ea1a16f33f94b6e15e7f3220f4c2966988b4784a 100644 (file)
@@ -23,6 +23,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 
+import org.openhab.core.util.StringUtils;
+
 /**
  * A XML-RPC request for sending data to the Homematic server.
  *
@@ -122,7 +124,7 @@ public class XmlRpcRequest implements RpcRequest<String> {
         } else {
             Class<?> clazz = value.getClass();
             if (clazz == String.class || clazz == Character.class) {
-                sb.append(escapeXml(value.toString()));
+                sb.append(StringUtils.escapeXml(value.toString()));
             } else if (clazz == Long.class || clazz == Integer.class || clazz == Short.class || clazz == Byte.class) {
                 tag("int", value.toString());
             } else if (clazz == Double.class) {
@@ -176,30 +178,4 @@ public class XmlRpcRequest implements RpcRequest<String> {
             }
         }
     }
-
-    private StringBuilder escapeXml(String inValue) {
-        StringBuilder outValue = new StringBuilder(inValue.length());
-        for (int i = 0; i < inValue.length(); i++) {
-            switch (inValue.charAt(i)) {
-                case '<':
-                    outValue.append("&lt;");
-                    break;
-                case '>':
-                    outValue.append("&gt;");
-                    break;
-                case '&':
-                    outValue.append("&amp;");
-                    break;
-                case '\'':
-                    outValue.append("&apost;");
-                    break;
-                case '"':
-                    outValue.append("&quot;");
-                    break;
-                default:
-                    outValue.append(inValue.charAt(i));
-            }
-        }
-        return outValue;
-    }
 }