/** * @since 3.19 / 3.10.1 */ // http://www.w3.org/TR/REC-xml/#charsets @Deprecated public static boolean validXml(final char ch) { return validXml(ch); }
/** * Append escaped version of CData "character data" to the end of the StringBuilder */ private static void transformCData(final StringBuilder sb, final String cdata, final TransformPolicy policy) { cdata.codePoints().forEach(codePoint -> { if (!validXml(codePoint)) { sb.append(policy.handle((char) codePoint)); } else { sb.append(Character.toChars(codePoint)); } }); }
/** * Append escaped version of CData "character data" to the end of the StringBuilder */ private static void transformCData(final StringBuilder sb, final String cdata, final TransformPolicy policy) { for (int i = 0; i < cdata.toCharArray().length; i++) { char ch = cdata.toCharArray()[i]; if (!validXml(ch)) { sb.append(policy.handle(ch)); } else { sb.append(ch); } } }
/** * Append escaped version of character to the end of the StringBuilder */ private static void transform(final StringBuilder sb, final int codePoint, final TransformPolicy policy) { if (!validXml(codePoint)) { sb.append(policy.handle((char)codePoint)); } else { String charRef = getEntityRef(codePoint); if (charRef != null) { sb.append("&").append(charRef).append(";"); } else if ((codePoint >= ' ' && codePoint <= _lastPrintable && codePoint != 0xF7) || codePoint == '\n' || codePoint == '\r' || codePoint == '\t') { // If the character is not printable, print as character reference. // Non printables are below ASCII space but not tab or line // terminator, ASCII delete, or above a certain Unicode threshold. sb.append(Character.toChars(codePoint)); } else { sb.append("&#").append(codePoint).append(";"); } } }
/** * Append escaped version of character to the end of the StringBuilder */ private static void transform(final StringBuilder sb, final char ch, final TransformPolicy policy) { if (!validXml(ch)) { sb.append(policy.handle(ch)); } else { String charRef = getEntityRef(ch); if (charRef != null) { sb.append("&").append(charRef).append(";"); } else if ((ch >= ' ' && ch <= _lastPrintable && ch != 0xF7) || ch == '\n' || ch == '\r' || ch == '\t') { // If the character is not printable, print as character reference. // Non printables are below ASCII space but not tab or line // terminator, ASCII delete, or above a certain Unicode threshold. sb.append(ch); } else { sb.append("&#").append(Integer.toString(ch)).append(";"); } } }