org.opends.server.util.table
Class TextTablePrinter

java.lang.Object
  extended by org.opends.server.util.table.TablePrinter
      extended by org.opends.server.util.table.TextTablePrinter

public final class TextTablePrinter
extends TablePrinter

An interface for creating a text based table. Tables have configurable column widths, padding, and column separators.


Constructor Summary
TextTablePrinter(java.io.OutputStream stream)
          Creates a new text table printer for the specified output stream.
TextTablePrinter(java.io.Writer writer)
          Creates a new text table printer for the specified writer.
 
Method Summary
protected  TableSerializer getSerializer()
          Creates a new table serializer based on the configuration of this table printer.
 void setColumnSeparator(java.lang.String columnSeparator)
          Sets the column separator which should be used to separate one column from the next (not including padding).
 void setColumnWidth(int column, int width)
          Set the maximum width for a column.
 void setDisplayHeadings(boolean displayHeadings)
          Specify whether the column headings should be displayed or not.
 void setHeadingSeparator(char headingSeparator)
          Sets the heading separator which should be used to separate the table heading row from the rows beneath.
 void setHeadingSeparatorStartColumn(int startColumn)
          Sets the heading separator start column.
 void setIndentWidth(int indentWidth)
          Sets the amount of characters that the table should be indented.
 void setPadding(int padding)
          Sets the padding which will be used to separate a cell's contents from its adjacent column separators.
 void setTotalWidth(int totalWidth)
          Sets the total permitted width for the table which expandable columns can use up.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextTablePrinter

public TextTablePrinter(java.io.OutputStream stream)
Creates a new text table printer for the specified output stream. The text table printer will have the following initial settings:

Parameters:
stream - The stream to output tables to.

TextTablePrinter

public TextTablePrinter(java.io.Writer writer)
Creates a new text table printer for the specified writer. The text table printer will have the following initial settings:

Parameters:
writer - The writer to output tables to.
Method Detail

setColumnSeparator

public void setColumnSeparator(java.lang.String columnSeparator)
Sets the column separator which should be used to separate one column from the next (not including padding).

Parameters:
columnSeparator - The column separator.

setColumnWidth

public void setColumnWidth(int column,
                           int width)
                    throws java.lang.IllegalArgumentException
Set the maximum width for a column. If a cell is too big to fit in its column then it will be wrapped.

Parameters:
column - The column to make fixed width (0 is the first column).
width - The width of the column (this should not include column separators or padding), or 0 to indicate that this column should be expandable.
Throws:
java.lang.IllegalArgumentException - If column is less than 0.

setDisplayHeadings

public void setDisplayHeadings(boolean displayHeadings)
Specify whether the column headings should be displayed or not.

Parameters:
displayHeadings - true if column headings should be displayed.

setHeadingSeparator

public void setHeadingSeparator(char headingSeparator)
Sets the heading separator which should be used to separate the table heading row from the rows beneath.

Parameters:
headingSeparator - The heading separator.

setHeadingSeparatorStartColumn

public void setHeadingSeparatorStartColumn(int startColumn)
Sets the heading separator start column. The heading separator will only be display in the specified column and all subsequent columns. Usually this should be left at zero (the default) but sometimes it useful to indent the heading separate in order to provide additional emphasis (for example in menus).

Parameters:
startColumn - The heading separator start column.

setIndentWidth

public void setIndentWidth(int indentWidth)
                    throws java.lang.IllegalArgumentException
Sets the amount of characters that the table should be indented. By default the table is not indented.

Parameters:
indentWidth - The number of characters the table should be indented.
Throws:
java.lang.IllegalArgumentException - If indentWidth is less than 0.

setPadding

public void setPadding(int padding)
Sets the padding which will be used to separate a cell's contents from its adjacent column separators.

Parameters:
padding - The padding.

setTotalWidth

public void setTotalWidth(int totalWidth)
Sets the total permitted width for the table which expandable columns can use up.

Parameters:
totalWidth - The total width.

getSerializer

protected TableSerializer getSerializer()
Creates a new table serializer based on the configuration of this table printer.

Specified by:
getSerializer in class TablePrinter
Returns:
Returns a new table serializer based on the configuration of this table printer.