List of utility methods to do XML Encode
String | xmlEncode(String string) xml Encode if (string.equals("")) { return string; int index = string.indexOf('&'); while (index != -1) { string = string.substring(0, index) + "&" + string.substring(index + 1); index = string.indexOf('&', index + 1); ... |
String | xmlEncode(String text) xml Encode int length = text.length(); if (text != null && length > 0) { StringBuffer ret = new StringBuffer(length * 12 / 10); int last = 0; for (int i = 0; i < length; i++) { char c = text.charAt(i); switch (c) { case '&': ... |
String | xmlEncode(String text) xml Encode return xmlEncode(text, null);
|
String | xmlEncode(String text) Encodes the text into safe XML by replacing < > and & with XML tokens if (text == null) { return ""; text = text.replaceAll("&", "&"); text = text.replaceAll("\"", """); text = text.replaceAll("<", "<"); text = text.replaceAll(">", ">"); return text; ... |
String | xmlEncode(String text, String invalidCharReplacement) xml Encode if (text == null || text.length() == 0) { return text; int length = text.length(); StringBuffer ret = new StringBuffer(); int last = 0; for (int i = 0; i < length; i++) { char c = text.charAt(i); ... |
String | XMLEncode(String value) XML Encode if (value == null) return value; return value.replaceAll("&", "&").replaceAll("'", "'").replaceAll("\"", """) .replaceAll("<", "<").replaceAll(">", ">"); |
String | xmlEncodeAttr(String src) xml Encode Attr StringBuffer sb = new StringBuffer(src.length()); for (int i = 0; i < src.length(); i++) { char ch = src.charAt(i); switch (ch) { case '&': if (sb == null) { sb = createStringBuffer(src, i); sb.append("&"); break; case '<': if (sb == null) { sb = createStringBuffer(src, i); sb.append("<"); break; case '>': if (sb == null) { sb = createStringBuffer(src, i); sb.append(">"); break; case '\'': if (sb == null) { sb = createStringBuffer(src, i); sb.append("'"); break; case '\"': if (sb == null) { sb = createStringBuffer(src, i); sb.append("""); break; case '\r': if (sb == null) { sb = createStringBuffer(src, i); sb.append(" "); break; case '\n': if (sb == null) { sb = createStringBuffer(src, i); sb.append(" "); break; case '\t': if (sb == null) { sb = createStringBuffer(src, i); sb.append("	"); break; default: if (sb != null) { sb.append(ch); return sb != null ? sb.toString() : src; |
String | xmlEncodeCDATA(String src) xml Encode CDATA return xmlEncodeCDATA(src, false);
|