public class TextTable extends Object
Constructor and Description |
---|
TextTable(int rows,
int columns)
Constructs a text table with predefined number of rows and columns.
|
Modifier and Type | Method and Description |
---|---|
Appendable |
format(Appendable a)
Formats the TextTable and outputs to an Appendable.
|
StringBuffer |
format(StringBuffer b)
StringBuffer version of format.
|
StringBuilder |
format(StringBuilder b)
StringBuilder version of format.
|
CharSequence |
getField(int row,
int column)
Obtains the field so formatters can insert values directly.
|
CharSequence |
getHeader(int column)
Gets the header field's value.
|
void |
setField(int row,
int column,
CharSequence field)
Sets the data fields' value.
|
void |
setHeader(int column,
CharSequence header)
Sets the header fields' value.
|
String |
toString()
Returns the formatted table in a string.
|
public TextTable(int rows, int columns)
rows
- The number of rowscolumns
- The number of columnspublic void setHeader(int column, CharSequence header)
column
- The column to set the headerheader
- The headerpublic CharSequence getHeader(int column)
column
- The colund to get the headerpublic void setField(int row, int column, CharSequence field)
row
- The row index of the datacolumn
- The column index of the datafield
- The data fieldpublic CharSequence getField(int row, int column)
row
- The row indexcolumn
- The column indexpublic StringBuilder format(StringBuilder b)
b
- The StringBuilder to append topublic StringBuffer format(StringBuffer b)
b
- The StringBuffer to append topublic Appendable format(Appendable a) throws IOException
a
- The Appendable to output the textIOException
- Problems writing to the Appendable