APIdia Launch Partner
Top Description Fields Constructors Methods
jdk.javadoc.internal.html

public Class HtmlTree

extends Content
Class Inheritance
Imports
java.io.IOException, .Writer, java.net.URI, java.nio.charset.StandardCharsets, java.util.ArrayList, .BitSet, .Collection, .LinkedHashMap, .List, .Map, .Objects, java.util.function.Function, jdk.javadoc.internal.doclets.toolkit.util.DocPath

A tree node representing an HTML element, containing the name of the element, a collection of attributes, and content. 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.
See Also
WhatWG: Normal Elements, HTML 5.1: Elements

Field Summary

Modifier and TypeField and Description
private Map<HtmlAttr, String>
attrs

The attributes for the HTML element.

private static final HtmlTree
private List<Content>
content

The enclosed content ("inner HTML") for this HTML element.

private static final HtmlTree
public static final BitSet
public static final BitSet
public final HtmlTag
tag

The tag for the HTML element.

private static final HtmlTree

Constructor Summary

AccessConstructor and Description
pack-priv
HtmlTree(HtmlTag
the name
tag
)

Creates an HTMLTree object representing an HTML element with the given name.

Method Summary

Modifier and TypeMethod and Description
public static HtmlTree

Returns:

the element
A
(String
the value for the href attribute
ref
,
Content
the content for element
body
)

Creates an HTML A element.

public static HtmlTree

Returns:

the element
A
(URI
the value for the href attribute
ref
,
Content
the content for element
body
)

Creates an HTML A element.

public HtmlTree

Returns:

this HTML tree
add
(Content
the content
content
)

Overrides jdk.javadoc.internal.html.Content.add.

Adds additional content for the HTML element.

public HtmlTree
add(CharSequence
string content that needs to be added
stringContent
)

Overrides jdk.javadoc.internal.html.Content.add.

Adds text content for the HTML element.

public HtmlTree

Returns:

this object
add
(List<? extends Content>
the list
list
)

Adds each of a list of content items.

public <T> HtmlTree

Returns:

this object
addAll
(Collection<T>
the items
items
,
Function<T, Content>
the map function to generate the content for each item
mapper
)

Overrides jdk.javadoc.internal.html.Content.addAll.

Adds each of a collection of items, using a map function to create the content for each item.

public HtmlTree
public HtmlTree
public HtmlTree

Returns:

this HTML tree
addUnchecked
(Content
the content to add
content
)

Adds content to this HTML tree without checking whether it is discardable.

private static BitSet
private static BitSet
bitSet(char from, char to)

private static BitSet
bitSet(BitSet... sets)

public static HtmlTree

Returns:

the element
BODY
(HtmlStyle
the style
style
)

Creates an HTML BODY element with the given style.

public static HtmlTree

Returns:

an HTML BR element
BR
()

Returns an HTML BR element.

public static HtmlTree

Returns:

the element
BUTTON
(HtmlId
the id
id
)

Creates an HTML BUTTON element with the given id.

public static HtmlTree

Returns:

the element
BUTTON
(HtmlStyle
the style
style
)

Creates an HTML BUTTON element with the given style.

public static HtmlTree

Returns:

the element
CAPTION
(Content
content for the element
body
)

Creates an HTML CAPTION element with the given content.

public int
charCount()

Overrides jdk.javadoc.internal.html.Content.charCount.

Returns the number of characters of plain text content in this object.

private static HtmlTag
checkHeading(HtmlTag headingTag)

public static HtmlTree

Returns:

the element
CODE
()

Creates an empty HTML CODE element.

public static HtmlTree

Returns:

the element
CODE
(Content
content for the element
body
)

Creates an HTML CODE element with the given content.

public static HtmlTree

Returns:

the element
DD
()

Creates an empty HTML DD element.

public static HtmlTree

Returns:

the element
DD
(Content
content for the element
body
)

Creates an HTML DD element with the given content.

public static HtmlTree

Returns:

the element
DETAILS
()

Creates an HTML DETAILS element.

public static HtmlTree

Returns:

the element
DETAILS
(HtmlStyle style)

Creates an HTML DETAILS element.

public static HtmlTree

Returns:

the element
DIV
(HtmlId
the id
id
)

Creates an HTML DIV element with the given id.

public static HtmlTree

Returns:

the element
DIV
(HtmlStyle
the style
style
)

Creates an HTML DIV element with the given style.

public static HtmlTree

Returns:

the element
DIV
(HtmlStyle
the style
style
,
Content
the content
body
)

Creates an HTML DIV element with the given style and content.

public static HtmlTree

Returns:

the element
DIV
(Content
the content
body
)

Creates an HTML DIV element with the given content.

public static HtmlTree

Returns:

the element
DL
(HtmlStyle
the style
style
)

Creates an HTML DL element with the given style.

public static HtmlTree

Returns:

the element
DL
(HtmlStyle
the style
style
,
Content
the content
body
)

Creates an HTML DL element with the given style and content.

public static HtmlTree

Returns:

the element
DT
(Content
the content
body
)

Creates an HTML DT element with the given content.

