public static class CommandLine.Help.TextTable extends Object
Responsible for spacing out CommandLine.Help.Ansi.Text
values according to the CommandLine.Help.Column
definitions the table was
created with. Columns have a width, indentation, and an overflow policy that decides what to do if a value is
longer than the column's width.
Modifier and Type | Class and Description |
---|---|
static class |
CommandLine.Help.TextTable.Cell
Helper class to index positions in a
Help.TextTable . |
Modifier and Type | Field and Description |
---|---|
CommandLine.Help.Column[] |
columns
The column definitions of this table.
|
protected List<CommandLine.Help.Ansi.Text> |
columnValues
The
char[] slots of the TextTable to copy text values into. |
int |
indentWrappedLines
By default, indent wrapped lines by 2 spaces.
|
Constructor and Description |
---|
TextTable(CommandLine.Help.Ansi ansi)
Constructs a TextTable with five columns as follows:
required option/parameter marker (width: 2, indent: 0, TRUNCATE on overflow)
short option name (width: 2, indent: 0, TRUNCATE on overflow)
comma separator (width: 1, indent: 0, TRUNCATE on overflow)
long option name(s) (width: 24, indent: 1, SPAN multiple columns on overflow)
description line(s) (width: 51, indent: 1, WRAP to next row on overflow)
|
TextTable(CommandLine.Help.Ansi ansi,
CommandLine.Help.Column... columns)
Constructs a
TextTable with the specified columns. |
TextTable(CommandLine.Help.Ansi ansi,
int... columnWidths)
Constructs a new TextTable with columns with the specified width, all SPANning multiple columns on
overflow except the last column which WRAPS to the next row.
|
Modifier and Type | Method and Description |
---|---|
void |
addEmptyRow()
Adds the required
char[] slots for a new row to the columnValues field. |
void |
addRowValues(CommandLine.Help.Ansi.Text... values)
|
void |
addRowValues(String... values)
Delegates to
addRowValues(CommandLine.Help.Ansi.Text...) . |
CommandLine.Help.Ansi.Text |
cellAt(int row,
int col)
Deprecated.
use
textAt(int, int) instead |
CommandLine.Help.TextTable.Cell |
putValue(int row,
int col,
CommandLine.Help.Ansi.Text value)
Writes the specified value into the cell at the specified row and column and returns the last row and
column written to.
|
int |
rowCount()
Returns the current number of rows of this
TextTable . |
CommandLine.Help.Ansi.Text |
textAt(int row,
int col)
Returns the
Text slot at the specified row and column to write a text value into. |
String |
toString() |
StringBuilder |
toString(StringBuilder text)
Copies the text representation that we built up from the options into the specified StringBuilder.
|
public final CommandLine.Help.Column[] columns
protected final List<CommandLine.Help.Ansi.Text> columnValues
char[]
slots of the TextTable
to copy text values into.public int indentWrappedLines
public TextTable(CommandLine.Help.Ansi ansi)
ansi
- whether to emit ANSI escape codes or notpublic TextTable(CommandLine.Help.Ansi ansi, int... columnWidths)
ansi
- whether to emit ANSI escape codes or notcolumnWidths
- the width of the table columns (all columns have zero indent)public TextTable(CommandLine.Help.Ansi ansi, CommandLine.Help.Column... columns)
TextTable
with the specified columns.ansi
- whether to emit ANSI escape codes or notcolumns
- columns to construct this TextTable withpublic CommandLine.Help.Ansi.Text textAt(int row, int col)
Text
slot at the specified row and column to write a text value into.row
- the row of the cell whose Text to returncol
- the column of the cell whose Text to return@Deprecated public CommandLine.Help.Ansi.Text cellAt(int row, int col)
textAt(int, int)
insteadText
slot at the specified row and column to write a text value into.row
- the row of the cell whose Text to returncol
- the column of the cell whose Text to returnpublic int rowCount()
TextTable
.public void addEmptyRow()
char[]
slots for a new row to the columnValues
field.public void addRowValues(String... values)
addRowValues(CommandLine.Help.Ansi.Text...)
.values
- the text values to display in each column of the current rowpublic void addRowValues(CommandLine.Help.Ansi.Text... values)
putValue
for each of the specified values, adding more empty rows
if the return value indicates that the value spanned multiple columns or was wrapped to multiple rows.values
- the values to write into a new row in this TextTableIllegalArgumentException
- if the number of values exceeds the number of Columns in this tablepublic CommandLine.Help.TextTable.Cell putValue(int row, int col, CommandLine.Help.Ansi.Text value)
Overflow
policy, the value may span
multiple columns or wrap to multiple rows when larger than the column width.row
- the target row in the tablecol
- the target column in the table to write tovalue
- the value to writeIllegalArgumentException
- if the specified row exceeds the table's row countjava.awt.Point
object)public StringBuilder toString(StringBuilder text)
text
- the StringBuilder to write into Copyright © 1999-2023 The Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.