22 package org.matsim.core.utils.io;
42 if (attributeValue == null) {
45 int len = attributeValue.length();
46 boolean encode =
false;
47 for (
int pos = 0; pos < len; pos++) {
48 char ch = attributeValue.charAt(pos);
52 }
else if (ch ==
'>') {
55 }
else if (ch ==
'\"') {
58 }
else if (ch ==
'&') {
64 StringBuilder bf =
new StringBuilder(attributeValue.length() + 30);
65 for (
int pos = 0; pos < len; pos++) {
66 char ch = attributeValue.charAt(pos);
69 }
else if (ch ==
'>') {
71 }
else if (ch ==
'\"') {
73 }
else if (ch ==
'&') {
82 return attributeValue;
91 if (attributeValue == null) {
97 int len = attributeValue.length();
99 for (
int pos = 0; pos < len; pos++) {
100 char ch = attributeValue.charAt(pos);
102 case '<' -> out.append(
"<");
103 case '>' -> out.append(
">");
104 case '\"' -> out.append(
""");
105 case '&' -> out.append(
"&");
106 default -> out.append(ch);
118 out.append(key).append(
"=\"");
125 if (content.contains(
"&") || content.contains(
"<") || content.contains(
">")) {
126 return content.replace(
"&",
"&").replace(
"<",
"<").replace(
">",
">");
static String encodeAttributeValue(final String attributeValue)
static String encodeContent(final String content)
static StringBuilder writeEncodedAttributeValue(StringBuilder out, String attributeValue)
static StringBuilder writeEncodedAttributeKeyValue(StringBuilder out, String key, String value)