public final class V1_AsciiTable extends Object
| Modifier and Type | Field and Description |
|---|---|
protected Map<Integer,String[][]> |
table
The actual table.
|
| Modifier | Constructor and Description |
|---|---|
protected |
V1_AsciiTable()
Instantiates a table.
|
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
_init(Integer[] columns)
Initialises columns.
|
protected boolean |
_init(Integer columns,
Integer width)
Initializes columns.
|
int |
addRow(Object... columns)
Adds a new row to the table.
|
Integer[] |
getColumnAr()
Returns a clone of the column array.
|
int |
getColumnCount()
Returns the number of columns set for the table.
|
int |
getWidth()
Returns the width of the table.
|
static V1_AsciiTable |
newTable(Integer[] columns)
Returns a new instance of an ASCII Table.
|
static V1_AsciiTable |
newTable(Integer columns,
Integer width)
Returns a new instance of an ASCII Table.
|
protected String[] |
obj2At(Object obj,
int colP)
Returns a string array with wrapped lines.
|
String |
render()
Returns a rendered table using given options for rendering.
|
protected StrBuilder |
renderBottomRule(String[][] row,
char[] theme)
Renders the bottom rule of the table.
|
protected StrBuilder |
renderMiddleRule(String[][] top,
String[][] bot,
char[] theme)
Renders a middle rule, that is a row separating two content rows.
|
protected StrBuilder |
renderRow(String[][] row,
char padChar,
char[] theme)
Renders rows of content with correct separators.
|
protected List<StrBuilder> |
renderTable(char padChar,
char[] theme)
Renders the table.
|
protected StrBuilder |
renderTopRule(String[][] row,
char[] theme)
Renders the top rule of the table.
|
V1_AsciiTable |
setPaddingCharacter(char padChar)
Sets the padding character, default is blank.
|
V1_AsciiTable |
setTheme(V1_StandardTableThemes theme)
Sets the rendering theme, default is plain 7 bit.
|
String |
toString()
Returns a string with debug information.
|
protected V1_AsciiTable()
newTable(Integer[]) or newTable(Integer, Integer) to obtain an instance of the ASCII table.public static V1_AsciiTable newTable(Integer columns, Integer width)
columns - number of columns for the tablewidth - maximum width of the tablepublic static V1_AsciiTable newTable(Integer[] columns)
columns - array with information about the width of each column (entries of array) and number of columns (size of array)public V1_AsciiTable setPaddingCharacter(char padChar)
padChar - new padding characterpublic V1_AsciiTable setTheme(V1_StandardTableThemes theme)
theme - new themepublic int addRow(Object... columns)
"|␣␣␣␣␣text␣␣␣␣␣|""|␣␣text␣␣␣|␣␣␣␣|""|text|␣␣␣␣␣␣␣␣␣|""|␣␣␣␣␣␣␣␣␣␣␣␣␣␣|"columns - text for the columnspublic Integer[] getColumnAr()
public int getColumnCount()
public int getWidth()
protected final boolean _init(Integer columns, Integer width)
columns - number of columnswidth - requested width of the tablenewTable(Integer, Integer)protected final boolean _init(Integer[] columns)
columns - array with column width information (entries) and number of columns (array length)newTable(Integer[])protected final String[] obj2At(Object obj, int colP)
obj - object containing a string (null and empty are allowed)colP - index to the column array for column widthpublic String render()
protected final StrBuilder renderMiddleRule(String[][] top, String[][] bot, char[] theme)
top - content row above the middle rulebot - content row below the middle ruletheme - row themeprotected final StrBuilder renderBottomRule(String[][] row, char[] theme)
row - last content row of the tabletheme - row themeprotected final StrBuilder renderRow(String[][] row, char padChar, char[] theme)
row - array with all lines for all columns of a single rowpadChar - padding charactertheme - row themeprotected final List<StrBuilder> renderTable(char padChar, char[] theme)
padChar - padding charactertheme - row themeprotected final StrBuilder renderTopRule(String[][] row, char[] theme)
row - first content row of the tabletheme - row themeCopyright © 2010–2015. All rights reserved.