Package io.github.qishr.cascara.common.data
Class Table
java.lang.Object
io.github.qishr.cascara.common.data.Table
public class Table
A utility class for creating tables .This class allows adding columns with headings and rows with data. It automatically calculates column widths to align the table content.
Constructor Summary
| Constructor | Description |
|---|---|
| Table() | Constructs an empty Table. |
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
| public void | setShowBorder(boolean v) | |
| public void | setShowHeaders(boolean v) | |
| public Table | addColumn(String heading) | Adds a column with the specified heading to the table. |
| public Table | addRow(TableData row) | |
| public Table | addRow(String[] valueStrings) | Adds a row of data to the table. |
| public void | render(Writer writer) | Renders the table as text without any indentation. |
| public void | render(Writer writer, int indent) | Renders the table as text with a given indentation level (number of spaces). |
Method Details
setShowBorder
public void setShowBorder(boolean v)
setShowHeaders
public void setShowHeaders(boolean v)
addColumn
public Table addColumn(String heading)
Adds a column with the specified heading to the table.
Parameters:
heading - String to be used as the column heading.
Returns:
The table (this) to allow method chaining.
addRow
public Table addRow(TableData row)
addRow
public Table addRow(String[] valueStrings)
Adds a row of data to the table.The number of values should match or be less than the number of columns.
Parameters:
valueStrings - One or more strings representing the data for this row.
Returns:
The table (this) to allow method chaining.
render
public void render(Writer writer)
Renders the table as text without any indentation.
Parameters:
writer - The Writer to output text to.
Throws:
render
public void render(Writer writer, int indent)
Renders the table as text with a given indentation level (number of spaces).
Parameters:
writer - The Writer to output text to.
indent - The number of spaces to indent each line.
Throws: