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 TextualTable setShowHeaders(boolean v)
public TextualTable setStyle(Style style)
public TextualTable setMaxColumnWidth(int n)
public io.github.qishr.cascara.common.data.@io.github.qishr.cascara.common.annotation.Experimental TextualTable setBorderColor(String s)
public TextualTable addColumn(String headerText) 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 TextualTable render(Writer writer) Renders the table as text without any indentation.
public TextualTable render(Writer writer, int indent) Renders the table as text with a given indentation level (number of spaces).

Method Details

setShowHeaders

public TextualTable setShowHeaders(boolean v)

Returns:

The table (this) to allow method chaining.


setStyle

public TextualTable setStyle(Style style)

Returns:

The table (this) to allow method chaining.


setMaxColumnWidth

public TextualTable setMaxColumnWidth(int n)

Returns:

The table (this) to allow method chaining.


setBorderColor

@io.github.qishr.cascara.common.annotation.Experimental
public io.github.qishr.cascara.common.data.@io.github.qishr.cascara.common.annotation.Experimental TextualTable setBorderColor(String s)

Returns:

The table (this) to allow method chaining.


addColumn

public TextualTable addColumn(String headerText)

Adds a column with the specified heading to the table.

Parameters:

headerText - String to be used as the column heading.

Returns:

The table (this) to allow method chaining.


addRow

public TextualTable addRow(TabularData row)

Returns:

The table (this) to allow method chaining.


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 TextualTable render(Writer writer)

Renders the table as text without any indentation.

Parameters:

writer - The Writer to output text to.

Returns:

The table (this) to allow method chaining.


render

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