Class Table
- java.lang.Object
-
- com.identityworksllc.iiq.common.table.Element
-
- com.identityworksllc.iiq.common.table.Table
-
public class Table extends Element
Type-safe fluent API for creating HTML tables from data inputs.Usage examples:
Table table = new Table(); (Populating a table with individual cell data) table .withCellClasses("cellClass") .row().header() .cell("Header A").withClass("abc") .cell("Header B") .row() .cell(val1) .cell(val2) .row() .cell(val3) .cell(val4); (Populating a table with list data) table .row(headers).header() .row(list1).withClass("firstRowClass") .row(list2); (Populating a table with lists of lists) List rowData = List.of(row1, row2, row3); table .row(headers).header() .rows(rowData);
-
-
Field Summary
-
Fields inherited from class com.identityworksllc.iiq.common.table.Element
cssClasses, style
-
-
Constructor Summary
Constructors Constructor Description Table()
Constructs a new tableTable(List<Object> rows, CellOption... options)
Creates a new Table and populates it with the given row data and options
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Table
cell(Cell cell)
Adds a specified cell to the current row.Table
cell(Object value, CellOption... options)
Adds a new cell to the current row with the given value contentTable
clearCellClasses()
Clears the cell classes list set bywithCellClasses(String...)
Table
header()
Sets the current row or cell to be a header.Table
header(List<Object> values)
Creates a new header row and populates it with the given cell valuesTable
htmlCell(Object value)
Adds a new HTML cell to the current rowString
render()
Renders the table as HTMLTable
row()
Starts a new row in the tableTable
row(List<Object> values, CellOption... options)
Creates a new (non-header) row and populates it with the given cell values.Table
rows(List<Object> rowData, CellOption... cellOptions)
Accepts a set of row data and adds it to the output table.Table
setColumnCellOptions(int column, CellOption... options)
To be used after populating the table: applies the given CellOption modifications to the cells at the given column index in each row.Table
setColumnStyle(int column, String style)
To be used after populating the table: sets the given style to the cells at the given column in each row.Table
setExtraColumnStyle(int column, String style)
To be used after populating the table: appends the given style to the cells at the given column in each row.Table
setRowCellOptions(int row, CellOption... options)
To be used after populating the table: sets the given style to the given row, indexed starting from zero, including the header row.Table
setRowStyle(int row, String style)
To be used after populating the table: sets the given style to the given row, indexed starting from zero, including the header row.Table
width(int value)
Sets the table width to the given value, in percentTable
withCellClasses(String... classes)
All future cells will have the given classes appended.Table
withCellOptions(CellOption... options)
Applies the given set of cell options to either the current cell or the current row.Table
withCellOptions(List<CellOption> options)
Applies the given set of cell options to the current object.Table
withClass(String... cssClasses)
Adds the given CSS class to the current objectTable
withHeaderRow(CellOption... options)
Resets the first row to be a header row, which will have its header flag set and any given options applied to all cells in the row.Table
withStyle(String style)
Sets the style of the current item to the given value.-
Methods inherited from class com.identityworksllc.iiq.common.table.Element
getCssClasses, getEscapedCssClassAttr, getEscapedStyle, getStyle, setCssClasses, setStyle
-
-
-
-
Constructor Detail
-
Table
public Table()
Constructs a new table
-
Table
public Table(List<Object> rows, CellOption... options) throws sailpoint.tools.GeneralException
Creates a new Table and populates it with the given row data and options- Parameters:
rows
- The row data to addoptions
- The cell options- Throws:
sailpoint.tools.GeneralException
- on failures applying the cell options
-
-
Method Detail
-
cell
public Table cell(Object value, CellOption... options) throws sailpoint.tools.GeneralException
Adds a new cell to the current row with the given value content- Parameters:
value
- The value to add- Throws:
sailpoint.tools.GeneralException
-
cell
public Table cell(Cell cell) throws sailpoint.tools.GeneralException
Adds a specified cell to the current row.The cell will be modified to add the ‘withCellClasses’ classes, if any have been specified.
- Parameters:
cell
- The cell to add- Throws:
sailpoint.tools.GeneralException
-
clearCellClasses
public Table clearCellClasses()
Clears the cell classes list set bywithCellClasses(String...)
-
header
public Table header()
Sets the current row or cell to be a header.If the current object is a row, all cells in that row will be header cells.
-
header
public Table header(List<Object> values) throws sailpoint.tools.GeneralException
Creates a new header row and populates it with the given cell values- Parameters:
values
- The values to add- Throws:
sailpoint.tools.GeneralException
-
htmlCell
public Table htmlCell(Object value) throws sailpoint.tools.GeneralException
Adds a new HTML cell to the current row- Parameters:
value
- The HTML contents- Throws:
sailpoint.tools.GeneralException
-
row
public Table row(List<Object> values, CellOption... options) throws sailpoint.tools.GeneralException
Creates a new (non-header) row and populates it with the given cell values.This will NOT put the builder into cell mode, so all style/class operators will apply to the row.
If the value is a Cell object obtained via
Cell.of(Object, CellOption...)
, it will be inserted as-is. Otherwise, the provided CellOptions will be applied to each cell as it is added.- Parameters:
values
- The values to addoptions
- Any cell options you wish to add to each cell- Throws:
sailpoint.tools.GeneralException
-
rows
public Table rows(List<Object> rowData, CellOption... cellOptions) throws sailpoint.tools.GeneralException
Accepts a set of row data and adds it to the output table.The input should be a list of lists. Each item will be interpreted as input to
row(List, CellOption...)
. All non-list inputs will be quietly ignored.The current row and cell will remain blank afterwards, so you cannot use builder syntax to modify the most recent cell or row.
- Parameters:
rowData
- The row data- Throws:
sailpoint.tools.GeneralException
-
setColumnCellOptions
public Table setColumnCellOptions(int column, CellOption... options) throws sailpoint.tools.GeneralException
To be used after populating the table: applies the given CellOption modifications to the cells at the given column index in each row.If a given row does not have enough cells, nothing will happen for that row.
- Parameters:
column
- The column indexoptions
- The cell options to apply- Throws:
sailpoint.tools.GeneralException
-
setColumnStyle
public Table setColumnStyle(int column, String style)
To be used after populating the table: sets the given style to the cells at the given column in each row.- Parameters:
column
- The column indexstyle
- The style
-
setExtraColumnStyle
public Table setExtraColumnStyle(int column, String style)
To be used after populating the table: appends the given style to the cells at the given column in each row.- Parameters:
column
- The column indexstyle
- The style
-
setRowCellOptions
public Table setRowCellOptions(int row, CellOption... options) throws sailpoint.tools.GeneralException
To be used after populating the table: sets the given style to the given row, indexed starting from zero, including the header row.- Parameters:
row
- The row indexoptions
- The options to apply to each cell in this row- Throws:
sailpoint.tools.GeneralException
-
setRowStyle
public Table setRowStyle(int row, String style)
To be used after populating the table: sets the given style to the given row, indexed starting from zero, including the header row.- Parameters:
row
- The row indexstyle
- The style
-
width
public Table width(int value)
Sets the table width to the given value, in percent- Parameters:
value
- The percentage
-
withCellClasses
public Table withCellClasses(String... classes)
All future cells will have the given classes appended.Note that cells already in the table will not have the classes added. You should call this method before adding any cells.
-
withCellOptions
public Table withCellOptions(List<CellOption> options) throws sailpoint.tools.GeneralException
Applies the given set of cell options to the current object.If applied to a row, it will apply the options to all cells currently in the row and all cells added to the row in the future.
If applied to a cell, it apply only to that cell.
If applied to the table, it will apply to all cells in any row.
- Parameters:
options
- The options to apply to each relevant cell- Throws:
sailpoint.tools.GeneralException
-
withCellOptions
public Table withCellOptions(CellOption... options) throws sailpoint.tools.GeneralException
Applies the given set of cell options to either the current cell or the current row.If applied to a row, it will apply the options to all cells currently in the row and all cells added to the row in the future.
- Parameters:
options
- The options to apply to each relevant cell- Throws:
sailpoint.tools.GeneralException
-
withClass
public Table withClass(String... cssClasses)
Adds the given CSS class to the current object- Parameters:
cssClasses
- The CSS class (or space-separated classes)
-
withHeaderRow
public Table withHeaderRow(CellOption... options) throws sailpoint.tools.GeneralException
Resets the first row to be a header row, which will have its header flag set and any given options applied to all cells in the row.- Parameters:
options
- An optional list of CellOptions to apply to each cell in the row- Throws:
sailpoint.tools.GeneralException
- On any failures applying the CellOptions
-
-