org.opends.server.util.table
Class TableBuilder

java.lang.Object
  extended by org.opends.server.util.table.TableBuilder

public final class TableBuilder
extends java.lang.Object

A class which can be used to construct tables of information to be displayed in a terminal. Once built the table can be output using a TableSerializer.


Constructor Summary
TableBuilder()
          Creates a new table printer.
 
Method Summary
 void addSortKey(int column)
          Adds a table sort key.
 void addSortKey(int column, java.util.Comparator<java.lang.String> comparator)
          Adds a table sort key.
 void appendCell()
          Appends a new blank cell to the current row.
 void appendCell(boolean value)
          Appends a new cell to the current row containing the provided boolean value.
 void appendCell(byte value)
          Appends a new cell to the current row containing the provided byte value.
 void appendCell(char value)
          Appends a new cell to the current row containing the provided char value.
 void appendCell(double value)
          Appends a new cell to the current row containing the provided double value.
 void appendCell(float value)
          Appends a new cell to the current row containing the provided float value.
 void appendCell(int value)
          Appends a new cell to the current row containing the provided integer value.
 void appendCell(long value)
          Appends a new cell to the current row containing the provided long value.
 void appendCell(java.lang.Object value)
          Appends a new cell to the current row containing the provided object value.
 void appendHeading()
          Appends a new blank column heading to the header row.
 void appendHeading(Message value)
          Appends a new column heading to the header row.
 int getRowWidth()
          Gets the width of the current row.
 int getTableHeight()
          Gets the number of rows in table.
 int getTableWidth()
          Gets the number of columns in table.
 void print(TablePrinter printer)
          Prints the table in its current state using the provided table printer.
 void startRow()
          Appends a new row to the table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TableBuilder

public TableBuilder()
Creates a new table printer.

Method Detail

addSortKey

public void addSortKey(int column)
Adds a table sort key. The table will be sorted according to the case-insensitive string ordering of the cells in the specified column.

Parameters:
column - The column which will be used as a sort key.

addSortKey

public void addSortKey(int column,
                       java.util.Comparator<java.lang.String> comparator)
Adds a table sort key. The table will be sorted according to the provided string comparator.

Parameters:
column - The column which will be used as a sort key.
comparator - The string comparator.

appendCell

public void appendCell()
Appends a new blank cell to the current row.


appendCell

public void appendCell(boolean value)
Appends a new cell to the current row containing the provided boolean value.

Parameters:
value - The boolean value.

appendCell

public void appendCell(byte value)
Appends a new cell to the current row containing the provided byte value.

Parameters:
value - The byte value.

appendCell

public void appendCell(char value)
Appends a new cell to the current row containing the provided char value.

Parameters:
value - The char value.

appendCell

public void appendCell(double value)
Appends a new cell to the current row containing the provided double value.

Parameters:
value - The double value.

appendCell

public void appendCell(float value)
Appends a new cell to the current row containing the provided float value.

Parameters:
value - The float value.

appendCell

public void appendCell(int value)
Appends a new cell to the current row containing the provided integer value.

Parameters:
value - The boolean value.

appendCell

public void appendCell(long value)
Appends a new cell to the current row containing the provided long value.

Parameters:
value - The long value.

appendCell

public void appendCell(java.lang.Object value)
Appends a new cell to the current row containing the provided object value.

Parameters:
value - The object value.

appendHeading

public void appendHeading()
Appends a new blank column heading to the header row.


appendHeading

public void appendHeading(Message value)
Appends a new column heading to the header row.

Parameters:
value - The column heading value.

getRowWidth

public int getRowWidth()
Gets the width of the current row.

Returns:
Returns the width of the current row.

getTableHeight

public int getTableHeight()
Gets the number of rows in table.

Returns:
Returns the number of rows in table.

getTableWidth

public int getTableWidth()
Gets the number of columns in table.

Returns:
Returns the number of columns in table.

print

public void print(TablePrinter printer)
Prints the table in its current state using the provided table printer.

Parameters:
printer - The table printer.

startRow

public void startRow()
Appends a new row to the table.