Class TextTable


  • public class TextTable
    extends java.lang.Object
    A utility class for generating multi-column aligned text tables.
    Author:
    Matthew Wakeling
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String[] ROW_SEPARATOR
      An object representing a horizontal line separating two rows - treated as a row.
    • Constructor Summary

      Constructors 
      Constructor Description
      TextTable​(boolean leftBound, boolean columnSeparators, boolean rightBound)
      Creates a new TextTable object, with or without column separating lines.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addRow​(java.lang.String... row)
      Adds a single row to the table.
      java.lang.String toString()
      Returns a text-formatted representation of this table.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • ROW_SEPARATOR

        public static final java.lang.String[] ROW_SEPARATOR
        An object representing a horizontal line separating two rows - treated as a row.
    • Constructor Detail

      • TextTable

        public TextTable​(boolean leftBound,
                         boolean columnSeparators,
                         boolean rightBound)
        Creates a new TextTable object, with or without column separating lines.
        Parameters:
        leftBound - true for a vertical line to the left of the leftmost column
        columnSeparators - true for vertical lines separating the columns
        rightBound - true for a vertical line to the right of the rightmost column
    • Method Detail

      • addRow

        public void addRow​(java.lang.String... row)
        Adds a single row to the table.
        Parameters:
        row - an array of Strings - each String being a column
      • toString

        public java.lang.String toString()
        Returns a text-formatted representation of this table.
        Overrides:
        toString in class java.lang.Object
        Returns:
        a String, either empty or with a trailing newline