Package org.refcodes.textual
Class TableBuilderImpl
- java.lang.Object
-
- org.refcodes.textual.TableBuilderImpl
-
- All Implemented Interfaces:
org.refcodes.mixin.EscapeCodesStatusAccessor
,org.refcodes.mixin.EscapeCodesStatusAccessor.EscapeCodeStatusBuilder<TableBuilder>
,org.refcodes.mixin.EscapeCodesStatusAccessor.EscapeCodeStatusMutator
,org.refcodes.mixin.EscapeCodesStatusAccessor.EscapeCodeStatusProperty
,org.refcodes.mixin.PrintStreamAccessor
,org.refcodes.mixin.PrintStreamAccessor.PrintStreamBuilder<TableBuilder>
,org.refcodes.mixin.PrintStreamAccessor.PrintStreamMutator
,org.refcodes.mixin.PrintStreamAccessor.PrintStreamProperty
,org.refcodes.mixin.ResetEscapeCodeAccessor
,org.refcodes.mixin.ResetEscapeCodeAccessor.ResetEscapeCodeBuilder<TableBuilder>
,org.refcodes.mixin.ResetEscapeCodeAccessor.ResetEscapeCodeMutator
,org.refcodes.mixin.ResetEscapeCodeAccessor.ResetEscapeCodeProperty
,org.refcodes.mixin.RowWidthAccessor
,org.refcodes.mixin.RowWidthAccessor.RowWidthBuilder<TableBuilder>
,org.refcodes.mixin.RowWidthAccessor.RowWidthMutator
,org.refcodes.mixin.RowWidthAccessor.RowWidthProperty
,TableBuilder
,TablePrinter
public class TableBuilderImpl extends Object implements TableBuilder
An implementation of theTableBuilder
interface.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.refcodes.mixin.EscapeCodesStatusAccessor
org.refcodes.mixin.EscapeCodesStatusAccessor.EscapeCodeStatusBuilder<B extends org.refcodes.mixin.EscapeCodesStatusAccessor.EscapeCodeStatusBuilder<B>>, org.refcodes.mixin.EscapeCodesStatusAccessor.EscapeCodeStatusMutator, org.refcodes.mixin.EscapeCodesStatusAccessor.EscapeCodeStatusProperty
-
Nested classes/interfaces inherited from interface org.refcodes.mixin.PrintStreamAccessor
org.refcodes.mixin.PrintStreamAccessor.PrintStreamBuilder<B extends org.refcodes.mixin.PrintStreamAccessor.PrintStreamBuilder<?>>, org.refcodes.mixin.PrintStreamAccessor.PrintStreamMutator, org.refcodes.mixin.PrintStreamAccessor.PrintStreamProperty
-
Nested classes/interfaces inherited from interface org.refcodes.mixin.ResetEscapeCodeAccessor
org.refcodes.mixin.ResetEscapeCodeAccessor.ResetEscapeCodeBuilder<B extends org.refcodes.mixin.ResetEscapeCodeAccessor.ResetEscapeCodeBuilder<B>>, org.refcodes.mixin.ResetEscapeCodeAccessor.ResetEscapeCodeMutator, org.refcodes.mixin.ResetEscapeCodeAccessor.ResetEscapeCodeProperty
-
Nested classes/interfaces inherited from interface org.refcodes.mixin.RowWidthAccessor
org.refcodes.mixin.RowWidthAccessor.RowWidthBuilder<B extends org.refcodes.mixin.RowWidthAccessor.RowWidthBuilder<?>>, org.refcodes.mixin.RowWidthAccessor.RowWidthMutator, org.refcodes.mixin.RowWidthAccessor.RowWidthProperty
-
-
Constructor Summary
Constructors Constructor Description TableBuilderImpl()
Instantiates a new table builder impl.TableBuilderImpl(int aRowWidth)
Initializes theTableBuilder
with the given row width.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description TableBuilder
addColumn()
Adds a column and returns thisTableBuilder
instance as of the Builder-Pattern.PrintStream
getPrintStream()
String
getResetEscapeCode()
int
getRowWidth()
TableStatus
getTableStatus()
Retrieves theTablePrinter
(TableBuilder
) status.boolean
isEscapeCodesEnabled()
void
setEscapeCodesEnabled(boolean isEscCodesEnabled)
void
setPrintStream(PrintStream aPrintStream)
void
setResetEscapeCode(String aResetEscCode)
void
setRowWidth(int aRowWidth)
In case a value of -1 is provided, then the width is calculated dynamically from the individual columns' widths added together including any borders being specified.TableBuilder
setTableStatus(TableStatus aTableStatus)
Set theTablePrinter
(TableBuilder
) status.static String[][]
toColumns(String[][] aColumns, VertAlignTextMode aTextBlockMode)
Creates an array ofString
arrays where all the arrays are of the same length and where the arrays are all aligned as specified by the passedVertAlignTextMode
.int[]
toColumnWidths()
Returns the currently calculated or configured column widths.protected static int[]
toColumnWidths(int aTotalWidth, ColumnWidthMetrics... aColumnWidths)
Calculates the columns widths in "number of chars" according to the providedColumnWidthMetricsImpl
instances in relation to the provided total (available) width; the provided column widths can be a mix of "number of char" widths (ColumnWidthType.ABSOLUTE
) and percent (%) widths (ColumnWidthType.RELATIVE
).String
toHeader(String... aColumns)
Prints the table's header with the content of the provided columns.String
toHeaderBegin()
Begins a header, for convenience reasons, this is being encapsulated by theTablePrinter.toHeader(String...)
method.String
toHeaderContinue(String... aColumns)
Continues a begun header, for convenience reasons, this is being encapsulated by theTablePrinter.toHeader(String...)
method.String
toHeaderEnd()
Ends a header, for convenience reasons, this is being encapsulated by theTablePrinter.toHeader(String...)
method.String
toHeaderEnd(TableBuilder aTablePrinter)
Ends the headers of the providedTableBuilder
for this table printer to continue; different header widths and column widths are taken care of, so it is a pleasure to mix differentTableBuilder
s, especially when empty columns may result in better using another column layout making better use of the available width.String
toRow(String... aColumns)
Prints the table's (next) row with the content of the provided columns.String
toRowBegin()
Begins a row, for convenience reasons, this is being encapsulated by theTablePrinter.toRow(String...)
method.String
toRowContinue(String... aColumns)
Continues a begun row, for convenience reasons, this is being encapsulated by theTablePrinter.toRow(String...)
method.String
toRowEnd(TableBuilder aTablePrinter)
Ends the rows of the providedTableBuilder
for this table printer to continue; different row widths and column widths are taken care of, so it is a pleasure to mix differentTableBuilder
s, especially when empty columns may result in better using another column layout making better use of the available width.String
toTail()
Finishes off the table by closing it.TableBuilder
withBorderEscapeCode(String aAnsiEscCode)
Sets an overall ANSI Escape-Code for the borders and returns thisTableBuilder
instance as of the Builder-Pattern.TableBuilder
withColumnFormatMetrics(ColumnFormatMetrics aColumnFormatMetrics)
Sets the current column's (the last added one with theTableBuilder.addColumn()
method) format (including the width) and returns thisTableBuilder
instance as of the Builder-Pattern.TableBuilder
withColumnHorizAlignTextMode(HorizAlignTextMode aHorizAlignTextMode)
Sets the column's alignment mode for the header and the rows and returns thisTableBuilder
instance as of the Builder-Pattern.TableBuilder
withColumnMoreTextMode(MoreTextMode aMoreTextMode)
Sets the column's "more" mode for the header and the rows and returns thisTableBuilder
instance as of the Builder-Pattern.TableBuilder
withColumnSplitTextMode(SplitTextMode aLineSplitMode)
Sets the column's line split mode for the header and the rows and returns thisTableBuilder
instance as of the Builder-Pattern.TableBuilder
withColumnTextFormatMode(TextFormatMode aTableFormatMode)
Sets the column's format mode for the header and the rows and returns thisTableBuilder
instance as of the Builder-Pattern.TableBuilder
withColumnWidth(int aColumnWidth)
Sets the current column's (the last added one with theTableBuilder.addColumn()
method) absolute width () @link ColumnWidthType#ABSOLUTE) and returns thisTableBuilder
instance as of the Builder-Pattern.TableBuilder
withColumnWidth(int aWidth, ColumnWidthType aWidthType)
Sets the current column's (the last added one with theTableBuilder.addColumn()
method) width and returns thisTableBuilder
instance as of the Builder-Pattern.TableBuilder
withColumnWidthMetrics(ColumnWidthMetrics aColumnWidthMetrics)
Sets the current column's (the last added one with theTableBuilder.addColumn()
method) width and returns thisTableBuilder
instance as of the Builder-Pattern.TableBuilder
withDividerLine(boolean hasDividerLine)
Sets whether to print the divider line between the columns of a row and returns thisTableBuilder
instance as of the Builder-Pattern.TableBuilder
withEscapeCode(String aAnsiEscCode)
Sets an overall ANSI Escape-Code for the header, the rows as well as the borders; and returns thisTableBuilder
instance as of the builder pattern.TableBuilder
withHeaderColumnEscapeCode(String aAnsiEscCode)
Sets the column's header ANSI Escape-Code for the current header column and returns thisTableBuilder
instance as of the Builder-Pattern.TableBuilder
withHeaderColumnHorizAlignTextMode(HorizAlignTextMode aHorizAlignTextMode)
Sets the column's header alignment mode for the header and the rows and returns thisTableBuilder
instance as of the Builder-Pattern.TableBuilder
withHeaderColumnMoreTextMode(MoreTextMode aMoreTextMode)
Sets the column's header "more" mode for the header and the rows and returns thisTableBuilder
instance as of the Builder-Pattern.TableBuilder
withHeaderColumnSplitTextMode(SplitTextMode aLineSplitMode)
Sets the column's header line split mode for the header and the rows and returns thisTableBuilder
instance as of the Builder-Pattern.TableBuilder
withHeaderColumnTextFormatMode(TextFormatMode aTableFormatMode)
Sets the column's header format mode for the header and the rows and returns thisTableBuilder
instance as of the Builder-Pattern.TableBuilder
withHeaderEscapeCode(String aAnsiEscCode)
Sets an overall ANSI Escape-Code for the header and returns thisTableBuilder
instance as of the Builder-Pattern.TableBuilder
withHeaderHorizAlignTextMode(HorizAlignTextMode aHorizAlignTextMode)
Sets an overall alignment mode for the header and returns thisTableBuilder
instance as of the Builder-Pattern.TableBuilder
withHeaderMoreTextMode(MoreTextMode aMoreTextMode)
Sets an overall "more" mode for the header and returns thisTableBuilder
instance as of the Builder-Pattern.TableBuilder
withHeaderSplitTextMode(SplitTextMode aLineSplitMode)
Sets an overall line split mode for the header and returns thisTableBuilder
instance as of the Builder-Pattern.TableBuilder
withHeaderTextFormatMode(TextFormatMode aTableFormatMode)
Sets an overall format mode for the header and returns thisTableBuilder
instance as of the Builder-Pattern.TableBuilder
withHorizAlignTextMode(HorizAlignTextMode aHorizAlignTextMode)
Sets an overall alignment mode for the header and the rows and returns thisTableBuilder
instance as of the Builder-Pattern.TableBuilder
withLeftBorder(boolean hasLeftBorder)
Sets whether to print the left border and returns thisTableBuilder
instance as of the Builder-Pattern.TableBuilder
withLineBreak(String aLineBreak)
Sets the required line break and returns thisTableBuilder
instance as of the Builder-Pattern.TableBuilder
withMoreTextMode(MoreTextMode aMoreTextMode)
Sets an overall "more" mode for the header and the rows and returns thisTableBuilder
instance as of the Builder-Pattern.TableBuilder
withResetEscapeCode(String aAnsiEscCode)
Sets the ANSI reset Escape-Code for thisTableBuilder
instance as of the Builder-Pattern.TableBuilder
withRightBorder(boolean hasRightBorder)
Sets whether to print the right border and returns thisTableBuilder
instance as of the Builder-Pattern.TableBuilder
withRowColumnEscapeCode(String aAnsiEscCode)
Sets the column's header ANSI Escape-Code for the current row column and returns thisTableBuilder
instance as of the Builder-Pattern.TableBuilder
withRowColumnHorizAlignTextMode(HorizAlignTextMode aHorizAlignTextMode)
Sets the column's header alignment mode for the header and the rows and returns thisTableBuilder
instance as of the Builder-Pattern.TableBuilder
withRowColumnMoreTextMode(MoreTextMode aMoreTextMode)
Sets the column's header "more" mode for the header and the rows and returns thisTableBuilder
instance as of the Builder-Pattern.TableBuilder
withRowColumnSplitTextMode(SplitTextMode aLineSplitMode)
Sets the column's header line split mode for the header and the rows and returns thisTableBuilder
instance as of the Builder-Pattern.TableBuilder
withRowColumnTextFormatMode(TextFormatMode aTableFormatMode)
Sets the column's row format mode for the header and the rows and returns thisTableBuilder
instance as of the Builder-Pattern.TableBuilder
withRowEscapeCode(String aAnsiEscCode)
Sets an overall ANSI Escape-Code for the rows and returns thisTableBuilder
instance as of the Builder-Pattern.TableBuilder
withRowHorizAlignTextMode(HorizAlignTextMode aHorizAlignTextMode)
Sets an overall alignment mode for the rows and returns thisTableBuilder
instance as of the Builder-Pattern.TableBuilder
withRowMoreTextMode(MoreTextMode aMoreTextMode)
Sets an overall "more" mode for the rows and returns thisTableBuilder
instance as of the Builder-Pattern.TableBuilder
withRowSplitTextMode(SplitTextMode aLineSplitMode)
Sets an overall line split mode for the rows and returns thisTableBuilder
instance as of the Builder-Pattern.TableBuilder
withRowTextFormatMode(TextFormatMode aTableFormatMode)
Sets an overall format mode for the rows and returns thisTableBuilder
instance as of the Builder-Pattern.TableBuilder
withRowWidth(int aRowWidth)
In case a value of -1 is provided, then the width is calculated dynamically from the individual columns' widths added together including any borders being specified.TableBuilder
withSplitTextMode(SplitTextMode aLineSplitMode)
Sets an overall line split mode for the header and the rows and returns thisTableBuilder
instance as of the Builder-Pattern.TableBuilder
withTableStyle(TableStyle aTableStyle)
Sets theTableStyle
to use when printing and returns thisTableBuilder
instance as of the Builder-Pattern.TableBuilder
withTextColumnEscapeCode(String aAnsiEscCode)
Sets the column's ANSI Escape-Code for the current (header and row) column and returns thisTableBuilder
instance as of the builder pattern.TableBuilder
withTextEscapeCode(String aAnsiEscCode)
Sets an overall ANSI Escape-Code for the header and the rows and returns thisTableBuilder
instance as of the Builder-Pattern.TableBuilder
withTextFormatMode(TextFormatMode aTableFormatMode)
Sets an overall format mode for the header and the rows and returns thisTableBuilder
instance as of the Builder-Pattern.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.refcodes.textual.TableBuilder
build, printHeader, printHeaderBegin, printHeaderContinue, printHeaderEnd, printHeaderEnd, printRow, printRowBegin, printRowContinue, printRowEnd, printTail, withEscapeCodesEnabled, withPrintStream
-
Methods inherited from interface org.refcodes.textual.TablePrinter
printHeader, printHeaderComplete, printHeaderContinue, printRow, printRowContinue, toHeader, toHeaderComplete, toHeaderContinue, toRow, toRowContinue
-
-
-
-
Constructor Detail
-
TableBuilderImpl
public TableBuilderImpl()
Instantiates a new table builder impl.
-
TableBuilderImpl
public TableBuilderImpl(int aRowWidth)
Initializes theTableBuilder
with the given row width.- Parameters:
aRowWidth
- The row width with which to initialize theTableBuilder
.
-
-
Method Detail
-
toColumns
public static String[][] toColumns(String[][] aColumns, VertAlignTextMode aTextBlockMode)
Creates an array ofString
arrays where all the arrays are of the same length and where the arrays are all aligned as specified by the passedVertAlignTextMode
.- Parameters:
aColumns
- An array ofString
arrays to be equalized.aTextBlockMode
- TheVertAlignTextMode
to be used when equalizing the columns.- Returns:
- The equalized columns.
-
toColumnWidths
protected static int[] toColumnWidths(int aTotalWidth, ColumnWidthMetrics... aColumnWidths)
Calculates the columns widths in "number of chars" according to the providedColumnWidthMetricsImpl
instances in relation to the provided total (available) width; the provided column widths can be a mix of "number of char" widths (ColumnWidthType.ABSOLUTE
) and percent (%) widths (ColumnWidthType.RELATIVE
). When the width is being relative, then the total sum of all of relative widths represents 100%. The resulting column widths add up to the total width. The column widths for theColumnWidthMetricsImpl
instances being specified in percent (ColumnWidthType.RELATIVE
) are calculated from the remainder width after all "number of char"ColumnWidthMetricsImpl
instances (ColumnWidthType.ABSOLUTE
) have been subtracted from the provided total width. *- Parameters:
aTotalWidth
- The total available width in number of chars.aColumnWidths
- TheColumnWidthMetricsImpl
instances providing width specifications either in percent (%) or in "number of chars".- Returns:
- An array where each element represents one of the provided
ColumnWidthMetricsImpl
instances in the order themColumnWidthMetricsImpl
instances have been passed; the array species the actual column widths in "number of chars", adding up to the total width.
-
addColumn
public TableBuilder addColumn()
Adds a column and returns thisTableBuilder
instance as of the Builder-Pattern.- Specified by:
addColumn
in interfaceTableBuilder
- Returns:
- This
TableBuilder
instance to continue configuration.
-
getPrintStream
public PrintStream getPrintStream()
- Specified by:
getPrintStream
in interfaceorg.refcodes.mixin.PrintStreamAccessor
-
getResetEscapeCode
public String getResetEscapeCode()
- Specified by:
getResetEscapeCode
in interfaceorg.refcodes.mixin.ResetEscapeCodeAccessor
-
getRowWidth
public int getRowWidth()
- Specified by:
getRowWidth
in interfaceorg.refcodes.mixin.RowWidthAccessor
-
getTableStatus
public TableStatus getTableStatus()
Retrieves theTablePrinter
(TableBuilder
) status. TheTableStatus
is required by aTablePrinter
(TableBuilder
) to determine whether to do additional table decoration for a print operation or to fail that operation as of an illegal state exception. As far as possible an illegal state exception is to be tried to be prevented by decorating the table automatically by an operation as of the currentTableStatus
.- Specified by:
getTableStatus
in interfaceTablePrinter
- Returns:
- The table's current
TableStatus
.
-
isEscapeCodesEnabled
public boolean isEscapeCodesEnabled()
- Specified by:
isEscapeCodesEnabled
in interfaceorg.refcodes.mixin.EscapeCodesStatusAccessor
-
setPrintStream
public void setPrintStream(PrintStream aPrintStream)
- Specified by:
setPrintStream
in interfaceorg.refcodes.mixin.PrintStreamAccessor.PrintStreamMutator
-
setResetEscapeCode
public void setResetEscapeCode(String aResetEscCode)
- Specified by:
setResetEscapeCode
in interfaceorg.refcodes.mixin.ResetEscapeCodeAccessor.ResetEscapeCodeMutator
-
setRowWidth
public void setRowWidth(int aRowWidth)
In case a value of -1 is provided, then the width is calculated dynamically from the individual columns' widths added together including any borders being specified.- Specified by:
setRowWidth
in interfaceorg.refcodes.mixin.RowWidthAccessor.RowWidthMutator
-
setTableStatus
public TableBuilder setTableStatus(TableStatus aTableStatus)
Set theTablePrinter
(TableBuilder
) status. TheTableStatus
is required by aTablePrinter
(TableBuilder
) to determine whether to do additional table decoration for a print operation or to fail that operation as of an illegal state exception. As far as possible an illegal state exception is to be tried to be prevented by decorating the table automatically by an operation as of the currentTableStatus
. Setting the status manually, you can use differently configuredTablePrinter
interfaces to print their lines according to the status of a previousTablePrinter
.- Specified by:
setTableStatus
in interfaceTablePrinter
- Parameters:
aTableStatus
- The table's currentTableStatus
to be set.- Returns:
- the table printer
-
toColumnWidths
public int[] toColumnWidths()
Returns the currently calculated or configured column widths. Changing the row width or adding a column will affect the result being returned.- Specified by:
toColumnWidths
in interfaceTableBuilder
- Returns:
- The widths of the rows as currently calculated.
-
toHeader
public String toHeader(String... aColumns)
Prints the table's header with the content of the provided columns.- Specified by:
toHeader
in interfaceTablePrinter
- Parameters:
aColumns
- The columns to be used in the table's header.- Returns:
- The header
String
including line breaks as it most probably will consist of more than one line.
-
toHeaderBegin
public String toHeaderBegin()
Begins a header, for convenience reasons, this is being encapsulated by theTablePrinter.toHeader(String...)
method. Use this method in case you need more control on the header construction thanTablePrinter.toHeader(String...)
can provide you.- Specified by:
toHeaderBegin
in interfaceTablePrinter
- Returns:
- The header's begin
String
including the line breaks.
-
toHeaderContinue
public String toHeaderContinue(String... aColumns)
Continues a begun header, for convenience reasons, this is being encapsulated by theTablePrinter.toHeader(String...)
method. Use this method in case you need more control on the header construction thanTablePrinter.toHeader(String...)
can provide you.- Specified by:
toHeaderContinue
in interfaceTablePrinter
- Parameters:
aColumns
- the columns- Returns:
- The begun header continued
String
including the line breaks.
-
toHeaderEnd
public String toHeaderEnd()
Ends a header, for convenience reasons, this is being encapsulated by theTablePrinter.toHeader(String...)
method. Use this method in case you need more control on the header construction thanTablePrinter.toHeader(String...)
can provide you.- Specified by:
toHeaderEnd
in interfaceTablePrinter
- Returns:
- The header's end
String
including the line breaks.
-
toHeaderEnd
public String toHeaderEnd(TableBuilder aTablePrinter)
Ends the headers of the providedTableBuilder
for this table printer to continue; different header widths and column widths are taken care of, so it is a pleasure to mix differentTableBuilder
s, especially when empty columns may result in better using another column layout making better use of the available width.- Specified by:
toHeaderEnd
in interfaceTablePrinter
- Parameters:
aTablePrinter
- TheTableBuilder
to which to append thisTableBuilder
's headers.- Returns:
- The divider header joining the provided (top)
TableBuilder
's layout with this (bottom)TableBuilder
's layout.
-
toRow
public String toRow(String... aColumns)
Prints the table's (next) row with the content of the provided columns. Call this method for each row to print out.- Specified by:
toRow
in interfaceTablePrinter
- Parameters:
aColumns
- The columns to be used in the (next) table's row.- Returns:
- The row
String
including line breaks as it most probably will consist of more than one line.
-
toRowBegin
public String toRowBegin()
Begins a row, for convenience reasons, this is being encapsulated by theTablePrinter.toRow(String...)
method. Use this method in case you need more control on the row construction thanTablePrinter.toRow(String...)
can provide you.- Specified by:
toRowBegin
in interfaceTablePrinter
- Returns:
- The row's begin
String
including the line breaks.
-
toRowContinue
public String toRowContinue(String... aColumns)
Continues a begun row, for convenience reasons, this is being encapsulated by theTablePrinter.toRow(String...)
method. Use this method in case you need more control on the header construction thanTablePrinter.toRow(String...)
can provide you.- Specified by:
toRowContinue
in interfaceTablePrinter
- Parameters:
aColumns
- the columns- Returns:
- The begun row continued
String
including the line breaks.
-
toRowEnd
public String toRowEnd(TableBuilder aTablePrinter)
Ends the rows of the providedTableBuilder
for this table printer to continue; different row widths and column widths are taken care of, so it is a pleasure to mix differentTableBuilder
s, especially when empty columns may result in better using another column layout making better use of the available width.- Specified by:
toRowEnd
in interfaceTablePrinter
- Parameters:
aTablePrinter
- TheTableBuilder
to which to append thisTableBuilder
's rows.- Returns:
- The divider row joining the provided (top)
TableBuilder
's layout with this (bottom)TableBuilder
's layout.
-
toTail
public String toTail()
Finishes off the table by closing it.- Specified by:
toTail
in interfaceTablePrinter
- Returns:
- The tail of the table for finishing the table off.
-
withBorderEscapeCode
public TableBuilder withBorderEscapeCode(String aAnsiEscCode)
Sets an overall ANSI Escape-Code for the borders and returns thisTableBuilder
instance as of the Builder-Pattern. In case an ANSI Escape-Codes is set, then the ANSI Escape-Code is prepended and an ANSI Reset-Code is appended to the according text being printed. The latest ANSI Escape-Code set wins.- Specified by:
withBorderEscapeCode
in interfaceTableBuilder
- Parameters:
aAnsiEscCode
- TheString
to be used for ANSI escaping.- Returns:
- This
TableBuilder
instance to continue configuration.
-
withColumnFormatMetrics
public TableBuilder withColumnFormatMetrics(ColumnFormatMetrics aColumnFormatMetrics) throws IllegalStateException
Sets the current column's (the last added one with theTableBuilder.addColumn()
method) format (including the width) and returns thisTableBuilder
instance as of the Builder-Pattern.- Specified by:
withColumnFormatMetrics
in interfaceTableBuilder
- Parameters:
aColumnFormatMetrics
- The width and theColumnWidthType
(ColumnWidthType.RELATIVE
orColumnWidthType.ABSOLUTE
) of the column as well as the format.- Returns:
- This
TableBuilder
instance to continue configuration. - Throws:
IllegalStateException
- in case there is none column already added.
-
withColumnHorizAlignTextMode
public TableBuilder withColumnHorizAlignTextMode(HorizAlignTextMode aHorizAlignTextMode)
Sets the column's alignment mode for the header and the rows and returns thisTableBuilder
instance as of the Builder-Pattern. The latest alignment mode being set wins.- Specified by:
withColumnHorizAlignTextMode
in interfaceTableBuilder
- Parameters:
aHorizAlignTextMode
- TheHorizAlignTextMode
to be used for aligning the text.- Returns:
- This
TableBuilder
instance to continue configuration.
-
withColumnMoreTextMode
public TableBuilder withColumnMoreTextMode(MoreTextMode aMoreTextMode)
Sets the column's "more" mode for the header and the rows and returns thisTableBuilder
instance as of the Builder-Pattern. The latest "more" mode being set wins.- Specified by:
withColumnMoreTextMode
in interfaceTableBuilder
- Parameters:
aMoreTextMode
- TheMoreTextMode
to be used for aligning the text.- Returns:
- This
TableBuilder
instance to continue configuration.
-
withColumnSplitTextMode
public TableBuilder withColumnSplitTextMode(SplitTextMode aLineSplitMode)
Sets the column's line split mode for the header and the rows and returns thisTableBuilder
instance as of the Builder-Pattern. The latest line split mode being set wins.- Specified by:
withColumnSplitTextMode
in interfaceTableBuilder
- Parameters:
aLineSplitMode
- TheSplitTextMode
to be used for aligning the text.- Returns:
- This
TableBuilder
instance to continue configuration.
-
withColumnTextFormatMode
public TableBuilder withColumnTextFormatMode(TextFormatMode aTableFormatMode)
Sets the column's format mode for the header and the rows and returns thisTableBuilder
instance as of the Builder-Pattern. The latest format mode being set wins.- Specified by:
withColumnTextFormatMode
in interfaceTableBuilder
- Parameters:
aTableFormatMode
- TheTextFormatMode
to be used for formating the text.- Returns:
- This
TableBuilder
instance to continue configuration.
-
withColumnWidth
public TableBuilder withColumnWidth(int aColumnWidth) throws IllegalStateException
Sets the current column's (the last added one with theTableBuilder.addColumn()
method) absolute width () @link ColumnWidthType#ABSOLUTE) and returns thisTableBuilder
instance as of the Builder-Pattern. Same as calling "withColumnWidth(int, ColumnWidthType.ABSOLUTE)}"- Specified by:
withColumnWidth
in interfaceTableBuilder
- Parameters:
aColumnWidth
- The width for the column.- Returns:
- This
TableBuilder
instance to continue configuration. - Throws:
IllegalStateException
- in case there is none column already added.
-
withColumnWidth
public TableBuilder withColumnWidth(int aWidth, ColumnWidthType aWidthType) throws IllegalStateException
Sets the current column's (the last added one with theTableBuilder.addColumn()
method) width and returns thisTableBuilder
instance as of the Builder-Pattern.- Specified by:
withColumnWidth
in interfaceTableBuilder
- Parameters:
aWidth
- The width for the column.aWidthType
- The type the width is of, e.g.ColumnWidthType.RELATIVE
orColumnWidthType.ABSOLUTE
- Returns:
- This
TableBuilder
instance to continue configuration. - Throws:
IllegalStateException
- in case there is none column already added.
-
withColumnWidthMetrics
public TableBuilder withColumnWidthMetrics(ColumnWidthMetrics aColumnWidthMetrics) throws IllegalStateException
Sets the current column's (the last added one with theTableBuilder.addColumn()
method) width and returns thisTableBuilder
instance as of the Builder-Pattern.- Specified by:
withColumnWidthMetrics
in interfaceTableBuilder
- Parameters:
aColumnWidthMetrics
- The width and theColumnWidthType
(ColumnWidthType.RELATIVE
orColumnWidthType.ABSOLUTE
) of the column.- Returns:
- This
TableBuilder
instance to continue configuration. - Throws:
IllegalStateException
- in case there is none column already added.
-
withEscapeCode
public TableBuilder withEscapeCode(String aAnsiEscCode)
Sets an overall ANSI Escape-Code for the header, the rows as well as the borders; and returns thisTableBuilder
instance as of the builder pattern. In case an ANSI Escape-Codes is set, then an ANSI Reset-Code is prepended to the according text being printed. The latest ANSI escape code set wins.- Specified by:
withEscapeCode
in interfaceTableBuilder
- Parameters:
aAnsiEscCode
- TheString
to be used for ANSI escaping.- Returns:
- This
TableBuilder
instance to continue configuration.
-
setEscapeCodesEnabled
public void setEscapeCodesEnabled(boolean isEscCodesEnabled)
- Specified by:
setEscapeCodesEnabled
in interfaceorg.refcodes.mixin.EscapeCodesStatusAccessor.EscapeCodeStatusMutator
-
withHeaderColumnEscapeCode
public TableBuilder withHeaderColumnEscapeCode(String aAnsiEscCode)
Sets the column's header ANSI Escape-Code for the current header column and returns thisTableBuilder
instance as of the Builder-Pattern. The latest ANSI Escape-Code being set wins.- Specified by:
withHeaderColumnEscapeCode
in interfaceTableBuilder
- Parameters:
aAnsiEscCode
- TheString
to be used for ANSI escaping.- Returns:
- This
TableBuilder
instance to continue configuration.
-
withHeaderColumnHorizAlignTextMode
public TableBuilder withHeaderColumnHorizAlignTextMode(HorizAlignTextMode aHorizAlignTextMode)
Sets the column's header alignment mode for the header and the rows and returns thisTableBuilder
instance as of the Builder-Pattern. The latest alignment mode being set wins.- Specified by:
withHeaderColumnHorizAlignTextMode
in interfaceTableBuilder
- Parameters:
aHorizAlignTextMode
- TheHorizAlignTextMode
to be used for aligning the text.- Returns:
- This
TableBuilder
instance to continue configuration.
-
withHeaderColumnMoreTextMode
public TableBuilder withHeaderColumnMoreTextMode(MoreTextMode aMoreTextMode)
Sets the column's header "more" mode for the header and the rows and returns thisTableBuilder
instance as of the Builder-Pattern. The latest "more" mode being set wins.- Specified by:
withHeaderColumnMoreTextMode
in interfaceTableBuilder
- Parameters:
aMoreTextMode
- TheMoreTextMode
to be used for aligning the text.- Returns:
- This
TableBuilder
instance to continue configuration.
-
withHeaderColumnSplitTextMode
public TableBuilder withHeaderColumnSplitTextMode(SplitTextMode aLineSplitMode)
Sets the column's header line split mode for the header and the rows and returns thisTableBuilder
instance as of the Builder-Pattern. The latest line split mode being set wins.- Specified by:
withHeaderColumnSplitTextMode
in interfaceTableBuilder
- Parameters:
aLineSplitMode
- TheSplitTextMode
to be used for aligning the text.- Returns:
- This
TableBuilder
instance to continue configuration.
-
withHeaderColumnTextFormatMode
public TableBuilder withHeaderColumnTextFormatMode(TextFormatMode aTableFormatMode)
Sets the column's header format mode for the header and the rows and returns thisTableBuilder
instance as of the Builder-Pattern. The latest format mode being set wins.- Specified by:
withHeaderColumnTextFormatMode
in interfaceTableBuilder
- Parameters:
aTableFormatMode
- TheTextFormatMode
to be used for formating the text.- Returns:
- This
TableBuilder
instance to continue configuration.
-
withHeaderEscapeCode
public TableBuilder withHeaderEscapeCode(String aAnsiEscCode)
Sets an overall ANSI Escape-Code for the header and returns thisTableBuilder
instance as of the Builder-Pattern. The latest ANSI Escape-Code being set wins.- Specified by:
withHeaderEscapeCode
in interfaceTableBuilder
- Parameters:
aAnsiEscCode
- TheString
to be used for ANSI escaping.- Returns:
- This
TableBuilder
instance to continue configuration.
-
withHeaderHorizAlignTextMode
public TableBuilder withHeaderHorizAlignTextMode(HorizAlignTextMode aHorizAlignTextMode)
Sets an overall alignment mode for the header and returns thisTableBuilder
instance as of the Builder-Pattern. The latest alignment mode being set wins.- Specified by:
withHeaderHorizAlignTextMode
in interfaceTableBuilder
- Parameters:
aHorizAlignTextMode
- TheHorizAlignTextMode
to be used for aligning the text.- Returns:
- This
TableBuilder
instance to continue configuration.
-
withHeaderMoreTextMode
public TableBuilder withHeaderMoreTextMode(MoreTextMode aMoreTextMode)
Sets an overall "more" mode for the header and returns thisTableBuilder
instance as of the Builder-Pattern. The latest "more" mode being set wins.- Specified by:
withHeaderMoreTextMode
in interfaceTableBuilder
- Parameters:
aMoreTextMode
- TheMoreTextMode
to be used for aligning the text.- Returns:
- This
TableBuilder
instance to continue configuration.
-
withHeaderSplitTextMode
public TableBuilder withHeaderSplitTextMode(SplitTextMode aLineSplitMode)
Sets an overall line split mode for the header and returns thisTableBuilder
instance as of the Builder-Pattern. The latest line split mode being set wins.- Specified by:
withHeaderSplitTextMode
in interfaceTableBuilder
- Parameters:
aLineSplitMode
- TheSplitTextMode
to be used for aligning the text.- Returns:
- This
TableBuilder
instance to continue configuration.
-
withHeaderTextFormatMode
public TableBuilder withHeaderTextFormatMode(TextFormatMode aTableFormatMode)
Sets an overall format mode for the header and returns thisTableBuilder
instance as of the Builder-Pattern. The latest format mode being set wins.- Specified by:
withHeaderTextFormatMode
in interfaceTableBuilder
- Parameters:
aTableFormatMode
- TheTextFormatMode
to be used for formating the text.- Returns:
- This
TableBuilder
instance to continue configuration.
-
withHorizAlignTextMode
public TableBuilder withHorizAlignTextMode(HorizAlignTextMode aHorizAlignTextMode)
Sets an overall alignment mode for the header and the rows and returns thisTableBuilder
instance as of the Builder-Pattern. The latest alignment mode being set wins.- Specified by:
withHorizAlignTextMode
in interfaceTableBuilder
- Parameters:
aHorizAlignTextMode
- TheHorizAlignTextMode
to be used for aligning the text.- Returns:
- This
TableBuilder
instance to continue configuration.
-
withLeftBorder
public TableBuilder withLeftBorder(boolean hasLeftBorder)
Sets whether to print the left border and returns thisTableBuilder
instance as of the Builder-Pattern.- Specified by:
withLeftBorder
in interfaceTableBuilder
- Parameters:
hasLeftBorder
- True in case a left border is to be printed, elser false- Returns:
- This
TableBuilder
instance to continue configuration.
-
withLineBreak
public TableBuilder withLineBreak(String aLineBreak)
Sets the required line break and returns thisTableBuilder
instance as of the Builder-Pattern.- Specified by:
withLineBreak
in interfaceTableBuilder
- Parameters:
aLineBreak
- The line break character to use, by default the platform specific one is used.- Returns:
- This
TableBuilder
instance to continue configuration.
-
withMoreTextMode
public TableBuilder withMoreTextMode(MoreTextMode aMoreTextMode)
Sets an overall "more" mode for the header and the rows and returns thisTableBuilder
instance as of the Builder-Pattern. The latest "more" mode being set wins.- Specified by:
withMoreTextMode
in interfaceTableBuilder
- Parameters:
aMoreTextMode
- TheMoreTextMode
to be used for aligning the text.- Returns:
- This
TableBuilder
instance to continue configuration.
-
withResetEscapeCode
public TableBuilder withResetEscapeCode(String aAnsiEscCode)
Sets the ANSI reset Escape-Code for thisTableBuilder
instance as of the Builder-Pattern. In case an ANSI Escape-Codes is set, then this ANSI Reset-Code is prepended to the according text being printed.- Specified by:
withResetEscapeCode
in interfaceorg.refcodes.mixin.ResetEscapeCodeAccessor.ResetEscapeCodeBuilder<TableBuilder>
- Specified by:
withResetEscapeCode
in interfaceTableBuilder
- Parameters:
aAnsiEscCode
- TheString
to be used for resetting ANSI escaping.- Returns:
- This
TableBuilder
instance to continue configuration.
-
withRightBorder
public TableBuilder withRightBorder(boolean hasRightBorder)
Sets whether to print the right border and returns thisTableBuilder
instance as of the Builder-Pattern.- Specified by:
withRightBorder
in interfaceTableBuilder
- Parameters:
hasRightBorder
- True in case a right border is to be printed, elser false- Returns:
- This
TableBuilder
instance to continue configuration.
-
withDividerLine
public TableBuilder withDividerLine(boolean hasDividerLine)
Sets whether to print the divider line between the columns of a row and returns thisTableBuilder
instance as of the Builder-Pattern.- Specified by:
withDividerLine
in interfaceTableBuilder
- Parameters:
hasDividerLine
- True in case the divider lines are to be printed, elser false- Returns:
- This
TableBuilder
instance to continue configuration.
-
withRowColumnEscapeCode
public TableBuilder withRowColumnEscapeCode(String aAnsiEscCode)
Sets the column's header ANSI Escape-Code for the current row column and returns thisTableBuilder
instance as of the Builder-Pattern. The latest ANSI Escape-Code being set wins.- Specified by:
withRowColumnEscapeCode
in interfaceTableBuilder
- Parameters:
aAnsiEscCode
- TheString
to be used for ANSI escaping.- Returns:
- This
TableBuilder
instance to continue configuration.
-
withRowColumnHorizAlignTextMode
public TableBuilder withRowColumnHorizAlignTextMode(HorizAlignTextMode aHorizAlignTextMode)
Sets the column's header alignment mode for the header and the rows and returns thisTableBuilder
instance as of the Builder-Pattern. The latest alignment mode being set wins.- Specified by:
withRowColumnHorizAlignTextMode
in interfaceTableBuilder
- Parameters:
aHorizAlignTextMode
- TheHorizAlignTextMode
to be used for aligning the text.- Returns:
- This
TableBuilder
instance to continue configuration.
-
withRowColumnMoreTextMode
public TableBuilder withRowColumnMoreTextMode(MoreTextMode aMoreTextMode)
Sets the column's header "more" mode for the header and the rows and returns thisTableBuilder
instance as of the Builder-Pattern. The latest "more" mode being set wins.- Specified by:
withRowColumnMoreTextMode
in interfaceTableBuilder
- Parameters:
aMoreTextMode
- TheMoreTextMode
to be used for aligning the text.- Returns:
- This
TableBuilder
instance to continue configuration.
-
withRowColumnSplitTextMode
public TableBuilder withRowColumnSplitTextMode(SplitTextMode aLineSplitMode)
Sets the column's header line split mode for the header and the rows and returns thisTableBuilder
instance as of the Builder-Pattern. The latest line split mode being set wins.- Specified by:
withRowColumnSplitTextMode
in interfaceTableBuilder
- Parameters:
aLineSplitMode
- TheSplitTextMode
to be used for aligning the text.- Returns:
- This
TableBuilder
instance to continue configuration.
-
withRowColumnTextFormatMode
public TableBuilder withRowColumnTextFormatMode(TextFormatMode aTableFormatMode)
Sets the column's row format mode for the header and the rows and returns thisTableBuilder
instance as of the Builder-Pattern. The latest format mode being set wins.- Specified by:
withRowColumnTextFormatMode
in interfaceTableBuilder
- Parameters:
aTableFormatMode
- TheTextFormatMode
to be used for formating the text.- Returns:
- This
TableBuilder
instance to continue configuration.
-
withRowEscapeCode
public TableBuilder withRowEscapeCode(String aAnsiEscCode)
Sets an overall ANSI Escape-Code for the rows and returns thisTableBuilder
instance as of the Builder-Pattern. The latest ANSI Escape-Code being set wins.- Specified by:
withRowEscapeCode
in interfaceTableBuilder
- Parameters:
aAnsiEscCode
- TheString
to be used for ANSI escaping.- Returns:
- This
TableBuilder
instance to continue configuration.
-
withRowHorizAlignTextMode
public TableBuilder withRowHorizAlignTextMode(HorizAlignTextMode aHorizAlignTextMode)
Sets an overall alignment mode for the rows and returns thisTableBuilder
instance as of the Builder-Pattern. The latest alignment mode being set wins.- Specified by:
withRowHorizAlignTextMode
in interfaceTableBuilder
- Parameters:
aHorizAlignTextMode
- TheHorizAlignTextMode
to be used for aligning the text.- Returns:
- This
TableBuilder
instance to continue configuration.
-
withRowMoreTextMode
public TableBuilder withRowMoreTextMode(MoreTextMode aMoreTextMode)
Sets an overall "more" mode for the rows and returns thisTableBuilder
instance as of the Builder-Pattern. The latest "more" mode being set wins.- Specified by:
withRowMoreTextMode
in interfaceTableBuilder
- Parameters:
aMoreTextMode
- TheMoreTextMode
to be used for aligning the text.- Returns:
- This
TableBuilder
instance to continue configuration.
-
withRowSplitTextMode
public TableBuilder withRowSplitTextMode(SplitTextMode aLineSplitMode)
Sets an overall line split mode for the rows and returns thisTableBuilder
instance as of the Builder-Pattern. The latest line split mode being set wins.- Specified by:
withRowSplitTextMode
in interfaceTableBuilder
- Parameters:
aLineSplitMode
- TheSplitTextMode
to be used for aligning the text.- Returns:
- This
TableBuilder
instance to continue configuration.
-
withRowTextFormatMode
public TableBuilder withRowTextFormatMode(TextFormatMode aTableFormatMode)
Sets an overall format mode for the rows and returns thisTableBuilder
instance as of the Builder-Pattern. The latest format mode being set wins.- Specified by:
withRowTextFormatMode
in interfaceTableBuilder
- Parameters:
aTableFormatMode
- TheTextFormatMode
to be used for formating the text.- Returns:
- This
TableBuilder
instance to continue configuration.
-
withRowWidth
public TableBuilder withRowWidth(int aRowWidth)
In case a value of -1 is provided, then the width is calculated dynamically from the individual columns' widths added together including any borders being specified.- Specified by:
withRowWidth
in interfaceorg.refcodes.mixin.RowWidthAccessor.RowWidthBuilder<TableBuilder>
-
withSplitTextMode
public TableBuilder withSplitTextMode(SplitTextMode aLineSplitMode)
Sets an overall line split mode for the header and the rows and returns thisTableBuilder
instance as of the Builder-Pattern. The latest line split mode being set wins.- Specified by:
withSplitTextMode
in interfaceTableBuilder
- Parameters:
aLineSplitMode
- TheSplitTextMode
to be used for aligning the text.- Returns:
- This
TableBuilder
instance to continue configuration.
-
withTableStyle
public TableBuilder withTableStyle(TableStyle aTableStyle)
Sets theTableStyle
to use when printing and returns thisTableBuilder
instance as of the Builder-Pattern.- Specified by:
withTableStyle
in interfaceTableBuilder
- Parameters:
aTableStyle
- TheTableStyle
defining the tables style to be used when printing the table borders.- Returns:
- This
TableBuilder
instance to continue configuration.
-
withTextColumnEscapeCode
public TableBuilder withTextColumnEscapeCode(String aAnsiEscCode)
Sets the column's ANSI Escape-Code for the current (header and row) column and returns thisTableBuilder
instance as of the builder pattern. The latest ANSI Escape-Code being set wins.- Specified by:
withTextColumnEscapeCode
in interfaceTableBuilder
- Parameters:
aAnsiEscCode
- TheString
to be used for ANSI escaping.- Returns:
- This
TableBuilder
instance to continue configuration.
-
withTextEscapeCode
public TableBuilder withTextEscapeCode(String aAnsiEscCode)
Sets an overall ANSI Escape-Code for the header and the rows and returns thisTableBuilder
instance as of the Builder-Pattern. In case an ANSI Escape-Codes is set, then the ANSI Escape-Code is prepended and an ANSI Reset-Code is appended to the according text being printed. The latest ANSI Escape-Code set wins.- Specified by:
withTextEscapeCode
in interfaceTableBuilder
- Parameters:
aAnsiEscCode
- TheString
to be used for ANSI escaping.- Returns:
- This
TableBuilder
instance to continue configuration.
-
withTextFormatMode
public TableBuilder withTextFormatMode(TextFormatMode aTableFormatMode)
Sets an overall format mode for the header and the rows and returns thisTableBuilder
instance as of the Builder-Pattern. The latest format mode being set wins.- Specified by:
withTextFormatMode
in interfaceTableBuilder
- Parameters:
aTableFormatMode
- TheTextFormatMode
to be used for formating the text.- Returns:
- This
TableBuilder
instance to continue configuration.
-
-