java.lang.Object
org.sentrysoftware.metricshub.engine.common.helpers.TextTableHelper

public class TextTableHelper extends Object
Helper class providing methods for working with text tables.
  • Method Details

    • generateTextTable

      public static String generateTextTable(List<List<String>> rows)
      Creates a text table for the given rows.

      Each row is designed as a List of String values.

      The headers are generated as Column 1, Column 2, ..., with the number of columns being based on the number of columns in the longest row.
      Parameters:
      rows - The List of rows.
      Returns:
      A formatted text table representing the given rows.
    • generateTextTable

      public static String generateTextTable(String semiColonSeparatedColumns, List<List<String>> rows)
      Creates a text table for the given rows.

      Each row is designed as a List of String values.

      The headers are generated based on semiColonSeparatedColumns (e.g. : column1;column2).
      Parameters:
      semiColonSeparatedColumns - A semicolon-separated list of column names.
      rows - The List of rows.
      Returns:
      A formatted text table representing the given rows, with the given column names as the headers.
    • generateTextTable

      public static String generateTextTable(String[] columns, List<List<String>> rows)
      Creates a text table for the given rows.

      Each row is designed as a List of String values.

      The headers are generated based on columns (e.g. : new String[] {column1, column2}).
      Parameters:
      columns - An array of column names.
      rows - The List of rows.
      Returns:
      A formatted text table representing the given rows, with the given column names as the headers.
    • generateTextTable

      public static String generateTextTable(Collection<String> columns, List<List<String>> rows)
      Creates a text table for the given rows.

      Each row is designed as a List of String values.

      The headers are generated based on columns (e.g. : Arrays.asList(column1, column2)).
      Parameters:
      columns - An Collection of column names.
      rows - The List of rows.
      Returns:
      A formatted text table representing the given rows, with the given column names as the headers.
    • generateTextTable

      public static String generateTextTable(List<TableHeader> headers, List<List<String>> rows)
      Create a text table for the given headers and the corresponding rows.
      Each row is designed as a List of String values.
      • This method expects non-null headers List and non-null rows List
      • headers List cannot contain null values
      • The row List elements order is important and must match the same order as on the headers List
      • A null row is ignored
      • A row can be empty or having a size less than the headers size
      • Extra cells in a row are ignored
      Parameters:
      headers - List of columns we wish to insert in the text table
      rows - List of List elements
      Returns:
      Text table