Package com.forgerock.opendj.cli
Class TextTablePrinter
- java.lang.Object
-
- com.forgerock.opendj.cli.TablePrinter
-
- com.forgerock.opendj.cli.TextTablePrinter
-
public final class TextTablePrinter extends TablePrinter
An interface for creating a text based table. Tables have configurable column widths, padding, and column separators.
-
-
Constructor Summary
Constructors Constructor Description TextTablePrinter(OutputStream stream)Creates a new text table printer for the specified output stream.TextTablePrinter(Writer writer)Creates a new text table printer for the specified writer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected TableSerializergetSerializer()Creates a new table serializer based on the configuration of this table printer.voidsetColumnSeparator(String columnSeparator)Sets the column separator which should be used to separate one column from the next (not including padding).voidsetColumnWidth(int column, int width)Set the maximum width for a column.voidsetDisplayHeadings(boolean displayHeadings)Specify whether the column headings should be displayed or not.voidsetHeadingSeparator(char headingSeparator)Sets the heading separator which should be used to separate the table heading row from the rows beneath.voidsetHeadingSeparatorStartColumn(int startColumn)Sets the heading separator start column.voidsetIndentWidth(int indentWidth)Sets the amount of characters that the table should be indented.voidsetPadding(int padding)Sets the padding which will be used to separate a cell's contents from its adjacent column separators.voidsetTotalWidth(int totalWidth)Sets the total permitted width for the table which expandable columns can use up.
-
-
-
Constructor Detail
-
TextTablePrinter
public TextTablePrinter(OutputStream stream)
Creates a new text table printer for the specified output stream. The text table printer will have the following initial settings:- headings will be displayed
- no separators between columns
- columns are padded by one character
- Parameters:
stream- The stream to output tables to.
-
TextTablePrinter
public TextTablePrinter(Writer writer)
Creates a new text table printer for the specified writer. The text table printer will have the following initial settings:- headings will be displayed
- no separators between columns
- columns are padded by one character
- Parameters:
writer- The writer to output tables to.
-
-
Method Detail
-
setColumnSeparator
public void setColumnSeparator(String columnSeparator)
Sets the column separator which should be used to separate one column from the next (not including padding).- Parameters:
columnSeparator- The column separator.
-
setColumnWidth
public void setColumnWidth(int column, int width)Set the maximum width for a column. If a cell is too big to fit in its column then it will be wrapped.- Parameters:
column- The column to make fixed width (0 is the first column).width- The width of the column (this should not include column separators or padding), or0to indicate that this column should be expandable.- Throws:
IllegalArgumentException- If column is less than 0.
-
setDisplayHeadings
public void setDisplayHeadings(boolean displayHeadings)
Specify whether the column headings should be displayed or not.- Parameters:
displayHeadings-trueif column headings should be displayed.
-
setHeadingSeparator
public void setHeadingSeparator(char headingSeparator)
Sets the heading separator which should be used to separate the table heading row from the rows beneath.- Parameters:
headingSeparator- The heading separator.
-
setHeadingSeparatorStartColumn
public void setHeadingSeparatorStartColumn(int startColumn)
Sets the heading separator start column. The heading separator will only be display in the specified column and all subsequent columns. Usually this should be left at zero (the default) but sometimes it useful to indent the heading separate in order to provide additional emphasis (for example in menus).- Parameters:
startColumn- The heading separator start column.
-
setIndentWidth
public void setIndentWidth(int indentWidth)
Sets the amount of characters that the table should be indented. By default the table is not indented.- Parameters:
indentWidth- The number of characters the table should be indented.- Throws:
IllegalArgumentException- If indentWidth is less than 0.
-
setPadding
public void setPadding(int padding)
Sets the padding which will be used to separate a cell's contents from its adjacent column separators.- Parameters:
padding- The padding.
-
setTotalWidth
public void setTotalWidth(int totalWidth)
Sets the total permitted width for the table which expandable columns can use up.- Parameters:
totalWidth- The total width.
-
getSerializer
protected TableSerializer getSerializer()
Description copied from class:TablePrinterCreates a new table serializer based on the configuration of this table printer.- Specified by:
getSerializerin classTablePrinter- Returns:
- Returns a new table serializer based on the configuration of this table printer.
-
-