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

public Class Table<T>

extends Content
Class Inheritance
Type Parameters
<T>
the class or interface used to distinguish the rows to be displayed for each tab, or Void when a table does not contain tabs
Imports
java.io.IOException, .Writer, java.util.ArrayList, .Arrays, .HashSet, .List, .Set, java.util.function.Predicate, jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles, jdk.javadoc.internal.html.Content, .ContentBuilder, .HtmlAttr, .HtmlId, .HtmlStyle, .HtmlTag, .HtmlTree, .Text

An HTML container used to display summary tables for various kinds of elements and other tabular data. This class historically used to generate an HTML <table> element but has been updated to render its content as a stream of <div> elements that rely on CSS Grid Layout for styling. This provides for more flexible layout options, such as splitting up table rows on small displays.

The table should be used in three phases:

  1. Configuration: the overall characteristics of the table should be specified
  2. Population: the content for the cells in each row should be added
  3. Generation: the HTML content and any associated JavaScript can be accessed
Many methods return the current object, to facilitate fluent builder-style usage. A table may support filtered views, which can be selected by clicking on one of a list of tabs above the table. If the table does not support filtered views, the caption element is typically displayed as a single (inactive) tab. The filtered views use a Predicate to identify the rows to be shown for each tab. The type parameter for the predicate is the type parameter T for the table. The type parameter should be Void when the table is not configured to use tabs.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static record
Table.Tab<T>

A record containing the data for a table tab.

Field Summary

Modifier and TypeField and Description
private final List<Content>
private Content
private List<HtmlStyle>
private Content
private HtmlStyle
private TableHeader
private HtmlId
private Set<Table.Tab<T>>
private boolean
private final HtmlStyle
private List<Table.Tab<T>>

Constructor Summary

AccessConstructor and Description
public
Table(HtmlStyle
the style class for the top-level <div> element
tableStyle
)

Creates a builder for an HTML element representing a table.

Method Summary

Modifier and TypeMethod and Description
public void
addRow(Content...
the contents for the row
contents
)

Adds a row of data to the table.

public void
addRow(List<Content>
the contents for the row
contents
)

Adds a row of data to the table.

public void
addRow(T
the item
item
,
Content...
the contents for the row
contents
)

Adds a row of data to the table.

public void
addRow(T
the item
item
,
List<Content>
the contents for the row
contents
)

Adds a row of data to the table.

public Table<T>

Returns:

this object
addTab
(Content
the tab label
label
,
Predicate<T>
the predicate
predicate
)

Adds a tab to the table.

private HtmlTree
createTab(HtmlId tabId, HtmlStyle style, boolean defaultTab, Content tabLabel)

private HtmlTree
private Content
public boolean

Returns:

true if the table has no rows
isEmpty
()

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

Returns whether the table is empty.

public Table<T>

Returns:

this object
setCaption
(Content
the caption
captionContent
)

Sets the caption for the table.

public Table<T>

Returns:

this object
setColumnStyles
(HtmlStyle...
the styles
styles
)

Sets the styles for be used for the cells in each row.

public Table<T>

Returns:

this object
setColumnStyles
(List<HtmlStyle>
the styles
styles
)

Sets the styles for be used for the cells in each row.

public Table<T>

Returns:

this object
setDefaultTab
(Content
the default tab label
label
)

Sets the label for the default tab, which displays all the rows in the table.

public Table<T>

Returns:

this object
setGridStyle
(HtmlStyle
the grid style
gridStyle
)

Sets the style for the table's grid which controls allocation of space among table columns.

public Table<T>

Returns:

this object
setHeader
(TableHeader
the header
header
)

Sets the header for the table.

public Table<T>

Returns:

this object
setId
(HtmlId
the id
id
)

Sets the id attribute of the table.

public Table<T>

Returns:

this object
setRenderTabs
(boolean
true if table tabs should be rendered
renderTabs
)

Allows to set whether tabs should be rendered for this table.

private Content

Returns:

the HTML
toContent
()

Returns the HTML for the table.

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:
addaddaddAllcharCountisDiscardableisPhrasingContentstripTagstoString

Field Detail

bodyRowsback to summary
private final List<Content> bodyRows
captionback to summary
private Content caption
columnStylesback to summary
private List<HtmlStyle> columnStyles
defaultTabback to summary
private Content defaultTab
gridStyleback to summary
private HtmlStyle gridStyle
idback to summary
private HtmlId id
occurringTabsback to summary
private Set<Table.Tab<T>> occurringTabs
renderTabsback to summary
private boolean renderTabs
tableStyleback to summary
private final HtmlStyle tableStyle
tabsback to summary
private List<Table.Tab<T>> tabs

Constructor Detail

Tableback to summary
public Table(HtmlStyle tableStyle)

Creates a builder for an HTML element representing a table.

Parameters
tableStyle:HtmlStyle

the style class for the top-level <div> element

Method Detail

addRowback to summary
public void addRow(Content... contents)

Adds a row of data to the table. Each item of content should be suitable for use as the content of a <th> or <td> cell. This method should not be used when the table has tabs: use a method that takes an Element parameter instead.

Parameters
contents:Content[]

the contents for the row

addRowback to summary
public void addRow(List<Content> contents)

Adds a row of data to the table. Each item of content should be suitable for use as the content of a <th> or <td> cell. This method should not be used when the table has tabs: use a method that takes an item parameter instead.

Parameters
contents:List<Content>

the contents for the row

addRowback to summary
public void addRow(T item, Content... contents)

