fc.io
Class TablePrinter.PrintConfig

java.lang.Object
  extended by fc.io.TablePrinter.PrintConfig
Enclosing class:
TablePrinter

public static class TablePrinter.PrintConfig
extends Object

Configuration object containing for table printing object. Some methods in this class return this object for method chaining convenience.

Note: Alas ! TablePrinter does not support cellspans across columns or rows. That would make things too complicated for this implementation.


Constructor Summary
TablePrinter.PrintConfig()
          Constructs a new PrintConfig with the following default options.
 
Method Summary
 String[] getHeader()
          Gets the header row for the table if set.
 TablePrinter.PrintConfig headerEveryPage(boolean show)
          Specifies that page heading (if set) on each separate page.
 TablePrinter.PrintConfig setAlign(HAlign align)
          Sets the alignment of each cell.
 TablePrinter.PrintConfig setAutoFit(boolean autofit)
          Sets each cell to expand to the size needed for the maximum sized cell in that column.
 TablePrinter.PrintConfig setCellBorderHorizontal(String str)
          Sets the string (typically a single character) that makes up a horizontal cell border.
 TablePrinter.PrintConfig setCellBorderVertical(String str)
          Sets the string (typically a single character) that makes up a vertical cell border.
 TablePrinter.PrintConfig setCellCorner(String str)
          Sets the string (typically a single character) that makes up a cell corner.
 TablePrinter.PrintConfig setCellPadding(int width)
          Specifies the cell padding for each cell.
 TablePrinter.PrintConfig setCellPaddingGlyph(String str)
          Sets the string (typically a single character) that makes up the cellpadding.
 TablePrinter.PrintConfig setCellSpacing(int width)
          Specifies the cell spacing between cells.
 TablePrinter.PrintConfig setCellSpacingGlyph(String str)
          Sets the string (typically a single character) that makes up the cellspacing.
 TablePrinter.PrintConfig setCellWidth(int width)
          Sets the width of each cell.
 TablePrinter.PrintConfig setCellWidthForColumn(int column, int width)
          Sets the cell width of the the specified column.
 TablePrinter.PrintConfig setCellWrap(boolean wrap)
          Cell wrapping is on by default and the contents of any column that exceed the width are wrapped within each cell (using the current platforms line seperator for newlines within the cell).
 void setHeader(String[] header)
          Optionally sets the header row for the table
 TablePrinter.PrintConfig setPageSize(int lines)
          Sets the number of lines on each page.
 TablePrinter.PrintConfig setPrintBorders(boolean print)
          Specifies whether table and cell borders are printed.
 String toString()
          Prints a short description of this object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TablePrinter.PrintConfig

public TablePrinter.PrintConfig()
Constructs a new PrintConfig with the following default options.

Method Detail

setHeader

public void setHeader(String[] header)
Optionally sets the header row for the table


getHeader

public String[] getHeader()
Gets the header row for the table if set. If not set, return null


setPageSize

public TablePrinter.PrintConfig setPageSize(int lines)
Sets the number of lines on each page. A page is a logical unit that typically shows some number of lines on the screen without the need to scroll the page. This value is useful in conjunction with other page specific settings like showPageHeading()

Parameters:
lines - number of lines on the page, specify a zero or negative quantity for a single page. (number of lines not including lines occupied by the table header itself, if the header is printed).

headerEveryPage

public TablePrinter.PrintConfig headerEveryPage(boolean show)
Specifies that page heading (if set) on each separate page. This may be ignored if no heading has been set. true by default, although headers will still not be printed until the setPageSize method is invoked.


setAlign

public TablePrinter.PrintConfig setAlign(HAlign align)
Sets the alignment of each cell. By default: left


setCellCorner

public TablePrinter.PrintConfig setCellCorner(String str)
Sets the string (typically a single character) that makes up a cell corner. Defaults to +


setCellBorderHorizontal

public TablePrinter.PrintConfig setCellBorderHorizontal(String str)
Sets the string (typically a single character) that makes up a horizontal cell border. Defaults to -


setCellBorderVertical

public TablePrinter.PrintConfig setCellBorderVertical(String str)
Sets the string (typically a single character) that makes up a vertical cell border. Defaults to |


setCellPaddingGlyph

public TablePrinter.PrintConfig setCellPaddingGlyph(String str)
Sets the string (typically a single character) that makes up the cellpadding. Defaults to " "


setCellSpacingGlyph

public TablePrinter.PrintConfig setCellSpacingGlyph(String str)
Sets the string (typically a single character) that makes up the cellspacing. Defaults to " "


setCellWidth

public TablePrinter.PrintConfig setCellWidth(int width)
Sets the width of each cell. Defaults to 20. This width is common to all cells.

Parameters:
width - the width of each cell

setCellWidthForColumn

public TablePrinter.PrintConfig setCellWidthForColumn(int column,
                                                      int width)
Sets the cell width of the the specified column. cells are numbered starting from 0

Parameters:
column - the cell number
width - the desired character width

setCellWrap

public TablePrinter.PrintConfig setCellWrap(boolean wrap)
Cell wrapping is on by default and the contents of any column that exceed the width are wrapped within each cell (using the current platforms line seperator for newlines within the cell).

Parameters:
wrap - true To turn cell wrapping on, false to turn cell wrapping off and show fixed width contents only.

setAutoFit

public TablePrinter.PrintConfig setAutoFit(boolean autofit)
Sets each cell to expand to the size needed for the maximum sized cell in that column. By default, this is false. Setting this to true automatically turns off cell wrapping.

Note: using autofit may result in slower performance because the table almost always has to be rendered in two passes.

Parameters:
autofit - true to turn autofit on, false otherwise.

setPrintBorders

public TablePrinter.PrintConfig setPrintBorders(boolean print)
Specifies whether table and cell borders are printed. By default this is true.

Parameters:
print - true to print borders, false otherwise

setCellSpacing

public TablePrinter.PrintConfig setCellSpacing(int width)
Specifies the cell spacing between cells. This is useful for tables with no borders. By default, this value is zero.


setCellPadding

public TablePrinter.PrintConfig setCellPadding(int width)
Specifies the cell padding for each cell. This is useful for tables with no borders. By default, this value is zero.


toString

public String toString()
Prints a short description of this object.

Overrides:
toString in class Object