Class AsciiTable


  • public final class AsciiTable
    extends Object
    An ASCII table generator.

    Provides the ability to generate a simple ASCII table, typically used on the command line. All data is provided as strings, with formatting the responsibility of the caller.

    • Method Detail

      • generate

        public static String generate​(List<String> headers,
                                      List<AsciiTableAlignment> alignments,
                                      List<? extends List<String>> cells)
        Generates the ASCII table.

        The caller specifies the headers for each column and the alignment to use, plus the list of lists representing the data. All data is provided as strings, with formatting the responsibility of the caller.

        Parameters:
        headers - the table headers
        alignments - the table alignments, must match the size of the headers
        cells - the table cells, outer list of rows, inner list of columns
        Returns:
        the table
        Throws:
        IllegalArgumentException - if the number of columns specified is inconsistent