public static HtmlTree

Returns:

the element
EM
(String
content for the element
body
)

Creates an HTML EM element with the given content.

public static String

Returns:

a percent-encoded string.
encodeURL
(String
the url to be percent-encoded.
url
)

Apply percent-encoding to a URL.

public Map<HtmlAttr, String>

Returns:

the attributes of this node
getAttrs
()

Returns the attributes of this node.

public List<Content>

Returns:

the contents of this node
getContents
()

Returns the contents of this node.

public boolean

Returns:

true if the HTML tree has the specified attribute else return false
hasAttr
(HtmlAttr
name of the attribute to check within the HTML tree
attrName
)

Returns true if the HTML tree has a specific attribute.

public boolean

Returns:

true if the HTML tree has attributes else return false
hasAttrs
()

Returns true if the HTML tree has attributes.

public boolean

Returns:

true if the HTML tree has content else return false
hasContent
()

Returns true if the HTML tree has content.

public static HtmlTree

Returns:

the element
HEADER
()

Creates an HTML HEADER element.

public static HtmlTree

Returns:

the element
HEADING
(HtmlTag
the tag for the heading
headingTag
,
Content
the content
body
)

Creates an HTML heading element with the given content.

public static HtmlTree

Returns:

the element
HEADING
(HtmlTag
the tag for the heading
headingTag
,
HtmlStyle
the stylesheet class
style
,
Content
the content
body
)

Creates an HTML heading element with the given style and content.

public static HtmlTree

Returns:

the element
HEADING_TITLE
(HtmlTag
the tag for the heading
headingTag
,
HtmlStyle
the stylesheet class
style
,
Content
the content
body
)

Creates an HTML heading element with the given style and content.

public static HtmlTree

Returns:

the element
HEADING_TITLE
(HtmlTag
the tag for the heading
headingTag
,
Content
the content
body
)

Creates an HTML heading element with the given style and content.

public static HtmlTree

Returns:

an HTML HR element
HR
()

Returns an HTML HR element.

public static HtmlTree

Returns:

the HTML element
HTML
(String
the value for the lang attribute
lang
,
Content
the HEAD element
head
,
Content
the BODY element
body
)

Creates an HTML HTML element with the given lang attribute, and HEAD and BODY contents.

public static HtmlTree

Returns:

an HTML IMG element
IMG
(DocPath
the path of the image
src
,
String
alternate text for the image
alt
)

Returns an HTML IMG element.

public static HtmlTree

Returns:

the element
INPUT
(HtmlAttr.InputType
the type of input
type
,
HtmlId
the id
id
)

Creates an HTML INPUT element with the given id. The element as marked as initially disabled.

public static HtmlTree

Returns:

the element
INPUT
(HtmlAttr.InputType
the input type
type
,
HtmlStyle
the input style
style
)

Creates an HTML INPUT element with the given type and style.

public boolean

Returns:

true if the HTML tree can be discarded without affecting the output
isDiscardable
()

Overrides jdk.javadoc.internal.html.Content.isDiscardable.

Returns true if the HTML tree does not affect the output and can be discarded.

public boolean
isEmpty()

Implements abstract jdk.javadoc.internal.html.Content.isEmpty.

Returns true if the content is empty.

public boolean

Returns:

true if this is an inline element
isInline
()

Returns true if the element is a normal element that is phrasing content.

public boolean
isPhrasingContent()

Overrides jdk.javadoc.internal.html.Content.isPhrasingContent.

Returns true if the content is "phrasing content".

public boolean

Returns:

whether this is a void element
isVoid
()

Returns whether this is a void element.

public static HtmlTree

Returns:

the element
KBD
(Content
the content
body
)

Creates a KBD element with the given content.

public static HtmlTree

Returns:

the element
LABEL
(String
the value of the for attribute
forLabel
,
Content
the content
body
)

Creates an HTML LABEL element with the given content.

public static HtmlTree

Returns:

the element
LI
()

Creates an empty HTML LI element.

public static HtmlTree

Returns:

the element
LI
(HtmlStyle
the style
style
)

Creates an HTML LI element with the given style.

public static HtmlTree

Returns:

the element
LI
(Content
the content
body
)

Creates an HTML LI element with the given content.

public static HtmlTree

Returns:

the element
LI
(HtmlStyle
the style
style
,
Content
the content
body
)

Creates an HTML LI element with the given style and the given content.

public static HtmlTree

Returns:

the element
MAIN
()

Creates an HTML MAIN element.

public static HtmlTree

Returns:

the element
MAIN
(Content body)

Creates an HTML MAIN element with the given content.

public static HtmlTree

Returns:

the element
META
(String
the value for the http-equiv attribute
httpEquiv
,
String
the type of content, to be used in the content attribute
content
,
String
the character set for the document, to be used in the content attribute
charset
)

Creates an HTML META element with http-equiv and content attributes.

public static HtmlTree

Returns:

the element
META
(String
the value for the name attribute
name
,
String
the value for the content attribute
content
)

Creates an HTML META element with name and content attributes.

public static HtmlTree

