Package sonia.scm.cli

Class Table

java.lang.Object
sonia.scm.cli.Table
All Implemented Interfaces:
Iterable<Table.Row>

public final class Table extends Object implements Iterable<Table.Row>
This table can be used to display table-like command output
Since:
2.33.0
  • Method Details

    • addHeader

      public void addHeader(String... keys)
      Sets the table headers. You can use resource keys which will be translated using the related resource bundle.
      Parameters:
      keys - actual names or resource keys for your table header
    • addRow

      public void addRow(String... row)
      Add a single row of values to the table.
      Parameters:
      row - values for a single table row
    • addLabelValueRow

      public void addLabelValueRow(String label, String value)
      Creates a table entry with two columns separated by DEFAULT_LABEL_VALUE_SEPARATOR.
      Parameters:
      label - label for the left table column
      value - value for the right table column
    • addLabelValueRow

      public void addLabelValueRow(String label, String value, String separator)
      Creates a table entry with two columns separated by the given separator.
      Parameters:
      label - label for the left table column
      value - value for the right table column
      separator - separator used to separate the label from the value
    • getRows

      public List<Table.Row> getRows()
      Returns a list of the table rows. This is required for the internal table implementation.
      Returns:
      a list of the table rows
    • iterator

      public Iterator<Table.Row> iterator()
      Specified by:
      iterator in interface Iterable<Table.Row>