Table

public interface Table

An interface for classes that generate tables from a given data set, following the Builder Design Pattern.

Author:Manoel Campos da Silva Filho

Methods

addColumn

TableColumn addColumn(String columnTitle)

Adds a column with a given to the end of the table’s columns to be printed.

Parameters:
  • columnTitle – The title of the column to be added.
Returns:

The created column.

addColumn

TableColumn addColumn(int index, String columnTitle)

Adds a column with a given title to the end of the table’s columns to be printed.

Parameters:
  • index – the position to insert the column into the column’s list
  • columnTitle – The title of the column to be added.
Returns:

the created column

addColumn

TableColumn addColumn(String columnTitle, String columnSubTitle)

Adds a column with a given title and sub-title to the end of the table’s columns to be printed.

Parameters:
  • columnTitle – The title of the column to be added.
  • columnSubTitle – The sub-title of the column to be added.
Returns:

the created column

addColumn

TableColumn addColumn(int index, TableColumn column)

Adds a column object to a specific position of the table’s columns to be printed.

Parameters:
  • index – the position to insert the column into the column’s list
  • column – The column to be added.
Returns:

the created column

addColumn

TableColumn addColumn(TableColumn column)

Adds a column object to the end of the table’s columns to be printed.

Parameters:
  • column – The column to be added.
Returns:

the created column

addColumnList

Table addColumnList(String... columnTitles)

Adds a list of columns (with given titles) to the end of the table’s columns to be printed, where the column data will be printed without a specific format.

Parameters:
  • columnTitles – The titles of the columns
Returns:

the Table instance.

See also: .addColumn(String)

getColumnSeparator

String getColumnSeparator()

Gets the string used to separate one column from another (optional).

getColumns

List<TableColumn> getColumns()
Returns:the list of columns of the table

getTitle

String getTitle()
Returns:the table title

newRow

List<Object> newRow()

Adds a new row to the list of rows containing the data to be printed.

print

void print()

Prints the table.

setColumnSeparator

Table setColumnSeparator(String columnSeparator)

Sets the string used to separate one column from another (optional).

Parameters:
  • columnSeparator – the separator to set

setTitle

Table setTitle(String title)
Parameters:
  • title – the table title to set
Returns:

The Table instance