Class TableBuilder

java.lang.Object
org.refcodes.textual.TableBuilder
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, TablePrinter

public class TableBuilder extends Object implements TablePrinter, org.refcodes.mixin.RowWidthAccessor.RowWidthProperty, org.refcodes.mixin.RowWidthAccessor.RowWidthBuilder<TableBuilder>, org.refcodes.mixin.PrintStreamAccessor.PrintStreamProperty, org.refcodes.mixin.PrintStreamAccessor.PrintStreamBuilder<TableBuilder>, org.refcodes.mixin.ResetEscapeCodeAccessor.ResetEscapeCodeProperty, org.refcodes.mixin.ResetEscapeCodeAccessor.ResetEscapeCodeBuilder<TableBuilder>, org.refcodes.mixin.EscapeCodesStatusAccessor.EscapeCodeStatusProperty, org.refcodes.mixin.EscapeCodesStatusAccessor.EscapeCodeStatusBuilder<TableBuilder>
The TableBuilder has the Builder-Pattern applied to configure a text (ASCII_HEADER_ASCII_BODY) table for later printing custom tables with a title, the table rows and if required a table tail. As of the convention over configuration paradigm, reasonable default values are preconfigured in order to start right away; fine-tune your configuration with the provided builder methods.
  • Constructor Details

    • TableBuilder

      public TableBuilder()
      Instantiates a new table builder with the current terminal's width (as of Terminal.toPreferredTerminalWidth()).
    • TableBuilder

      public TableBuilder(TableBuilder.RowWidthMode aMode)
      Instantiates a new table builder using the provided TableBuilder.RowWidthMode to determine the table's row width..
    • TableBuilder

      public TableBuilder(int aRowWidth)
      Initializes the TableBuilder with the given row width.
      Parameters:
      aRowWidth - The row width with which to initialize the TableBuilder.
  • Method Details

    • addColumn

      public TableBuilder addColumn()
      Adds a column and returns this TableBuilder instance as of the Builder-Pattern.
      Returns:
      This TableBuilder instance to continue configuration.
    • addColumn

      public TableBuilder addColumn(int aWidth)
      Adds a column and returns this TableBuilder instance as of the Builder-Pattern.
      Parameters:
      aWidth - The width for the column.
      Returns:
      This TableBuilder instance to continue configuration.
    • addColumn

      public TableBuilder addColumn(int aWidth, ColumnWidthType aWidthType)
      Adds a column and returns this TableBuilder instance as of the Builder-Pattern.
      Parameters:
      aWidth - The width for the column.
      aWidthType - The type the width is of, e.g. ColumnWidthType.RELATIVE or ColumnWidthType.ABSOLUTE
      Returns:
      This TableBuilder instance to continue configuration.
    • getPrintStream

      public PrintStream getPrintStream()
      Specified by:
      getPrintStream in interface org.refcodes.mixin.PrintStreamAccessor
    • getResetEscapeCode

      public String getResetEscapeCode()
      Specified by:
      getResetEscapeCode in interface org.refcodes.mixin.ResetEscapeCodeAccessor
    • getRowWidth

      public int getRowWidth()
      Specified by:
      getRowWidth in interface org.refcodes.mixin.RowWidthAccessor
    • getTableStatus

      public TableStatus getTableStatus()
      Retrieves the TablePrinter (TableBuilder) status. The TableStatus is required by a TablePrinter ( 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 current TableStatus.
      Specified by:
      getTableStatus in interface TablePrinter
      Returns:
      The table's current TableStatus.
    • isEscapeCodesEnabled

      public boolean isEscapeCodesEnabled()
      Specified by:
      isEscapeCodesEnabled in interface org.refcodes.mixin.EscapeCodesStatusAccessor
    • setPrintStream

      public void setPrintStream(PrintStream aPrintStream)
      Specified by:
      setPrintStream in interface org.refcodes.mixin.PrintStreamAccessor.PrintStreamMutator
    • setResetEscapeCode

      public void setResetEscapeCode(String aResetEscCode)
      Specified by:
      setResetEscapeCode in interface org.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 interface org.refcodes.mixin.RowWidthAccessor.RowWidthMutator
    • setTableStatus

      public TableBuilder setTableStatus(TableStatus aTableStatus)
      Set the TablePrinter (TableBuilder) status. The TableStatus is required by a TablePrinter ( 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 current TableStatus. Setting the status manually, you can use differently configured TablePrinter interfaces to print their lines according to the status of a previous TablePrinter.
      Specified by:
      setTableStatus in interface TablePrinter
      Parameters:
      aTableStatus - The table's current TableStatus 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.
      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 interface TablePrinter
      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 the TablePrinter.toHeader(String...) method. Use this method in case you need more control on the header construction than TablePrinter.toHeader(String...) can provide you.
      Specified by:
      toHeaderBegin in interface TablePrinter
      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 the TablePrinter.toHeader(String...) method. Use this method in case you need more control on the header construction than TablePrinter.toHeader(String...) can provide you.
      Specified by:
      toHeaderContinue in interface TablePrinter
      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 the TablePrinter.toHeader(String...) method. Use this method in case you need more control on the header construction than TablePrinter.toHeader(String...) can provide you.
      Specified by:
      toHeaderEnd in interface TablePrinter
      Returns:
      The header's end String including the line breaks.
    • toHeaderEnd

      public String toHeaderEnd(TableBuilder aTablePrinter)
      Ends the headers of the provided TableBuilder for this table printer to continue; different header widths and column widths are taken care of, so it is a pleasure to mix different TableBuilders, ehttps://www.metacodes.proly when empty columns may result in better using another column layout making better use of the available width.
      Specified by:
      toHeaderEnd in interface TablePrinter
      Parameters:
      aTablePrinter - The TableBuilder to which to append this TableBuilder'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 interface TablePrinter
      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 the TablePrinter.toRow(String...) method. Use this method in case you need more control on the row construction than TablePrinter.toRow(String...) can provide you.
      Specified by:
      toRowBegin in interface TablePrinter
      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 the TablePrinter.toRow(String...) method. Use this method in case you need more control on the header construction than TablePrinter.toRow(String...) can provide you.
      Specified by:
      toRowContinue in interface TablePrinter
      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 provided TableBuilder for this table printer to continue; different row widths and column widths are taken care of, so it is a pleasure to mix different TableBuilders, ehttps://www.metacodes.proly when empty columns may result in better using another column layout making better use of the available width.
      Specified by:
      toRowEnd in interface TablePrinter
      Parameters:
      aTablePrinter - The TableBuilder to which to append this TableBuilder'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 interface TablePrinter
      Returns:
      The tail of the table for finishing the table off.
    • withBorderEscapeCode

      public TableBuilder withBorderEscapeCode(String aEscapeCode)
      Sets an overall ANSI Escape-Code for the borders and returns this TableBuilder 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.
      Parameters:
      aEscapeCode - The String 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 the addColumn() method) format (including the width) and returns this TableBuilder instance as of the Builder-Pattern.
      Parameters:
      aColumnFormatMetrics - The width and the ColumnWidthType ( ColumnWidthType.RELATIVE or ColumnWidthType.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 this TableBuilder instance as of the Builder-Pattern. The latest alignment mode being set wins.
      Parameters:
      aHorizAlignTextMode - The HorizAlignTextMode 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 this TableBuilder instance as of the Builder-Pattern. The latest "more" mode being set wins.
      Parameters:
      aMoreTextMode - The MoreTextMode to be used for aligning the text.
      Returns:
      This TableBuilder instance to continue configuration.
    • withColumnSplitTextMode

      public TableBuilder withColumnSplitTextMode(SplitTextMode aSplitTextMode)
      Sets the column's line split mode for the header and the rows and returns this TableBuilder instance as of the Builder-Pattern. The latest line split mode being set wins.
      Parameters:
      aSplitTextMode - The SplitTextMode to be used for aligning the text.
      Returns:
      This TableBuilder instance to continue configuration.
    • withColumnTextFormatMode

      public TableBuilder withColumnTextFormatMode(TextFormatMode aTextFormatMode)
      Sets the column's format mode for the header and the rows and returns this TableBuilder instance as of the Builder-Pattern. The latest format mode being set wins.
      Parameters:
      aTextFormatMode - The TextFormatMode to be used for formating the text.
      Returns:
      This TableBuilder instance to continue configuration.
    • withColumnWidth

      public TableBuilder withColumnWidth(int aWidth) throws IllegalStateException
      Sets the current column's (the last added one with the addColumn() method) absolute width () @link ColumnWidthType#ABSOLUTE) and returns this TableBuilder instance as of the Builder-Pattern. Same as calling "withColumnWidth(int, ColumnWidthType.ABSOLUTE)}"
      Parameters:
      aWidth - 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 the addColumn() method) width and returns this TableBuilder instance as of the Builder-Pattern.
      Parameters:
      aWidth - The width for the column.
      aWidthType - The type the width is of, e.g. ColumnWidthType.RELATIVE or ColumnWidthType.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 the addColumn() method) width and returns this TableBuilder instance as of the Builder-Pattern.
      Parameters:
      aColumnWidthMetrics - The width and the ColumnWidthType ( ColumnWidthType.RELATIVE or ColumnWidthType.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 aEscapeCode)
      Sets an overall ANSI Escape-Code for the header, the rows as well as the borders; and returns this TableBuilder 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.
      Parameters:
      aEscapeCode - The String to be used for ANSI escaping.
      Returns:
      This TableBuilder instance to continue configuration.
    • setEscapeCodesEnabled

      public void setEscapeCodesEnabled(boolean isEscCodesEnabled)
      Specified by:
      setEscapeCodesEnabled in interface org.refcodes.mixin.EscapeCodesStatusAccessor.EscapeCodeStatusMutator
    • withHeaderColumnEscapeCode

      public TableBuilder withHeaderColumnEscapeCode(String aEscapeCode)
      Sets the column's header ANSI Escape-Code for the current header column and returns this TableBuilder instance as of the Builder-Pattern. The latest ANSI Escape-Code being set wins.
      Parameters:
      aEscapeCode - The String 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 this TableBuilder instance as of the Builder-Pattern. The latest alignment mode being set wins.
      Parameters:
      aHorizAlignTextMode - The HorizAlignTextMode 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 this TableBuilder instance as of the Builder-Pattern. The latest "more" mode being set wins.
      Parameters:
      aMoreTextMode - The MoreTextMode to be used for aligning the text.
      Returns:
      This TableBuilder instance to continue configuration.
    • withHeaderColumnSplitTextMode

      public TableBuilder withHeaderColumnSplitTextMode(SplitTextMode aSplitTextMode)
      Sets the column's header line split mode for the header and the rows and returns this TableBuilder instance as of the Builder-Pattern. The latest line split mode being set wins.
      Parameters:
      aSplitTextMode - The SplitTextMode to be used for aligning the text.
      Returns:
      This TableBuilder instance to continue configuration.
    • withHeaderColumnTextFormatMode

      public TableBuilder withHeaderColumnTextFormatMode(TextFormatMode aTextFormatMode)
      Sets the column's header format mode for the header and the rows and returns this TableBuilder instance as of the Builder-Pattern. The latest format mode being set wins.
      Parameters:
      aTextFormatMode - The TextFormatMode to be used for formating the text.
      Returns:
      This TableBuilder instance to continue configuration.
    • withHeaderEscapeCode

      public TableBuilder withHeaderEscapeCode(String aEscapeCode)
      Sets an overall ANSI Escape-Code for the header and returns this TableBuilder instance as of the Builder-Pattern. The latest ANSI Escape-Code being set wins.
      Parameters:
      aEscapeCode - The String 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 this TableBuilder instance as of the Builder-Pattern. The latest alignment mode being set wins.
      Parameters:
      aHorizAlignTextMode - The HorizAlignTextMode 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 this TableBuilder instance as of the Builder-Pattern. The latest "more" mode being set wins.
      Parameters:
      aMoreTextMode - The MoreTextMode to be used for aligning the text.
      Returns:
      This TableBuilder instance to continue configuration.
    • withHeaderSplitTextMode

      public TableBuilder withHeaderSplitTextMode(SplitTextMode aSplitTextMode)
      Sets an overall line split mode for the header and returns this TableBuilder instance as of the Builder-Pattern. The latest line split mode being set wins.
      Parameters:
      aSplitTextMode - The SplitTextMode to be used for aligning the text.
      Returns:
      This TableBuilder instance to continue configuration.
    • withHeaderTextFormatMode

      public TableBuilder withHeaderTextFormatMode(TextFormatMode aTextFormatMode)
      Sets an overall format mode for the header and returns this TableBuilder instance as of the Builder-Pattern. The latest format mode being set wins.
      Parameters:
      aTextFormatMode - The TextFormatMode 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 this TableBuilder instance as of the Builder-Pattern. The latest alignment mode being set wins.
      Parameters:
      aHorizAlignTextMode - The HorizAlignTextMode 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 this TableBuilder instance as of the Builder-Pattern.
      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 this TableBuilder instance as of the Builder-Pattern.
      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 this TableBuilder instance as of the Builder-Pattern. The latest "more" mode being set wins.
      Parameters:
      aMoreTextMode - The MoreTextMode to be used for aligning the text.
      Returns:
      This TableBuilder instance to continue configuration.
    • withResetEscapeCode

      public TableBuilder withResetEscapeCode(String aEscapeCode)
      Sets the ANSI reset Escape-Code for this TableBuilder 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 interface org.refcodes.mixin.ResetEscapeCodeAccessor.ResetEscapeCodeBuilder<TableBuilder>
      Parameters:
      aEscapeCode - The String 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 this TableBuilder instance as of the Builder-Pattern.
      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 this TableBuilder instance as of the Builder-Pattern.
      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 aEscapeCode)
      Sets the column's header ANSI Escape-Code for the current row column and returns this TableBuilder instance as of the Builder-Pattern. The latest ANSI Escape-Code being set wins.
      Parameters:
      aEscapeCode - The String 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 this TableBuilder instance as of the Builder-Pattern. The latest alignment mode being set wins.
      Parameters:
      aHorizAlignTextMode - The HorizAlignTextMode 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 this TableBuilder instance as of the Builder-Pattern. The latest "more" mode being set wins.
      Parameters:
      aMoreTextMode - The MoreTextMode to be used for aligning the text.
      Returns:
      This TableBuilder instance to continue configuration.
    • withRowColumnSplitTextMode

      public TableBuilder withRowColumnSplitTextMode(SplitTextMode aSplitTextMode)
      Sets the column's header line split mode for the header and the rows and returns this TableBuilder instance as of the Builder-Pattern. The latest line split mode being set wins.
      Parameters:
      aSplitTextMode - The SplitTextMode to be used for aligning the text.
      Returns:
      This TableBuilder instance to continue configuration.
    • withRowColumnTextFormatMode

      public TableBuilder withRowColumnTextFormatMode(TextFormatMode aTextFormatMode)
      Sets the column's row format mode for the header and the rows and returns this TableBuilder instance as of the Builder-Pattern. The latest format mode being set wins.
      Parameters:
      aTextFormatMode - The TextFormatMode to be used for formating the text.
      Returns:
      This TableBuilder instance to continue configuration.
    • withRowEscapeCode

      public TableBuilder withRowEscapeCode(String aEscapeCode)
      Sets an overall ANSI Escape-Code for the rows and returns this TableBuilder instance as of the Builder-Pattern. The latest ANSI Escape-Code being set wins.
      Parameters:
      aEscapeCode - The String 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 this TableBuilder instance as of the Builder-Pattern. The latest alignment mode being set wins.
      Parameters:
      aHorizAlignTextMode - The HorizAlignTextMode 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 this TableBuilder instance as of the Builder-Pattern. The latest "more" mode being set wins.
      Parameters:
      aMoreTextMode - The MoreTextMode to be used for aligning the text.
      Returns:
      This TableBuilder instance to continue configuration.
    • withRowSplitTextMode

      public TableBuilder withRowSplitTextMode(SplitTextMode aSplitTextMode)
      Sets an overall line split mode for the rows and returns this TableBuilder instance as of the Builder-Pattern. The latest line split mode being set wins.
      Parameters:
      aSplitTextMode - The SplitTextMode to be used for aligning the text.
      Returns:
      This TableBuilder instance to continue configuration.
    • withRowTextFormatMode

      public TableBuilder withRowTextFormatMode(TextFormatMode aTextFormatMode)
      Sets an overall format mode for the rows and returns this TableBuilder instance as of the Builder-Pattern. The latest format mode being set wins.
      Parameters:
      aTextFormatMode - The TextFormatMode 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 interface org.refcodes.mixin.RowWidthAccessor.RowWidthBuilder<TableBuilder>
    • withSplitTextMode

      public TableBuilder withSplitTextMode(SplitTextMode aSplitTextMode)
      Sets an overall line split mode for the header and the rows and returns this TableBuilder instance as of the Builder-Pattern. The latest line split mode being set wins.
      Parameters:
      aSplitTextMode - The SplitTextMode to be used for aligning the text.
      Returns:
      This TableBuilder instance to continue configuration.
    • withTableStyle

      public TableBuilder withTableStyle(TableStyle aTableStyle)
      Sets the TableStyle to use when printing and returns this TableBuilder instance as of the Builder-Pattern.
      Parameters:
      aTableStyle - The TableStyle defining the tables style to be used when printing the table borders.
      Returns:
      This TableBuilder instance to continue configuration.
    • setTableStyle

      public void setTableStyle(TableStyle aTableStyle)
      Sets the TableStyle to use when printing.
      Parameters:
      aTableStyle - The TableStyle defining the tables style to be used when printing the table borders.
    • withTextColumnEscapeCode

      public TableBuilder withTextColumnEscapeCode(String aEscapeCode)
      Sets the column's ANSI Escape-Code for the current (header and row) column and returns this TableBuilder instance as of the builder pattern. The latest ANSI Escape-Code being set wins.
      Parameters:
      aEscapeCode - The String to be used for ANSI escaping.
      Returns:
      This TableBuilder instance to continue configuration.
    • withTextEscapeCode

      public TableBuilder withTextEscapeCode(String aEscapeCode)
      Sets an overall ANSI Escape-Code for the header and the rows and returns this TableBuilder 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.
      Parameters:
      aEscapeCode - The String to be used for ANSI escaping.
      Returns:
      This TableBuilder instance to continue configuration.
    • withTextFormatMode

      public TableBuilder withTextFormatMode(TextFormatMode aTextFormatMode)
      Sets an overall format mode for the header and the rows and returns this TableBuilder instance as of the Builder-Pattern. The latest format mode being set wins.
      Parameters:
      aTextFormatMode - The TextFormatMode to be used for formating the text.
      Returns:
      This TableBuilder instance to continue configuration.
    • printHeader

      public void printHeader(String... aColumns)
      Prints the table's header to the PrintStream configured for this PrintWriter with the content of the provided columns.
      Specified by:
      printHeader in interface TablePrinter
      Parameters:
      aColumns - The columns to be used in the table's header.
    • printHeaderBegin

      public void printHeaderBegin()
      Prints out a header begin to the PrintStream configured for this PrintWriter, for convenience reasons, this is being encapsulated by the TablePrinter.printHeader(String...) method. Use this method in case you need more control on the header construction than TablePrinter.printHeader(String...) can provide you.
      Specified by:
      printHeaderBegin in interface TablePrinter
    • printHeaderContinue

      public void printHeaderContinue(String... aColumns)
      Continues to print out a begun header to the PrintStream configured for this PrintWriter, for convenience reasons, this is being encapsulated by the TablePrinter.printHeader(String...) method. Use this method in case you need more control on the header construction than TablePrinter.printHeader(String...) can provide you.
      Specified by:
      printHeaderContinue in interface TablePrinter
      Parameters:
      aColumns - the columns
    • printHeaderEnd

      public void printHeaderEnd()
      Prints out a header end to the PrintStream configured for this PrintWriter, for convenience reasons, this is being encapsulated by the TablePrinter.printHeader(String...) method. Use this method in case you need more control on the header construction than TablePrinter.printHeader(String...) can provide you.
      Specified by:
      printHeaderEnd in interface TablePrinter
    • printHeaderEnd

      public void printHeaderEnd(TableBuilder aTablePrinter)
      Ends the headers of the provided TableBuilder for this table printer to continue to the PrintStream configured for this PrintWriter; different header widths and column widths are taken care of, so it is a pleasure to mix different TableBuilders, ehttps://www.metacodes.proly when empty columns may result in better using another column layout making better use of the available width.
      Specified by:
      printHeaderEnd in interface TablePrinter
      Parameters:
      aTablePrinter - The TableBuilder to which to append this TableBuilder's headers.
    • printRow

      public void printRow(String... aColumns)
      Prints the table's (next) row to the PrintStream configured for this PrintWriter with the content of the provided columns. Call this method for each row to print out.
      Specified by:
      printRow in interface TablePrinter
      Parameters:
      aColumns - The columns to be used in the (next) table's row.
    • printRowBegin

      public void printRowBegin()
      Prints out a row begin to the PrintStream configured for this PrintWriter, for convenience reasons, this is being encapsulated by the TablePrinter.printRow(String...) method. Use this method in case you need more control on the row construction than TablePrinter.printRow(String...) can provide you.
      Specified by:
      printRowBegin in interface TablePrinter
    • printRowContinue

      public void printRowContinue(String... aColumns)
      Continues a print out begun row to the PrintStream configured for this PrintWriter, for convenience reasons, this is being encapsulated by the TablePrinter.printRow(String...) method. Use this method in case you need more control on the header construction than TablePrinter.printRow(String...) can provide you.
      Specified by:
      printRowContinue in interface TablePrinter
      Parameters:
      aColumns - the columns
    • printRowEnd

      public void printRowEnd(TableBuilder aTablePrinter)
      Ends the rows of the provided TableBuilder for this table printer to continue to the PrintStream configured for this PrintWriter; different row widths and column widths are taken care of, so it is a pleasure to mix different TableBuilders, ehttps://www.metacodes.proly when empty columns may result in better using another column layout making better use of the available width.
      Specified by:
      printRowEnd in interface TablePrinter
      Parameters:
      aTablePrinter - The TableBuilder to which to append this TableBuilder's rows.
    • printTail

      public void printTail()
      Finishes off the table by printing its closing to the PrintStream configured for this PrintWriter.
      Specified by:
      printTail in interface TablePrinter
    • withEscapeCodesEnabled

      public TableBuilder withEscapeCodesEnabled(boolean isEscCodesEnabled)
      Sets an overall ANSI Escape-Code support for the TableBuilder, for the rows as well as the borders; and returns this TableBuilder instance as of the Builder-Pattern. In case of being set to Boolean.FALSE, then an ANSI support is disabled altogether, else it is enabled (again, if already configured). The latest setting wins.
      Specified by:
      withEscapeCodesEnabled in interface org.refcodes.mixin.EscapeCodesStatusAccessor.EscapeCodeStatusBuilder<TableBuilder>
      Parameters:
      isEscCodesEnabled - True to enable, false to disable Escape-Code support altogether.
      Returns:
      This TableBuilder instance to continue configuration.
    • withPrintStream

      public TableBuilder withPrintStream(PrintStream aPrintStream)
      Sets the print stream to be used when using the print methods of the TableBuilder and returns this TableBuilder instance as of the Builder-Pattern.
      Specified by:
      withPrintStream in interface org.refcodes.mixin.PrintStreamAccessor.PrintStreamBuilder<TableBuilder>
      Parameters:
      aPrintStream - The PrintStream to be used when printing out the table.
      Returns:
      This TableBuilder instance to continue configuration.