Package org.refcodes.textual
Interface TablePrinter
-
- All Known Subinterfaces:
TableBuilder
- All Known Implementing Classes:
TableBuilderImpl
public interface TablePrinter
In comparison to theTableBuilder
, theTablePrinter
just provides the methods required to print a table. This is most useful when you want to create aTablePrinter
composite (which encapsulates manyTablePrinter
instances) which only requires the printing methods as the builder methods would make no sense: Think of aTablePrinter
which is used for logging text with a log priority. For each log priority there is a dedicatedTablePrinter
instance configured slightly different, e.g using different text colors for the printed row depending on the log priority. Those "internal"TablePrinter
instances would be pre-configured so that aTableBuilder
composite would actually overload the composite with Builder-Pattern functionality which must not be applied to the internalTablePrinter
instances. Actually the internalTablePrinter
instances would be part (implementation secret) of aTableBuilder
instance as them are configured each individually using the Builder-Pattern.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description TableStatus
getTableStatus()
Retrieves theTablePrinter
(TableBuilder
) status.void
printHeader(java.lang.String... aColumns)
Prints the table's header to thePrintStream
configured for thisPrintWriter
with the content of the provided columns.default void
printHeader(java.util.List<java.lang.String> aColumns)
Prints the table's header to thePrintStream
configured for thisPrintWriter
with the content of the provided columns.void
printHeaderBegin()
Prints out a header begin to thePrintStream
configured for thisPrintWriter
, for convenience reasons, this is being encapsulated by theprintHeader(String...)
method.default void
printHeaderComplete()
For more semantic clearness this method prints an end-of-header / begin-of-row line, though is equivalent to the methodprintHeaderBegin()
.void
printHeaderContinue(java.lang.String... aColumns)
Continues to print out a begun header to thePrintStream
configured for thisPrintWriter
, for convenience reasons, this is being encapsulated by theprintHeader(String...)
method.default void
printHeaderContinue(java.util.List<java.lang.String> aColumns)
Continues to print out a begun header to thePrintStream
configured for thisPrintWriter
, for convenience reasons, this is being encapsulated by theprintHeader(String...)
method.void
printHeaderEnd()
Prints out a header end to thePrintStream
configured for thisPrintWriter
, for convenience reasons, this is being encapsulated by theprintHeader(String...)
method.void
printHeaderEnd(TableBuilder aTablePrinter)
Ends the headers of the providedTableBuilder
for this table printer to continue to thePrintStream
configured for thisPrintWriter
; 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.void
printRow(java.lang.String... aColumns)
Prints the table's (next) row to thePrintStream
configured for thisPrintWriter
with the content of the provided columns.default void
printRow(java.util.List<java.lang.String> aColumns)
Prints the table's (next) row to thePrintStream
configured for thisPrintWriter
with the content of the provided columns.void
printRowBegin()
Prints out a row begin to thePrintStream
configured for thisPrintWriter
, for convenience reasons, this is being encapsulated by theprintRow(String...)
method.void
printRowContinue(java.lang.String... aColumns)
Continues a print out begun row to thePrintStream
configured for thisPrintWriter
, for convenience reasons, this is being encapsulated by theprintRow(String...)
method.default void
printRowContinue(java.util.List<java.lang.String> aColumns)
Continues a print out begun row to thePrintStream
configured for thisPrintWriter
, for convenience reasons, this is being encapsulated by theprintRow(String...)
method.void
printRowEnd(TableBuilder aTablePrinter)
Ends the rows of the providedTableBuilder
for this table printer to continue to thePrintStream
configured for thisPrintWriter
; 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.void
printTail()
Finishes off the table by printing its closing to thePrintStream
configured for thisPrintWriter
.TablePrinter
setTableStatus(TableStatus aTableStatus)
Set theTablePrinter
(TableBuilder
) status.java.lang.String
toHeader(java.lang.String... aColumns)
Prints the table's header with the content of the provided columns.default java.lang.String
toHeader(java.util.List<java.lang.String> aColumns)
Prints the table's header with the content of the provided columns.java.lang.String
toHeaderBegin()
Begins a header, for convenience reasons, this is being encapsulated by thetoHeader(String...)
method.default java.lang.String
toHeaderComplete()
For more semantic clearness this method returns an end-of-header / begin-of-row line, though is equivalent to the methodtoHeaderBegin()
.java.lang.String
toHeaderContinue(java.lang.String... aColumns)
Continues a begun header, for convenience reasons, this is being encapsulated by thetoHeader(String...)
method.default java.lang.String
toHeaderContinue(java.util.List<java.lang.String> aColumns)
Continues a begun header, for convenience reasons, this is being encapsulated by thetoHeader(String...)
method.java.lang.String
toHeaderEnd()
Ends a header, for convenience reasons, this is being encapsulated by thetoHeader(String...)
method.java.lang.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.java.lang.String
toRow(java.lang.String... aColumns)
Prints the table's (next) row with the content of the provided columns.default java.lang.String
toRow(java.util.List<java.lang.String> aColumns)
Prints the table's (next) row with the content of the provided columns.java.lang.String
toRowBegin()
Begins a row, for convenience reasons, this is being encapsulated by thetoRow(String...)
method.java.lang.String
toRowContinue(java.lang.String... aColumns)
Continues a begun row, for convenience reasons, this is being encapsulated by thetoRow(String...)
method.default java.lang.String
toRowContinue(java.util.List<java.lang.String> aColumns)
Continues a begun row, for convenience reasons, this is being encapsulated by thetoRow(String...)
method.java.lang.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.java.lang.String
toTail()
Finishes off the table by closing it.
-
-
-
Method Detail
-
toHeaderBegin
java.lang.String toHeaderBegin()
Begins a header, for convenience reasons, this is being encapsulated by thetoHeader(String...)
method. Use this method in case you need more control on the header construction thantoHeader(String...)
can provide you.- Returns:
- The header's begin
String
including the line breaks.
-
toHeaderComplete
default java.lang.String toHeaderComplete()
For more semantic clearness this method returns an end-of-header / begin-of-row line, though is equivalent to the methodtoHeaderBegin()
.- Returns:
- The header's end / row's begin
String
including the line breaks.
-
toHeaderContinue
java.lang.String toHeaderContinue(java.lang.String... aColumns)
Continues a begun header, for convenience reasons, this is being encapsulated by thetoHeader(String...)
method. Use this method in case you need more control on the header construction thantoHeader(String...)
can provide you.- Parameters:
aColumns
- the columns- Returns:
- The begun header continued
String
including the line breaks.
-
toHeaderContinue
default java.lang.String toHeaderContinue(java.util.List<java.lang.String> aColumns)
Continues a begun header, for convenience reasons, this is being encapsulated by thetoHeader(String...)
method. Use this method in case you need more control on the header construction thantoHeader(String...)
can provide you.- Parameters:
aColumns
- the columns- Returns:
- The begun header continued
String
including the line breaks.
-
toHeaderEnd
java.lang.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.- 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.
-
toHeaderEnd
java.lang.String toHeaderEnd()
Ends a header, for convenience reasons, this is being encapsulated by thetoHeader(String...)
method. Use this method in case you need more control on the header construction thantoHeader(String...)
can provide you.- Returns:
- The header's end
String
including the line breaks.
-
toRowBegin
java.lang.String toRowBegin()
Begins a row, for convenience reasons, this is being encapsulated by thetoRow(String...)
method. Use this method in case you need more control on the row construction thantoRow(String...)
can provide you.- Returns:
- The row's begin
String
including the line breaks.
-
toRowContinue
java.lang.String toRowContinue(java.lang.String... aColumns)
Continues a begun row, for convenience reasons, this is being encapsulated by thetoRow(String...)
method. Use this method in case you need more control on the header construction thantoRow(String...)
can provide you.- Parameters:
aColumns
- the columns- Returns:
- The begun row continued
String
including the line breaks.
-
toRowContinue
default java.lang.String toRowContinue(java.util.List<java.lang.String> aColumns)
Continues a begun row, for convenience reasons, this is being encapsulated by thetoRow(String...)
method. Use this method in case you need more control on the header construction thantoRow(String...)
can provide you.- Parameters:
aColumns
- the columns- Returns:
- The begun row continued
String
including the line breaks.
-
toRowEnd
java.lang.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.- 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.
-
toHeader
java.lang.String toHeader(java.lang.String... aColumns)
Prints the table's header with the content of the provided columns.- 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.
-
toHeader
default java.lang.String toHeader(java.util.List<java.lang.String> aColumns)
Prints the table's header with the content of the provided columns.- 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.
-
toRow
java.lang.String toRow(java.lang.String... aColumns)
Prints the table's (next) row with the content of the provided columns. Call this method for each row to print out.- 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.
-
toRow
default java.lang.String toRow(java.util.List<java.lang.String> aColumns)
Prints the table's (next) row with the content of the provided columns. Call this method for each row to print out.- 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.
-
toTail
java.lang.String toTail()
Finishes off the table by closing it.- Returns:
- The tail of the table for finishing the table off.
-
printHeaderBegin
void printHeaderBegin()
Prints out a header begin to thePrintStream
configured for thisPrintWriter
, for convenience reasons, this is being encapsulated by theprintHeader(String...)
method. Use this method in case you need more control on the header construction thanprintHeader(String...)
can provide you.
-
printHeaderComplete
default void printHeaderComplete()
For more semantic clearness this method prints an end-of-header / begin-of-row line, though is equivalent to the methodprintHeaderBegin()
.
-
printHeaderContinue
void printHeaderContinue(java.lang.String... aColumns)
Continues to print out a begun header to thePrintStream
configured for thisPrintWriter
, for convenience reasons, this is being encapsulated by theprintHeader(String...)
method. Use this method in case you need more control on the header construction thanprintHeader(String...)
can provide you.- Parameters:
aColumns
- the columns
-
printHeaderContinue
default void printHeaderContinue(java.util.List<java.lang.String> aColumns)
Continues to print out a begun header to thePrintStream
configured for thisPrintWriter
, for convenience reasons, this is being encapsulated by theprintHeader(String...)
method. Use this method in case you need more control on the header construction thanprintHeader(String...)
can provide you.- Parameters:
aColumns
- the columns
-
printHeaderEnd
void printHeaderEnd(TableBuilder aTablePrinter)
Ends the headers of the providedTableBuilder
for this table printer to continue to thePrintStream
configured for thisPrintWriter
; 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.- Parameters:
aTablePrinter
- TheTableBuilder
to which to append thisTableBuilder
's headers.
-
printHeaderEnd
void printHeaderEnd()
Prints out a header end to thePrintStream
configured for thisPrintWriter
, for convenience reasons, this is being encapsulated by theprintHeader(String...)
method. Use this method in case you need more control on the header construction thanprintHeader(String...)
can provide you.
-
printRowBegin
void printRowBegin()
Prints out a row begin to thePrintStream
configured for thisPrintWriter
, for convenience reasons, this is being encapsulated by theprintRow(String...)
method. Use this method in case you need more control on the row construction thanprintRow(String...)
can provide you.
-
printRowContinue
void printRowContinue(java.lang.String... aColumns)
Continues a print out begun row to thePrintStream
configured for thisPrintWriter
, for convenience reasons, this is being encapsulated by theprintRow(String...)
method. Use this method in case you need more control on the header construction thanprintRow(String...)
can provide you.- Parameters:
aColumns
- the columns
-
printRowContinue
default void printRowContinue(java.util.List<java.lang.String> aColumns)
Continues a print out begun row to thePrintStream
configured for thisPrintWriter
, for convenience reasons, this is being encapsulated by theprintRow(String...)
method. Use this method in case you need more control on the header construction thanprintRow(String...)
can provide you.- Parameters:
aColumns
- the columns
-
printRowEnd
void printRowEnd(TableBuilder aTablePrinter)
Ends the rows of the providedTableBuilder
for this table printer to continue to thePrintStream
configured for thisPrintWriter
; 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.- Parameters:
aTablePrinter
- TheTableBuilder
to which to append thisTableBuilder
's rows.
-
printHeader
void printHeader(java.lang.String... aColumns)
Prints the table's header to thePrintStream
configured for thisPrintWriter
with the content of the provided columns.- Parameters:
aColumns
- The columns to be used in the table's header.
-
printHeader
default void printHeader(java.util.List<java.lang.String> aColumns)
Prints the table's header to thePrintStream
configured for thisPrintWriter
with the content of the provided columns.- Parameters:
aColumns
- The columns to be used in the table's header.
-
printRow
void printRow(java.lang.String... aColumns)
Prints the table's (next) row to thePrintStream
configured for thisPrintWriter
with the content of the provided columns. Call this method for each row to print out.- Parameters:
aColumns
- The columns to be used in the (next) table's row.
-
printRow
default void printRow(java.util.List<java.lang.String> aColumns)
Prints the table's (next) row to thePrintStream
configured for thisPrintWriter
with the content of the provided columns. Call this method for each row to print out.- Parameters:
aColumns
- The columns to be used in the (next) table's row.
-
printTail
void printTail()
Finishes off the table by printing its closing to thePrintStream
configured for thisPrintWriter
.
-
getTableStatus
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
.- Returns:
- The table's current
TableStatus
.
-
setTableStatus
TablePrinter 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
.- Parameters:
aTableStatus
- The table's currentTableStatus
to be set.- Returns:
- the table printer
-
-