Adds a row of data to the table. Each item of content should be suitable for use as the content of a <th> or <td> cell. If tabs have been added to the table, the specified item will be used to determine whether the row should be displayed when any particular tab is selected, using the predicate specified when the tab was added.

Parameters
item:T

the item

contents:Content[]

the contents for the row

Exceptions
NullPointerException:
if tabs have previously been added to the table and item is null
addRowback to summary
public void addRow(T item, List<Content> contents)

Adds a row of data to the table. Each item of content should be suitable for use as the content of a <div> cell. If tabs have been added to the table, the specified item will be used to determine whether the row should be displayed when any particular tab is selected, using the predicate specified when the tab was added.

Parameters
item:T

the item

contents:List<Content>

the contents for the row

Exceptions
NullPointerException:
if tabs have previously been added to the table and item is null
addTabback to summary
public Table<T> addTab(Content label, Predicate<T> predicate)

Adds a tab to the table. Tabs provide a way to display subsets of rows, as determined by a predicate for the tab, and an item associated with each row. Tabs will appear left-to-right in the order they are added.

Parameters
label:Content

the tab label

predicate:Predicate<T>

the predicate

Returns:Table<T>

this object

createTabback to summary
private HtmlTree createTab(HtmlId tabId, HtmlStyle style, boolean defaultTab, Content tabLabel)
getCaptionback to summary
private HtmlTree getCaption(Content title)
getTableBodyback to summary
private Content getTableBody()
isEmptyback to summary
public boolean isEmpty()

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

Returns whether the table is empty. The table is empty if it has no (body) rows.

Returns:boolean

true if the table has no rows

Annotations
@Override
setCaptionback to summary
public Table<T> setCaption(Content captionContent)

Sets the caption for the table. This is ignored if the table is configured to provide tabs to select different subsets of rows within the table.

Parameters
captionContent:Content

the caption

Returns:Table<T>

this object

setColumnStylesback to summary
public Table<T> setColumnStyles(HtmlStyle... styles)

Sets the styles for be used for the cells in each row.

Note

  • The column styles are not currently applied to the header, but probably should, eventually
Parameters
styles:HtmlStyle[]

the styles

Returns:Table<T>

this object

setColumnStylesback to summary
public Table<T> setColumnStyles(List<HtmlStyle> styles)

Sets the styles for be used for the cells in each row.

Note

  • The column styles are not currently applied to the header, but probably should, eventually
Parameters
styles:List<HtmlStyle>

the styles

Returns:Table<T>

this object

setDefaultTabback to summary
public Table<T> setDefaultTab(Content label)

Sets the label for the default tab, which displays all the rows in the table. This tab will appear first in the left-to-right list of displayed tabs.

Parameters
label:Content

the default tab label

Returns:Table<T>

this object

setGridStyleback to summary
public Table<T> setGridStyle(HtmlStyle gridStyle)

Sets the style for the table's grid which controls allocation of space among table columns. The style should contain a display: grid; property and its number of columns must match the number of column styles and content passed to other methods in this class.

Parameters
gridStyle:HtmlStyle

the grid style

Returns:Table<T>

this object

setHeaderback to summary
public Table<T> setHeader(TableHeader header)

Sets the header for the table.

Notes

  • The column styles are not currently applied to the header, but probably should, eventually
Parameters
header:TableHeader

the header

Returns:Table<T>

this object

setIdback to summary
public Table<T> setId(HtmlId id)

Sets the id attribute of the table. This is required if the table has tabs, in which case a subsidiary id will be generated for the tabpanel. This subsidiary id is required for the ARIA support.

Parameters
id:HtmlId

the id

Returns:Table<T>

this object

setRenderTabsback to summary
public Table<T> setRenderTabs(boolean renderTabs)

Allows to set whether tabs should be rendered for this table. Some pages use their own controls to select table categories, in which case the tabs are omitted.

Parameters
renderTabs:boolean

true if table tabs should be rendered

Returns:Table<T>

this object

toContentback to summary
private Content toContent()

Returns the HTML for the table.

Returns:Content

the HTML

writeback to summary
public boolean write(Writer out, String newline, boolean atNewline) throws IOException

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

Doc from 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.

Annotations
@Override
Exceptions
IOException:
if an error occurs while writing the output
jdk.javadoc.internal.doclets.formats.html back to summary

pack-priv final Record Table.Tab<T>

extends Record
Class Inheritance
Record Components
label:Content 
predicate:Predicate<T> 
index:int 

A record containing the data for a table tab.

Field Summary

Modifier and TypeField and Description
private final int
index

Record Component accessed by index().

private final Content
label

Record Component accessed by label().

private final Predicate<T>
predicate

Record Component accessed by predicate().

Constructor Summary

AccessConstructor and Description
pack-priv
Tab(Content label, Predicate<T> predicate, int index)

Method Summary

Modifier and TypeMethod and Description
public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public int
index()

Record Component getter of index.

public Content
label()

Record Component getter of label.

public Predicate<T>
predicate()

Record Component getter of predicate.

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

indexback to summary
private final int index

Record Component accessed by index().

labelback to summary
private final Content label

Record Component accessed by label().

predicateback to summary
private final Predicate<T> predicate

Record Component accessed by predicate().

Constructor Detail

Tabback to summary
pack-priv Tab(Content label, Predicate<T> predicate, int index)

Method Detail

equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

indexback to summary
public int index()

Record Component getter of index.

labelback to summary
public Content label()

Record Component getter of label.

predicateback to summary
public Predicate<T> predicate()

Record Component getter of predicate.

toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.