List of utility methods to do HTML
String | htmlify(String str) Turns a regular string into a form appropriate for a HTML document. str = str.replace("&", "&"); str = str.replace("<", "<"); str = str.replace(">", ">"); return str; |
String | htmlItemName(int itemId) Method htmlItemName. return "&#" + itemId + ";"; |
String | htmlLineBreaks(String s) Convert newlines in the string into <br/> tags. if (s == null) { return ""; StringBuilder out = new StringBuilder(); char[] chars = s.toCharArray(); for (int i = 0; i < chars.length; i++) { if (chars[i] == '\n') { out.append("<br />"); ... |
String | htmlLink(String url, String linkName) html Link return new StringBuffer().append("<a href=\"").append(url).append("\">").append(linkName).append("</a>") .toString(); |
String | htmlNewline(String text) Replaces common newline characters like \n, \r, \r\n to the HTML line break tag br. if (text == null || text.trim().isEmpty()) { return null; return text.replaceAll("(\n|\r|\r\n)", "<br>"); |
String | htmlSafe(String field) Make string safe to output as value="" in an html form if (field == null) { return ""; field = field.replaceAll("\"", """); field = field.replaceAll("<", "<"); field = field.replaceAll(">", ">"); return field; |
String | htmlSafe(String value) html Safe value = value.replace("&", "&"); value = value.replace("<", "<"); value = value.replace(">", ">"); value = value.replace("\"", """); return value; |
int | htmlSize(String str) retreive the size of a String with html code. int c = 0; int cInCode = 0; boolean inHTMLCode = false; for (int i = 0; i < str.length(); i++) { if (!inHTMLCode) { if (str.charAt(i) == '&') { inHTMLCode = true; cInCode++; ... |
String | htmlString(String str) html String str = str.replaceAll("\\&", "&"); str = str.replaceAll("\\<", "<"); str = str.replaceAll("\\>", ">"); return "<html>" + str; |
String | htmlText(String text) This method converts texts to be displayed on html-page. StringBuilder sb = new StringBuilder(); char c; if (text == null) return ""; for (int i = 0; i < text.length(); i++) { c = text.charAt(i); switch (c) { case '<': ... |