@Test public void testEscapeXml() { assert (escapedStrings.length == unescapedStrings.length); for (int i = 0; i < unescapedStrings.length; i++) { if (unescapedStrings[i] == null) { assert (Strings.escapeXml(unescapedStrings[i]) == null); } else { Assert.assertEquals(escapedStrings[i], Strings.escapeXml(unescapedStrings[i])); } } }
public static String escapeXml(String s) { initializeEscapeMap(); if (s == null || s.length() == 0) { return s; } char[] sChars = s.toCharArray(); StringBuilder sb = new StringBuilder(); int lastReplacement = 0; for (int i = 0; i < sChars.length; i++) { if (isInvalidXMLCharacter(sChars[i])) { sb.append(sChars, lastReplacement, i - lastReplacement); sb.append(sChars[i] == 0xFFFE ? "\\ufffe" : xmlLowValueEscapeStrings[sChars[i]]); lastReplacement = i + 1; } } if (lastReplacement < sChars.length) { sb.append(sChars, lastReplacement, sChars.length - lastReplacement); } return StringEscapeUtils.escapeXml11(sb.toString()); }
Strings { public static String escapeXml(String s) { initializeEscapeMap(); if (s == null || s.length() == 0) { return s; } char[] sChars = s.toCharArray(); StringBuilder sb = new StringBuilder(); int lastReplacement = 0; for (int i = 0; i < sChars.length; i++) { if (isInvalidXMLCharacter(sChars[i])) { sb.append(sChars, lastReplacement, i - lastReplacement); sb.append(sChars[i] == 0xFFFE ? "\\ufffe" : xmlLowValueEscapeStrings[sChars[i]]); lastReplacement = i + 1; } } if (lastReplacement < sChars.length) { sb.append(sChars, lastReplacement, sChars.length - lastReplacement); } return StringEscapeUtils.escapeXml11(sb.toString()); } }
Strings { public static String escapeXml(String s) { initializeEscapeMap(); if (s == null || s.length() == 0) { return s; } char[] sChars = s.toCharArray(); StringBuilder sb = new StringBuilder(); int lastReplacement = 0; for (int i = 0; i < sChars.length; i++) { if (isInvalidXMLCharacter(sChars[i])) { sb.append(sChars, lastReplacement, i - lastReplacement); sb.append(sChars[i] == 0xFFFE ? "\\ufffe" : xmlLowValueEscapeStrings[sChars[i]]); lastReplacement = i + 1; } } if (lastReplacement < sChars.length) { sb.append(sChars, lastReplacement, sChars.length - lastReplacement); } return StringEscapeUtils.escapeXml11(sb.toString()); }  }
Strings { public static String escapeXml(String s) { initializeEscapeMap(); if (s == null || s.length() == 0) { return s; } char[] sChars = s.toCharArray(); StringBuilder sb = new StringBuilder(); int lastReplacement = 0; for (int i = 0; i < sChars.length; i++) { if (isInvalidXMLCharacter(sChars[i])) { sb.append(sChars, lastReplacement, i - lastReplacement); sb.append(sChars[i] == 0xFFFE ? "\\ufffe" : xmlLowValueEscapeStrings[sChars[i]]); lastReplacement = i + 1; } } if (lastReplacement < sChars.length) { sb.append(sChars, lastReplacement, sChars.length - lastReplacement); } return StringEscapeUtils.escapeXml11(sb.toString()); }  @Deprecated static String replace(String source, String find, String repl); @Deprecated static String toString(final Object[] a); static String trimComma(String s); static void initializeEscapeMap(); static String escapeXml(String s); static boolean initializeUnescapePattern(); static String unescapeXml(String s); static String escapeLFCRBackSlash(String s); }
Strings { public static String escapeXml(String s) { initializeEscapeMap(); if (s == null || s.length() == 0) { return s; } char[] sChars = s.toCharArray(); StringBuilder sb = new StringBuilder(); int lastReplacement = 0; for (int i = 0; i < sChars.length; i++) { if (isInvalidXMLCharacter(sChars[i])) { sb.append(sChars, lastReplacement, i - lastReplacement); sb.append(sChars[i] == 0xFFFE ? "\\ufffe" : xmlLowValueEscapeStrings[sChars[i]]); lastReplacement = i + 1; } } if (lastReplacement < sChars.length) { sb.append(sChars, lastReplacement, sChars.length - lastReplacement); } return StringEscapeUtils.escapeXml11(sb.toString()); }  @Deprecated static String replace(String source, String find, String repl); @Deprecated static String toString(final Object[] a); static String trimComma(String s); static void initializeEscapeMap(); static String escapeXml(String s); static boolean initializeUnescapePattern(); static String unescapeXml(String s); static String escapeLFCRBackSlash(String s);  }