Java Utililty Methods HTML

List of utility methods to do HTML

Description

The list of methods to do HTML are organized into topic(s).

Method

StringhtmlEnclose(String html)
Returns a String with wrapped with tags
StringBuilder sb = new StringBuilder();
sb.append("<html><body>").append(html).append("</body></html>");
return sb.toString();
StringhtmlFilenameForClass(Class c)
Return the filename of the GATKDoc HTML that would be generated for Class.
return c.getName().replace(".", "_") + ".html";
StringHTMLFilter(String the_txt)
Cleans up entered text to make it XML compatible and to prevent SQL injection tricks.
if (the_txt == null) {
    return null;
char content[] = new char[the_txt.length()];
the_txt.getChars(0, the_txt.length(), content, 0);
StringBuffer result = new StringBuffer(content.length + 50);
for (int i = 0; i < content.length; i++) {
    switch (content[i]) {
...
StringhtmlFilter(String value)
html Filter
if (value == null || value.length() == 0) {
    return "&nbsp;";
return value.replaceAll("&", "&amp;").replaceAll("\t", "    ").replaceAll(" ", "&nbsp;")
        .replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll("\"", "&quot;")
        .replaceAll("\n", "<br/>");
StringhtmlFilterToEmpty(String value)
html Filter To Empty
if (value == null || value.length() == 0) {
    return "";
return value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll("\"",
        "&quot;");
StringhtmlFooter()
html Footer
return HTML_FOOTER;
StringhtmlFormat(String input)
html Format
input = input.replaceAll("\n", "<br>");
input = input.replaceAll("\t", "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
return "<html><body><table width=\"500\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td>" + input
        + "</td></tr></table></body></html>";
StringhtmlFormatText(String line1, String line2)
html Format Text
String text = "<html> " + "<body>" + "<label>" + line1 + "</label>" + "<br><label>" + line2 + "</label>"
        + "</body>" + "</html>";
return text;
StringhtmlHashTag(final String tagName)
html Hash Tag
return htmlHashTag(tagName, "#");
StringhtmlHeaderGen(String errorMsg)
html Header Gen
StringBuilder htmlContentHeader = new StringBuilder();
htmlContentHeader.append("<html>");
htmlContentHeader.append(
        "<head><script type='text/javascript'>function openBrWindow(theURL,winName,features) { window.open(theURL,winName,features);}</script> </head>");
htmlContentHeader.append(
        "<body><style type='text/css'><!-- .bodytext{  font-family: Tahoma, Arial, Helvetica, sans-serif;  font-size: 12px; font-style: normal;  line-height: normal;  font-weight: normal;  font-variant: normal;  text-transform: none;  color: #003366;  text-decoration: none; --></style>\n");
htmlContentHeader.append("<table width='100%' border='0' cellspacing='0' cellpadding='0'> \n");
htmlContentHeader.append("<tr> \n");
...