public class DataDisplayTable
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
DataDisplayTable.Align
Enum representing the alignment of the text when being displayed
|
Constructor and Description |
---|
DataDisplayTable(java.util.List<java.lang.String> header)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
add(java.util.List<java.lang.String> row)
Inserts a row of data into the table.
|
java.lang.String |
csvString()
Gets the table as a string of comma-separated values
|
java.lang.String[] |
csvStringArray()
Gets the table as an array of strings, where each string is a row in the
table as comma-separated values.
|
java.util.List<java.util.List<java.lang.String>> |
getData() |
java.util.List<DataDisplayTable.Align> |
getDisplayAlignment() |
java.util.List<java.lang.String> |
getHeader() |
java.util.List<java.lang.Integer> |
getMaxColLengths() |
int |
getNumColumns() |
int |
getNumRows() |
void |
prettyPrint()
Prints the data represented by the table to the terminal.
|
java.lang.String |
prettyString()
Gets a string representation of the table.
|
void |
setAlignment(java.util.List<DataDisplayTable.Align> alignment)
Sets display alignment of each table column.
|
java.lang.String |
toString() |
public DataDisplayTable(java.util.List<java.lang.String> header)
header
- the header columns of the tablepublic void setAlignment(java.util.List<DataDisplayTable.Align> alignment)
alignment
- array of values for each column alignmentjava.lang.UnsupportedOperationException
- if array size is different from column countpublic void add(java.util.List<java.lang.String> row)
row
- the row of data to insert into the tablejava.lang.UnsupportedOperationException
- if array size is different from columnpublic java.util.List<java.lang.String> getHeader()
public java.util.List<java.util.List<java.lang.String>> getData()
public int getNumColumns()
public int getNumRows()
public java.util.List<java.lang.Integer> getMaxColLengths()
public java.util.List<DataDisplayTable.Align> getDisplayAlignment()
public java.lang.String prettyString()
This function may run slowly for larger tables due to potential memory issues, and it is suggested that the function prettyPrint be used in the case of printing large tables to the console.
public void prettyPrint()
public java.lang.String csvString()
public java.lang.String[] csvStringArray()
public java.lang.String toString()
toString
in class java.lang.Object