Class ASCIITableReport


  • public class ASCIITableReport
    extends java.lang.Object
    This builder allows easily to build ASCII tables around any data. Note that this implementation is not thread-safe.
    • Field Detail

      • EMPTY_CELL_MARKER

        public static final java.lang.String EMPTY_CELL_MARKER
        See Also:
        Constant Field Values
    • Method Detail

      • disableRowTitles

        public ASCIITableReport disableRowTitles()
        Disables all row titles which are normally displayed on left-hand side of the table.
      • withTopHeaders

        public ASCIITableReport withTopHeaders​(java.lang.String... headers)
        Allows to define top columns headers. Headers will be printed in the same order as passed to this method.
         builder.withTopHeaders("Foo", "Bar", "Baz")
         
        Parameters:
        headers - top column headers in form of varargs.
      • addDataRow

        public ASCIITableReport addDataRow​(java.lang.String... dataRow)
        Adds data row to the report. Row will be printed in the same order as passed to this method. If method titledBy(String) will be used as next in chain title for this row will be printed out as very first on the left hand side.
         builder.addDataRow("foo", "bar", "baz")
         
        Parameters:
        dataRow - data row in form of varargs.
      • titledBy

        public ASCIITableReport titledBy​(java.lang.String rowTitle)
        Title for the last data row defined by addDataRow(String...) method. This method must be used right after call to addDataRow(String...) to apply it to correct row.
         builder.addDataRow("foo", "bar", "baz").titledBy("My Row")
         
        Parameters:
        rowTitle - title for the last defined data row
      • printTable

        public void printTable()
        Prints report as ASCII table to the standard output.
      • getTable

        public java.lang.String getTable()
        Gets report as ASCII table in the String.