diff --git a/bundles/org.openhab.binding.homematic/src/main/java/org/openhab/binding/homematic/internal/communicator/message/XmlRpcRequest.java b/bundles/org.openhab.binding.homematic/src/main/java/org/openhab/binding/homematic/internal/communicator/message/XmlRpcRequest.java index af517dcf3..ea1a16f33 100644 --- a/bundles/org.openhab.binding.homematic/src/main/java/org/openhab/binding/homematic/internal/communicator/message/XmlRpcRequest.java +++ b/bundles/org.openhab.binding.homematic/src/main/java/org/openhab/binding/homematic/internal/communicator/message/XmlRpcRequest.java @@ -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 { } 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 { } } } - - 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("<"); - break; - case '>': - outValue.append(">"); - break; - case '&': - outValue.append("&"); - break; - case '\'': - outValue.append("&apost;"); - break; - case '"': - outValue.append("""); - break; - default: - outValue.append(inValue.charAt(i)); - } - } - return outValue; - } }