List of utility methods to do HTML Encode
String | encodeHTML(String aText) encode HTML final StringBuilder result = new StringBuilder(); final StringCharacterIterator iterator = new StringCharacterIterator(aText); char character = iterator.current(); while (character != CharacterIterator.DONE) { if (character == '<') { result.append("<"); } else if (character == '>') { result.append(">"); ... |
String | encodeHTML(String s) TODO: replace with JTidy or AntiSamy http://jtidy.sourceforge.net/multiproject/jtidyservlet/clover/org/w3c/tidy/servlet/util/HTMLEncode.html return encode(s, "\n"); |
String | forHTML(final String aText) Encodes the string to be used in HTML. final StringBuilder result = new StringBuilder(); final StringCharacterIterator iterator = new StringCharacterIterator(aText); char character = iterator.current(); while (character != CharacterIterator.DONE) { if (character == '\"') { result.append("DOUBLE_QUOTE"); } else if (character == '\r') { result.append("RETURN_CAR"); ... |
String | forHTML(String aText) Escape characters for text appearing in HTML markup. if (aText == null) return null; final StringBuilder result = new StringBuilder(); final StringCharacterIterator iterator = new StringCharacterIterator(aText); char character = iterator.current(); while (character != CharacterIterator.DONE) { if (character == '<') { result.append("<"); ... |
String | forHtmlComplete(final String aText) Encodes the string to be used in HTML. final StringBuilder result = new StringBuilder(); final StringCharacterIterator iterator = new StringCharacterIterator(aText); char character = iterator.current(); while (character != CharacterIterator.DONE) { if (character == '<') { result.append("<"); } else if (character == '>') { result.append(">"); ... |
String | forHTMLTag(String aTagFragment) Replace characters having special meaning inside HTML tags with their escaped equivalents, using character entities such as '&'. final StringBuffer result = new StringBuffer(); final StringCharacterIterator iterator = new StringCharacterIterator(aTagFragment); char character = iterator.current(); while (character != CharacterIterator.DONE) { if (character == '<') { result.append("<"); } else if (character == '>') { result.append(">"); ... |
String | forHTMLTag(String aTagFragment) Replace characters having special meaning inside HTML tags with their escaped equivalents, using character entities such as '&'. final StringBuffer result = new StringBuffer(); final StringCharacterIterator iterator = new StringCharacterIterator(aTagFragment); for (char character = iterator.current(); character != CharacterIterator.DONE; character = iterator .next()) { switch (character) { case '<': result.append("<"); break; ... |
String | html(String text) Creates an html element. return "<html>" + text + "</html>"; |
String | html(String text) Wraps text with tags StringBuilder sb = new StringBuilder(text.length() + 14); return sb.append("<html>").append(text).append("</html>").toString(); |
String | html_encode(String input_string) htmencode char[] input = input_string.toCharArray(); StringBuffer encoded_html_string = new StringBuffer(); for (int x = 0; x < input.length; x++) { if ((input[x] >= '0' && input[x] <= '9') || (input[x] >= 'A' && input[x] <= 'Z') || (input[x] >= 'a' && input[x] <= 'z')) { encoded_html_string.append(input[x]); else if (input[x] <= ' ') { ... |