mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
adapt to core StringUtils (#15770)
Signed-off-by: Leo Siepel <leosiepel@gmail.com>
This commit is contained in:
parent
e798ba9406
commit
b8805ba687
@ -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("<");
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user