Returns:

the element
NOSCRIPT
(Content
the content
body
)

Creates an HTML NOSCRIPT element with some content.

public static HtmlTree
of(HtmlTag
the name
tag
)

Creates an HTMLTree object representing an HTML element with the given name.

public static HtmlTree

Returns:

the element
OL
(HtmlStyle
the style
style
)

Creates an HTML OL element with the given style.

public static HtmlTree

Returns:

the element
P
(Content
the content
body
)

Creates an HTML P element with some content.

public static HtmlTree

Returns:

the element
P
(HtmlStyle
the style
style
,
Content
the content
body
)

Creates an HTML P element with the given style and some content.

public static HtmlTree

Returns:

the element
PRE
()

Creates an empty HTML PRE element.

public static HtmlTree

Returns:

the element
PRE
(HtmlStyle
the style
style
)

Creates an HTML PRE element with the given style

public static HtmlTree

Returns:

the element
PRE
(Content
the content
body
)

Creates an HTML PRE element with some content.

public HtmlTree

Returns:

this object
put
(HtmlAttr
the name of the attribute
attrName
,
String
the value of the attribute
attrValue
)

Adds an attribute.

public static HtmlTree

Returns:

the element
SCRIPT
(String
the content
src
)

Creates an HTML SCRIPT element with some script content.

public static HtmlTree

Returns:

the element
SECTION
(HtmlStyle
the style
style
)

Creates an HTML SECTION element with the given style.

public static HtmlTree

Returns:

the element
SECTION
(HtmlStyle
the style
style
,
Content
the content
body
)

Creates an HTML SECTION element with the given style and some content.

public HtmlTree

Returns:

this object
setId
(HtmlId
the value for the attribute
id
)

Sets the id attribute.

public HtmlTree

Returns:

this object
setRole
(HtmlAttr.Role
the role
role
)

Sets the role attribute.

public HtmlTree

Returns:

this object
setStyle
(HtmlStyle
the value for the attribute
style
)

Sets the class attribute.

public HtmlTree

Returns:

this object
setTitle
(Content
the content for the title attribute
body
)

Sets the title attribute.

public static HtmlTree

Returns:

the element
SMALL
(Content
the content
body
)

Creates an HTML SMALL element with some content.

public static HtmlTree

Returns:

the element
SPAN
(Content
the content
body
)

Creates an HTML SPAN element with some content.

public static HtmlTree

Returns:

the element
SPAN
(HtmlStyle
the style
styleClass
)

Creates an HTML SPAN element with the given style.

public static HtmlTree

Returns:

the element
SPAN
(HtmlStyle
the style
styleClass
,
Content
the content
body
)

Creates an HTML SPAN element with the given style and some content.

public static HtmlTree

Returns:

the element
SPAN
(HtmlId
the id
id
,
HtmlStyle
the style
style
,
Content
the content
body
)

Creates an HTML SPAN element with the given id and style, and some content.

public static HtmlTree

Returns:

the element
SPAN_ID
(HtmlId
the id
id
,
Content
the content
body
)

Creates an HTML SPAN element with the given id and some content.

private static String

Returns:

the plain text from the content node
stripHtml
(Content
The content node to check.
body
)

Given a Content node, strips all html characters and returns the result.

public Content
stripTags()

Overrides jdk.javadoc.internal.html.Content.stripTags.

Returns the plain text of this content with HTML tags removed.

public static HtmlTree

Returns:

the element
SUMMARY
(Content
the content
body
)

Creates an HTML SUMMARY element with the given content.

public static HtmlTree

Returns:

the element
SUP
(HtmlStyle
the style
style
,
Content
the content
body
)

Creates an HTML SUP element with the given style and content.

public static HtmlTree

Returns:

the element
TITLE
(String
the content
body
)

Creates an HTML TITLE element with some content.

public static HtmlTree

Returns:

the element
UL
()

Creates an empty HTML UL element.

public static HtmlTree

Returns:

the element
UL
(HtmlStyle
the style
style
)

Creates an HTML UL element with the given style.

public static HtmlTree

Returns:

the element
UL
(HtmlId
the id
id
,
HtmlStyle
the style
style
)

Creates an HTML UL element with the given id and style.

public static HtmlTree

Returns:

the element
UL
(HtmlStyle
the style
style
,
Content
the initial content
first
,
Content...
additional content
more
)

Creates an HTML UL element with the given style and some content.

public static <T> HtmlTree

Returns:

the element
UL
(HtmlStyle
the style
style
,
Collection<T>
the items to be added to the list
items
,
Function<T, Content>
a mapper to create the content for each item
mapper
)

Creates an HTML UL element with the given style and content generated from a collection of items.

private static HtmlTree
public static HtmlTree

Returns:

an HTML WBR element
WBR
()

Returns an HTML WBR element.

public boolean
write(Writer out, String newline, boolean atNewline)

Implements abstract jdk.javadoc.internal.html.Content.write.

Writes content to a writer, using a given newline sequence, which should be either \n or the platform line separator.

Inherited from jdk.javadoc.internal.html.Content:
toString