public class HtmlHelper extends java.lang.Object implements HtmlConstants
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
ENCODING
Standard encoding text for use in an HTML header.
|
HALIGN_CENTER, HALIGN_LEFT, HALIGN_RIGHT, VALIGN_BOTTOM, VALIGN_MIDDLE, VALIGN_TOP
Constructor and Description |
---|
HtmlHelper() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
br()
Creates a break element.
|
static java.lang.String |
endBody()
Ends the body portion of an HTML document.
|
static java.lang.String |
endCenter()
Ends a center section.
|
static java.lang.String |
endDiv()
Ends a division.
|
static java.lang.String |
endField()
Ends a field element.
|
static java.lang.String |
endHead()
Ends the header portion of an HTML document.
|
static java.lang.String |
endHtml()
Ends an HTML document.
|
static java.lang.String |
endPre()
Ends a preformatted section.
|
static java.lang.String |
endRow()
Ends a row.
|
static java.lang.String |
endTable()
Ends a table.
|
static java.lang.String |
field(java.lang.String halign,
java.lang.String valign,
java.lang.String color,
java.lang.String txt,
boolean filter)
Creates a field element.
|
static java.lang.String |
filter(java.lang.String input)
Return an output string based on the input string, where all unsafe
characters (in HTML) have been converted to the proper HTML entities.
|
static java.lang.String |
getEncoding()
Defines the encoding of an HTML document.
|
static java.lang.String |
heading(int level,
java.lang.String txt)
Creates a heading element.
|
static java.lang.String |
hr()
Creates a horizontal rule element.
|
static java.lang.String |
href(java.lang.String link,
java.lang.String txt,
boolean nl)
Creates a hyperlink element.
|
static java.lang.String |
namedAnchor(java.lang.String name,
java.lang.String txt)
Creates a named anchor element.
|
static java.lang.String |
namedAnchor(java.lang.String name,
java.lang.String txt,
boolean filter)
Creates a named anchor element.
|
static java.lang.String |
p()
Creates a paragraph element.
|
static java.lang.String |
pre(java.lang.String txt)
Creates a preformatted element.
|
static java.lang.String |
startBody()
Starts the body portion of an HTML document with a default background
color of '#FFFFFF'.
|
static java.lang.String |
startBody(java.lang.String bgcolor)
Starts the body portion of an HTML document with the given background
color.
|
static java.lang.String |
startCenter()
Starts a center section.
|
static java.lang.String |
startDiv()
Starts a divison.
|
static java.lang.String |
startField(java.lang.String halign,
java.lang.String valign)
Starts a field element.
|
static java.lang.String |
startField(java.lang.String halign,
java.lang.String valign,
boolean nl)
Starts a field element.
|
static java.lang.String |
startField(java.lang.String halign,
java.lang.String valign,
java.lang.String color,
boolean nl)
Starts a field element.
|
static java.lang.String |
startHead()
Starts the header portion of an HTML document.
|
static java.lang.String |
startHtml()
Starts an HTML document.
|
static java.lang.String |
startPre()
Starts a preformatted section.
|
static java.lang.String |
startRow()
Starts a row with no background color (uses the document's setting).
|
static java.lang.String |
startRow(java.lang.String bgcolor)
Starts a row.
|
static java.lang.String |
startTable()
Starts a table a default width of 100%, a border of 1 and a cell
spacing of 0.
|
static java.lang.String |
startTable(int width,
int border)
Starts a table with user provided width and border and a cell
spacing of 0.
|
static java.lang.String |
startTable(int width,
int border,
int cellSpacing)
Starts a table.
|
static java.lang.String |
strong(java.lang.String txt)
Creates a strong element.
|
static java.lang.String |
title(java.lang.String txt)
Creates a title element.
|
private static java.lang.String ENCODING
public static java.lang.String filter(java.lang.String input)
The following conversions occur:
Input Character Output Character ----------------- ----------------- " " ' ' & & < < > >
All other characters are simply written into the output without change.
input
- The text to filter.public static java.lang.String startHtml()
public static java.lang.String endHtml()
public static java.lang.String startHead()
public static java.lang.String getEncoding()
public static java.lang.String endHead()
public static java.lang.String startBody()
public static java.lang.String startBody(java.lang.String bgcolor)
bgcolor
- The background color for the document body.public static java.lang.String endBody()
public static java.lang.String title(java.lang.String txt)
txt
- The contents of the title element. This text will be filtered
using filter(java.lang.String)
before being inserted.public static java.lang.String heading(int level, java.lang.String txt)
level
- The heading element level to create.txt
- The contents of the heading element. This text will be
filtered using filter(java.lang.String)
before being inserted.public static java.lang.String startDiv()
public static java.lang.String endDiv()
public static java.lang.String startPre()
public static java.lang.String endPre()
public static java.lang.String pre(java.lang.String txt)
txt
- The contents of the element. This text will NOT be filtered
using filter(java.lang.String)
before being inserted.public static java.lang.String br()
public static java.lang.String p()
public static java.lang.String hr()
public static java.lang.String startCenter()
public static java.lang.String endCenter()
public static java.lang.String namedAnchor(java.lang.String name, java.lang.String txt)
name
- The anchor's name.txt
- The contents of the element. This text will be filtered
using filter(java.lang.String)
before being inserted.public static java.lang.String namedAnchor(java.lang.String name, java.lang.String txt, boolean filter)
name
- The anchor's name.txt
- The contents of the element. This text will be filtered
using filter(java.lang.String)
before being inserted.filter
- true
to filter the content using filter(java.lang.String)
before being inserted.public static java.lang.String href(java.lang.String link, java.lang.String txt, boolean nl)
link
- The hyperlink (URL).txt
- The contents of the element. This text will be filtered
using filter(java.lang.String)
before being inserted.nl
- true
to add a newline at the end of the element.public static java.lang.String startTable()
public static java.lang.String startTable(int width, int border)
width
- The width as a percent of the page.border
- The border size.public static java.lang.String startTable(int width, int border, int cellSpacing)
width
- The width as a percent of the page.border
- The border size.cellSpacing
- The amount of per cell padding.public static java.lang.String endTable()
public static java.lang.String startRow()
public static java.lang.String startRow(java.lang.String bgcolor)
bgcolor
- The background color for the row.public static java.lang.String endRow()
public static java.lang.String field(java.lang.String halign, java.lang.String valign, java.lang.String color, java.lang.String txt, boolean filter)
halign
- The horizontal alignment to use.valign
- The vertical alignment to use.color
- The background color value to use or null
for no override (uses
whatever is at the enclosing levels).txt
- The contents of the element.filter
- true
to cause the contents to be filtered
using filter(java.lang.String)
before being inserted.public static java.lang.String startField(java.lang.String halign, java.lang.String valign)
halign
- The horizontal alignment to use.valign
- The vertical alignment to use.public static java.lang.String startField(java.lang.String halign, java.lang.String valign, boolean nl)
halign
- The horizontal alignment to use.valign
- The vertical alignment to use.nl
- true
to add a newline at the end of the element.public static java.lang.String startField(java.lang.String halign, java.lang.String valign, java.lang.String color, boolean nl)
halign
- The horizontal alignment to use.valign
- The vertical alignment to use.color
- The background color value to use or null
for no override (uses
whatever is at the enclosing levels).nl
- true
to add a newline at the end of the element.public static java.lang.String endField()
public static java.lang.String strong(java.lang.String txt)
txt
- The contents of the element. This text will be filtered
using filter(java.lang.String)
before being inserted.