Class AsciiTable


  • public final class AsciiTable
    extends java.lang.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 Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String generate​(java.util.List<java.lang.String> headers, java.util.List<AsciiTableAlignment> alignments, java.util.List<? extends java.util.List<java.lang.String>> cells)
      Generates the ASCII table.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • generate

        public static java.lang.String generate​(java.util.List<java.lang.String> headers,
                                                java.util.List<AsciiTableAlignment> alignments,
                                                java.util.List<? extends java.util.List<java.lang.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:
        java.lang.IllegalArgumentException - if the number of columns specified is inconsistent