Skip to content

Package io.github.qishr.cascara.common.data

Class TextualTable

java.lang.Object
        io.github.qishr.cascara.common.data.TextualTable


public class TextualTable

A utility class for creating text-based 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
TextualTable() Constructs an empty Table.

Method Summary

Modifier and Type Method Description
public void setShowHeaders(boolean v)
public void setStyle(Style style)
public TextualTable addColumn(String heading) Adds a column with the specified heading to the table.
public TextualTable addRow(TabularData row)
public TextualTable 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

setShowHeaders

public void setShowHeaders(boolean v)


setStyle

public void setStyle(Style style)


addColumn

public TextualTable 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 TextualTable addRow(TabularData row)


addRow

public TextualTable 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.


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.