Class TableUtils


  • public class TableUtils
    extends java.lang.Object
    Class that contains static methods used to perform basic operations
    Version:
    2.0
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int[] longestLengthByColumns​(java.util.List<TableRow> rows)
      Creates an array of integers that represents the longest item by column number from a List of TableRows
      static int maxOfThree​(int a, int b, int c)
      Gets the maximum of three numbers using Math.max(int, int)
      static java.lang.String padAccordingToAlignment​(java.lang.String toPad, int length, TableAlignment alignment)
      Pads a string to a certain length according to a TableAlignment
      static java.lang.String padToLength​(java.lang.String input, int desiredLength)
      Pads a string with spaces at the end to a desired length (right padding)
      static void verifyValidity​(java.util.List<TableRow> rows)
      Verifies that the TableRows all have the same TableHeader
      static java.lang.String verticalDividerOf​(int length, char horizontalBar)
      Creates a vertical divider of a specific length
      • Methods inherited from class java.lang.Object

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

      • padToLength

        public static java.lang.String padToLength​(java.lang.String input,
                                                   int desiredLength)
        Pads a string with spaces at the end to a desired length (right padding)
        Parameters:
        input - String to pad
        desiredLength - Desired length of resulting string
        Returns:
        Padded String
      • longestLengthByColumns

        public static int[] longestLengthByColumns​(java.util.List<TableRow> rows)
        Creates an array of integers that represents the longest item by column number from a List of TableRows
        Parameters:
        rows - List of TableRows
        Returns:
        Array of ints representing the longest item by column
      • padAccordingToAlignment

        public static java.lang.String padAccordingToAlignment​(java.lang.String toPad,
                                                               int length,
                                                               TableAlignment alignment)
        Pads a string to a certain length according to a TableAlignment
        Parameters:
        toPad - String to pad
        length - Length to pad to
        alignment - TableAlignment to pad according to
        Returns:
        Padded String
      • verticalDividerOf

        public static java.lang.String verticalDividerOf​(int length,
                                                         char horizontalBar)
        Creates a vertical divider of a specific length
        Parameters:
        length - Length of desired vertical divider
        horizontalBar - Char to use in the bar
        Returns:
        String of the vertical divider
      • verifyValidity

        public static void verifyValidity​(java.util.List<TableRow> rows)
        Verifies that the TableRows all have the same TableHeader
        Parameters:
        rows - List of TableRows to verify
        Throws:
        java.lang.IllegalArgumentException - if not valid
      • maxOfThree

        public static int maxOfThree​(int a,
                                     int b,
                                     int c)
        Gets the maximum of three numbers using Math.max(int, int)
        Parameters:
        a - int 1
        b - int 2
        c - int 3
        Returns:
        Maximum of the three numbers