Class ZHtml.Document
- Enclosing class:
- ZHtml
public class ZHtml.Document extends ZHtml.Node
The root node of an HTML document is the node that is tagged html
.
-
Method Summary
Modifier and Type Method Description ZHtml.Div
addDiv()
Appends a div element (div
tag) to the document body.ZHtml.Heading
addHeading(String text, int level)
Appends a heading (h
tag) wrapping the given text and having the given level to the document body.ZHtml.Heading
addHeading(String text, int level, String align)
Appends a heading (h
tag) wrapping the given text, having the given level and aligned to the given direction to the document body.ZHtml.Heading
addHeading(ZHtml.Node node, int level)
Appends a heading (h
tag) wrapping the given node and having the given level to the document body.ZHtml.Heading
addHeading(ZHtml.Node node, int level, String align)
Appends a heading (h
tag) wrapping the given node, having the given level and aligned to the given direction to the document body.ZHtml.Paragraph
addParagraph(String text)
Appends a paragraph (p
tag) that wraps the given text to the document body.ZHtml.Table
addTable(String[] headers, String width)
Appends a table (table
tag) with the given list of column headers and of the specified width to the document body.String
toHtml()
Returns the document with all its added nodes as an HTML text.Methods inherited from class org.spiderwiz.zutils.ZHtml.Node
addStyle, createAnchor, createParagraph, createTextNode
-
Method Details
-
addParagraph
Appends a paragraph (p
tag) that wraps the given text to the document body.The given text can contain any character, including characters that have special HTML meanings. When the document is converted to HTML using
toHtml()
, special characters are escaped.- Parameters:
text
- the plain text that are wrapped by the paragraph tag.- Returns:
- the added Paragraph node.
-
addDiv
Appends a div element (div
tag) to the document body.- Returns:
- the added Div node.
-
addHeading
Appends a heading (h
tag) wrapping the given text and having the given level to the document body.The tag has the form of
<h
level>
.The given text can contain any character, including characters that have special HTML meanings. The method does the necessary HTML escaping.
- Parameters:
text
- the plain text wrapped by the heading tag.level
- the level of the heading tag.- Returns:
- the added Heading node.
-
addHeading
Appends a heading (h
tag) wrapping the given text, having the given level and aligned to the given direction to the document body.The tag has the form of
<h
level>
.The given text can contain any character, including characters that have special HTML meanings. The method does the necessary HTML escaping.
The alignment direction is applied to
text-align
style attached to the node.- Parameters:
text
- the plain text that are wrapped by the heading tag.level
- the level of the heading tag.align
- alignment direction - "left", "center" or "right". Null or empty values default to "left".- Returns:
- the added Heading node.
-
addHeading
Appends a heading (h
tag) wrapping the given node and having the given level to the document body.The tag has the form of
<h
level>
.- Parameters:
node
- the Node object that are wrapped by the heading tag.level
- the level of the heading tag.- Returns:
- the added Heading node.
-
addHeading
Appends a heading (h
tag) wrapping the given node, having the given level and aligned to the given direction to the document body.The tag has the form of
<h
level>
.- Parameters:
node
- the Node object that are wrapped by the heading tag.level
- the level of the heading tag.align
- alignment direction - "left", "center" or "right". Null or empty value defaults to "left".- Returns:
- the added Heading node.
-
addTable
Appends a table (table
tag) with the given list of column headers and of the specified width to the document body.The headers are placed in the table as a row (
tr
tag) of header cells (th
tags).The width can be any allowed value in
width
property of thetable
tag. If it isnull
,"100%"
is assumed.- Parameters:
headers
- an array of column headers to display in the table.width
- the table width. Null value defaults to "100%".- Returns:
- the added Table node.
-
toHtml
Returns the document with all its added nodes as an HTML text.- Returns:
- the document with all its added nodes as an HTML text.
-