|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.objectweb.cjdbc.console.text.formatter.TableFormatter
Utility class to format a table which can be pretty displayed in the text console.
Constructor Summary | |
TableFormatter()
|
Method Summary | |
private static void |
appendCellsTo(java.lang.String[][] cells,
java.lang.StringBuffer buf,
int[] longestLengths)
Append a table of cells to the buffer |
private static void |
appendHeaderAndCells(java.lang.String[] headers,
java.lang.String[][] cells,
java.lang.StringBuffer buf,
int[] longestLengths,
java.lang.String horizontalRule)
Append table's headers and cells in one pass. |
private static void |
appendHeadersTo(java.lang.String[] headers,
java.lang.StringBuffer buf,
int[] longestLengths)
Append table's headers to the buffer |
private static void |
appendStringTo(java.lang.StringBuffer buf,
java.lang.String string,
int n)
Append n times the string to buf . |
private static java.lang.String |
createHorizontalRule(int[] longestLengths)
Create an horizontal rule following the format: +-----+-------+-----+
where the size of each part is determinged based on the longest length
for each column |
private static int[] |
findLongestDataLengths(java.lang.String[] headers,
java.lang.String[][] cells,
boolean headersAsRow)
Find the longest lengths for the data. |
static java.lang.String |
format(java.lang.String[] headers,
java.lang.String[][] cells,
boolean headersAsRow)
Format as a table. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public TableFormatter()
Method Detail |
public static java.lang.String format(java.lang.String[] headers, java.lang.String[][] cells, boolean headersAsRow)
headers
- the headers of the tablecells
- the cells of the tableheadersAsRow
- true
if the headers must be displayed on the same row,
false
if the headers must be displayed on the same column
private static java.lang.String createHorizontalRule(int[] longestLengths)
+-----+-------+-----+
where the size of each part is determinged based on the longest length
for each column
longestLengths
- an array of int corresponding to the longest length of cells for a given column
String
to used as an horizontal ruleprivate static void appendStringTo(java.lang.StringBuffer buf, java.lang.String string, int n)
n
times the string
to buf
.
buf
- a StringBuffer
string
- the String
to appendn
- the number of times the string should be appendedprivate static int[] findLongestDataLengths(java.lang.String[] headers, java.lang.String[][] cells, boolean headersAsRow)
headers
- headers of the tablecells
- cells of the tableheadersAsRow
- true
if the headers must be displayed on the same row,
false
if the headers must be displayed on the same column
int
containing the longest length for each columnprivate static void appendCellsTo(java.lang.String[][] cells, java.lang.StringBuffer buf, int[] longestLengths)
cells
- the table of cells to appendbuf
- the StringBuffer
where to appendlongestLengths
- used to fill each cell with whitespaces so
that everything is properly formattedprivate static void appendHeadersTo(java.lang.String[] headers, java.lang.StringBuffer buf, int[] longestLengths)
headers
- the headers of the tablebuf
- the StringBuffer
where to appendlongestLengths
- used to fill each cell with whitespaces so
that everything is properly formattedprivate static void appendHeaderAndCells(java.lang.String[] headers, java.lang.String[][] cells, java.lang.StringBuffer buf, int[] longestLengths, java.lang.String horizontalRule)
headersAsRow
was false
).
headers
- the headers of the tablebuf
- the StringBuffer
where to appendlongestLengths
- used to fill each cell with whitespaces so
that everything is properly formattedhorizontalRule
- an horizontal rule
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |