Klasse HtmlTree
Except where otherwise stated, all methods in this class will throw NullPointerException for any arguments that are null or that are arrays or collections that contain null.
Many methods in this class return this, to enable a series of chained method calls on a single object.
Terminology: An HTML element is typically composed of a start tag, some enclosed content and typically an end tag. The start tag contains any attributes for the element. See: HTML element.
- Siehe auch:
-
Feldübersicht
-
Konstruktorübersicht
-
Methodenübersicht
Modifizierer und TypMethodeBeschreibungstatic HtmlTree
Creates an HTML A element.static HtmlTree
Creates an HTML A element.add
(CharSequence stringContent) Adds text content for the HTML element.Adds each of a list of content items.Adds additional content for the HTML element.<T> HtmlTree
addAll
(Collection<T> items, Function<T, Content> mapper) Adds each of a collection of items, using a map function to create the content for each item.addUnchecked
(Content content) Adds content to this HTML tree without checking whether it is discardable.static HtmlTree
Creates an HTML CAPTION element with the given content.int
Gibt the number of characters of plain text content in this object zurück.static HtmlTree
Creates an HTML CODE element with the given content.static HtmlTree
Creates an HTML DD element with the given content.static HtmlTree
DETAILS()
Creates an HTML DETAILS element.static HtmlTree
Creates an HTML DETAILS element.static HtmlTree
Creates an HTML DIV element with the given style.static HtmlTree
Creates an HTML DIV element with the given style and content.static HtmlTree
Creates an HTML DIV element with the given content.static HtmlTree
Creates an HTML DL element with the given style.static HtmlTree
Creates an HTML DL element with the given style and content.static HtmlTree
Creates an HTML DT element with the given content.static String
Apply percent-encoding to a URL.static HtmlTree
FOOTER()
Creates an HTML FOOTER element.boolean
Returns true if the HTML tree has a specific attribute.boolean
hasAttrs()
Returns true if the HTML tree has attributes.boolean
Returns true if the HTML tree has content.static HtmlTree
HEADER()
Creates an HTML HEADER element.static HtmlTree
Creates an HTML heading element with the given style and content.static HtmlTree
Creates an HTML heading element with the given content.static HtmlTree
HEADING_TITLE
(TagName headingTag, HtmlStyle style, Content body) Creates an HTML heading element with the given style and content.static HtmlTree
HEADING_TITLE
(TagName headingTag, Content body) Creates an HTML heading element with the given style and content.static HtmlTree
Creates an HTML HTML element with the given lang attribute, and HEAD and BODY contents.static HtmlTree
Creates an HTML INPUT element with the given id.boolean
Returns true if the HTML tree does not affect the output and can be discarded.boolean
isEmpty()
Returns true if the content is empty.boolean
isInline()
Returns true if the element is a normal element that is phrasing content.boolean
isVoid()
Returns whether or not this is a void element.static HtmlTree
Creates an HTML LABEL element with the given content.static HtmlTree
Creates an HTML LI element with the given style and the given content.static HtmlTree
Creates an HTML LI element with the given content.static HtmlTree
Creates an HTML LINK tag with the given attributes.static HtmlTree
MAIN()
Creates an HTML MAIN element.static HtmlTree
Creates an HTML MAIN element with the given content.static HtmlTree
Creates an HTML META element with name and content attributes.static HtmlTree
Creates an HTML META element with http-equiv and content attributes.static HtmlTree
NAV()
Creates an HTML NAV element.static HtmlTree
Creates an HTML NOSCRIPT element with some content.static HtmlTree
Creates an HTML P element with the given style and some content.static HtmlTree
Creates an HTML P element with some content.static HtmlTree
Creates an HTML PRE element with some content.Adds an attribute.static HtmlTree
Creates an HTML SCRIPT element with some script content.static HtmlTree
Creates an HTML SECTION element with the given style.static HtmlTree
Creates an HTML SECTION element with the given style and some content.Sets the id attribute.setRole
(HtmlAttr.Role role) Sets the role attribute.Sets the class attribute.Sets the title attribute.static HtmlTree
Creates an HTML SMALL element with some content.static HtmlTree
Creates an HTML SPAN element with the given id and style, and some content.static HtmlTree
Creates an HTML SPAN element with the given style.static HtmlTree
Creates an HTML SPAN element with the given style and some content.static HtmlTree
Creates an HTML SPAN element with some content.static HtmlTree
Creates an HTML SPAN element with the given id and some content.static HtmlTree
Creates an HTML SUMMARY element with the given content.static HtmlTree
Creates an HTML SUP element with the given content.static HtmlTree
Creates an HTML TD element with the given style and some content.static HtmlTree
Creates an HTML TH element with the given scope, and some content.static HtmlTree
Creates an HTML TH element with the given style and scope, and some content.static HtmlTree
Creates an HTML TITLE element with some content.static HtmlTree
Creates an HTML UL element with the given style.static <T> HtmlTree
UL
(HtmlStyle style, Collection<T> items, Function<T, Content> mapper) Creates an HTML UL element with the given style and content generated from a collection of items.static HtmlTree
Creates an HTML UL element with the given style and some content.boolean
Writes content to a writer, using a given newline sequence, which should be either \n or the platform line separator.
-
Felddetails
-
tagName
The name of the HTML element.This value is never null.
-
MAIN_CHARS
-
QUERY_FRAGMENT_CHARS
-
-
Konstruktordetails
-
HtmlTree
Creates an HTMLTree object representing an HTML element with the given name.- Parameter:
tagName
- the name
-
-
Methodendetails
-
put
Adds an attribute.- Parameter:
attrName
- the name of the attributeattrValue
- the value of the attribute- Gibt zurück:
- this object
-
setId
Sets the id attribute.- Parameter:
id
- the value for the attribute- Gibt zurück:
- this object
-
setTitle
Sets the title attribute.Any nested start or end tags in the content will be removed.
- Parameter:
body
- the content for the title attribute- Gibt zurück:
- this object
-
setRole
Sets the role attribute.- Parameter:
role
- the role- Gibt zurück:
- this object
-
setStyle
Sets the class attribute.- Parameter:
style
- the value for the attribute- Gibt zurück:
- this object
-
addStyle
-
addStyle
-
add
Adds additional content for the HTML element. -
addUnchecked
Adds content to this HTML tree without checking whether it is discardable.- Parameter:
content
- the content to add- Gibt zurück:
- this HTML tree
-
add
Adds text content for the HTML element.If the last content member that was added is a StringContent, appends the string to that item; otherwise, creates and uses a new StringContent for the new text content.
-
add
Adds each of a list of content items.- Parameter:
list
- the list- Gibt zurück:
- this object
-
addAll
Adds each of a collection of items, using a map function to create the content for each item. -
charCount
Beschreibung aus Klasse kopiert:Content
Gibt the number of characters of plain text content in this object zurück. -
encodeURL
Apply percent-encoding to a URL.This is similar to
URLEncoder
but is less aggressive about encoding some characters, like ‘(’, ‘)’, ‘,’ which are used in the anchor names for Java methods in HTML5 mode.- Parameter:
url
- the url to be percent-encoded.- Gibt zurück:
- a percent-encoded string.
-
A
Creates an HTML A element.The ref argument will be URL-encoded for use as the attribute value.
- Parameter:
ref
- the value for the href attributebody
- the content for element- Gibt zurück:
- the element
-
A
Creates an HTML A element.The ref argument is assumed to be already suitably encoded, and will not be additionally URL-encoded, but will be
converted
to ASCII for use as the attribute value.- Parameter:
ref
- the value for the href attributebody
- the content for element- Gibt zurück:
- the element
-
CAPTION
Creates an HTML CAPTION element with the given content.- Parameter:
body
- content for the element- Gibt zurück:
- the element
-
CODE
Creates an HTML CODE element with the given content.- Parameter:
body
- content for the element- Gibt zurück:
- the element
-
DD
Creates an HTML DD element with the given content.- Parameter:
body
- content for the element- Gibt zurück:
- the element
-
DETAILS
Creates an HTML DETAILS element.- Gibt zurück:
- the element
-
DETAILS
Creates an HTML DETAILS element.- Gibt zurück:
- the element
-
DL
Creates an HTML DL element with the given style.- Parameter:
style
- the style- Gibt zurück:
- the element
-
DL
Creates an HTML DL element with the given style and content.- Parameter:
style
- the stylebody
- the content- Gibt zurück:
- the element
-
DIV
Creates an HTML DIV element with the given style.- Parameter:
style
- the style- Gibt zurück:
- the element
-
DIV
Creates an HTML DIV element with the given style and content.- Parameter:
style
- the stylebody
- the content- Gibt zurück:
- the element
-
DIV
Creates an HTML DIV element with the given content.- Parameter:
body
- the content- Gibt zurück:
- the element
-
DT
Creates an HTML DT element with the given content.- Parameter:
body
- the content- Gibt zurück:
- the element
-
FOOTER
Creates an HTML FOOTER element.The role is set to contentinfo.
- Gibt zurück:
- the element
-
HEADER
Creates an HTML HEADER element.The role is set to banner.
- Gibt zurück:
- the element
-
HEADING
Creates an HTML heading element with the given content.- Parameter:
headingTag
- the tag for the headingbody
- the content- Gibt zurück:
- the element
-
HEADING
Creates an HTML heading element with the given style and content.- Parameter:
headingTag
- the tag for the headingstyle
- the stylesheet classbody
- the content- Gibt zurück:
- the element
-
HEADING_TITLE
Creates an HTML heading element with the given style and content.The title attribute is set from the content.
- Parameter:
headingTag
- the tag for the headingstyle
- the stylesheet classbody
- the content- Gibt zurück:
- the element
-
HEADING_TITLE
Creates an HTML heading element with the given style and content.The title attribute is set from the content.
- Parameter:
headingTag
- the tag for the headingbody
- the content- Gibt zurück:
- the element
-
HTML
Creates an HTML HTML element with the given lang attribute, and HEAD and BODY contents.- Parameter:
lang
- the value for the lang attributehead
- the HEAD elementbody
- the BODY element- Gibt zurück:
- the HTML element
-
INPUT
Creates an HTML INPUT element with the given id.The element as marked as initially disabled.
- Parameter:
type
- the type of inputid
- the id- Gibt zurück:
- the element
-
LABEL
Creates an HTML LABEL element with the given content.- Parameter:
forLabel
- the value of the for attributebody
- the content- Gibt zurück:
- the element
-
LI
Creates an HTML LI element with the given content.- Parameter:
body
- the content- Gibt zurück:
- the element
-
LI
Creates an HTML LI element with the given style and the given content.- Parameter:
style
- the stylebody
- the content- Gibt zurück:
- the element
-
LINK
Creates an HTML LINK tag with the given attributes.- Parameter:
rel
- the relevance of the link: the rel attributetype
- the type of link: the type attributehref
- the path for the link: the href attributetitle
- title for the link: the title attribute- Gibt zurück:
- the element
-
MAIN
Creates an HTML MAIN element.The role is set to main.
- Gibt zurück:
- the element
-
MAIN
Creates an HTML MAIN element with the given content.The role is set to main.
- Gibt zurück:
- the element
-
META
Creates an HTML META element with http-equiv and content attributes.- Parameter:
httpEquiv
- the value for the http-equiv attributecontent
- the type of content, to be used in the content attributecharset
- the character set for the document, to be used in the content attribute- Gibt zurück:
- the element
-
META
Creates an HTML META element with name and content attributes.- Parameter:
name
- the value for the name attributecontent
- the value for the content attribute- Gibt zurück:
- the element
-
NAV
Creates an HTML NAV element.The role is set to navigation.
- Gibt zurück:
- the element
-
NOSCRIPT
Creates an HTML NOSCRIPT element with some content.- Parameter:
body
- the content- Gibt zurück:
- the element
-
P
Creates an HTML P element with some content.- Parameter:
body
- the content- Gibt zurück:
- the element
-
P
Creates an HTML P element with the given style and some content.- Parameter:
style
- the stylebody
- the content- Gibt zurück:
- the element
-
PRE
Creates an HTML PRE element with some content.- Parameter:
body
- the content- Gibt zurück:
- the element
-
SCRIPT
Creates an HTML SCRIPT element with some script content.The type of the script is set to text/javascript.
- Parameter:
src
- the content- Gibt zurück:
- the element
-
SECTION
Creates an HTML SECTION element with the given style.- Parameter:
style
- the style- Gibt zurück:
- the element
-
SECTION
Creates an HTML SECTION element with the given style and some content.- Parameter:
style
- the stylebody
- the content- Gibt zurück:
- the element
-
SMALL
Creates an HTML SMALL element with some content.- Parameter:
body
- the content- Gibt zurück:
- the element
-
SPAN
Creates an HTML SPAN element with some content.- Parameter:
body
- the content- Gibt zurück:
- the element
-
SPAN
Creates an HTML SPAN element with the given style.- Parameter:
styleClass
- the style- Gibt zurück:
- the element
-
SPAN
Creates an HTML SPAN element with the given style and some content.- Parameter:
styleClass
- the stylebody
- the content- Gibt zurück:
- the element
-
SPAN_ID
Creates an HTML SPAN element with the given id and some content.- Parameter:
id
- the idbody
- the content- Gibt zurück:
- the element
-
SPAN
Creates an HTML SPAN element with the given id and style, and some content.- Parameter:
id
- the idstyle
- the stylebody
- the content- Gibt zurück:
- the element
-
SUMMARY
Creates an HTML SUMMARY element with the given content.- Parameter:
body
- the content- Gibt zurück:
- the element
-
SUP
Creates an HTML SUP element with the given content.- Parameter:
body
- the content- Gibt zurück:
- the element
-
TD
Creates an HTML TD element with the given style and some content.- Parameter:
style
- the stylebody
- the content- Gibt zurück:
- the element
-
TH
Creates an HTML TH element with the given style and scope, and some content.- Parameter:
style
- the stylescope
- the value for the scope attributebody
- the content- Gibt zurück:
- the element
-
TH
Creates an HTML TH element with the given scope, and some content.- Parameter:
scope
- the value for the scope attributebody
- the content- Gibt zurück:
- the element
-
TITLE
Creates an HTML TITLE element with some content.- Parameter:
body
- the content- Gibt zurück:
- the element
-
UL
Creates an HTML UL element with the given style.- Parameter:
style
- the style- Gibt zurück:
- the element
-
UL
Creates an HTML UL element with the given style and some content.- Parameter:
style
- the stylefirst
- the initial contentmore
- additional content- Gibt zurück:
- the element
-
UL
Creates an HTML UL element with the given style and content generated from a collection of items.- Parameter:
style
- the styleitems
- the items to be added to the listmapper
- a mapper to create the content for each item- Gibt zurück:
- the element
-
isEmpty
Beschreibung aus Klasse kopiert:Content
Returns true if the content is empty. -
hasContent
Returns true if the HTML tree has content.- Gibt zurück:
- true if the HTML tree has content else return false
-
hasAttrs
Returns true if the HTML tree has attributes.- Gibt zurück:
- true if the HTML tree has attributes else return false
-
hasAttr
Returns true if the HTML tree has a specific attribute.- Parameter:
attrName
- name of the attribute to check within the HTML tree- Gibt zurück:
- true if the HTML tree has the specified attribute else return false
-
isDiscardable
Returns true if the HTML tree does not affect the output and can be discarded.This implementation considers non-void elements without content or id attribute as discardable, with the exception of SCRIPT which can sometimes be used without content.
- Setzt außer Kraft:
isDiscardable
in KlasseContent
- Gibt zurück:
- true if the HTML tree can be discarded without affecting the output
-
isInline
Returns true if the element is a normal element that is phrasing content.- Gibt zurück:
- true if this is an inline element
- Siehe auch:
-
isVoid
Returns whether or not this is a void element.- Gibt zurück:
- whether or not this is a void element
- Siehe auch:
-
write
Beschreibung aus Klasse kopiert:Content
Writes content to a writer, using a given newline sequence, which should be either \n or the platform line separator.- Angegeben von:
write
in KlasseContent
- Parameter:
out
- the writernewline
- the newline sequence to useatNewline
- whether the writer has just written a newline- Gibt zurück:
- whether the writer has just written a newline
- Löst aus:
IOException
- if an error occurs while writing the output
-