Package org.dnsge.util.tableprinter
Class TableUtils
- java.lang.Object
-
- org.dnsge.util.tableprinter.TableUtils
-
public class TableUtils extends java.lang.ObjectClass 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 aListofTableRowsstatic intmaxOfThree(int a, int b, int c)Gets the maximum of three numbers usingMath.max(int, int)static java.lang.StringpadAccordingToAlignment(java.lang.String toPad, int length, TableAlignment alignment)Pads a string to a certain length according to aTableAlignmentstatic java.lang.StringpadToLength(java.lang.String input, int desiredLength)Pads a string with spaces at the end to a desired length (right padding)static voidverifyValidity(java.util.List<TableRow> rows)Verifies that theTableRowsall have the sameTableHeaderstatic java.lang.StringverticalDividerOf(int length, char horizontalBar)Creates a vertical divider of a specific length
-
-
-
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 paddesiredLength- 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 aListofTableRows- Parameters:
rows-ListofTableRows- 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 aTableAlignment- Parameters:
toPad- String to padlength- Length to pad toalignment-TableAlignmentto 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 dividerhorizontalBar- Char to use in the bar- Returns:
- String of the vertical divider
-
verifyValidity
public static void verifyValidity(java.util.List<TableRow> rows)
Verifies that theTableRowsall have the sameTableHeader- Parameters:
rows-ListofTableRowsto 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 usingMath.max(int, int)- Parameters:
a- int 1b- int 2c- int 3- Returns:
- Maximum of the three numbers
-
-