fc.io
Class TablePrinter

java.lang.Object
  extended by fc.io.TablePrinter

public class TablePrinter
extends Object

Prints a table formatted using plain text/ascii characters. Useful for console based output and/or formatted output to a file.


Nested Class Summary
static class TablePrinter.PrintConfig
          Configuration object containing for table printing object.
 
Constructor Summary
TablePrinter(int columnCount, PrintStream ps, TablePrinter.PrintConfig config)
          Constructs a new table printer.
TablePrinter(int columnCount, PrintWriter pw, TablePrinter.PrintConfig config)
          Constructs a new table printer.
 
Method Summary
 void endRow()
          This method should be called to finish the existing row
 void endTable()
          This method should be called to finish the table
static void main(String[] args)
           
 void printCell(String str)
          This method should be called to print a new cell in the current row.
 void startRow()
          This method should be called to start a new row
 void startTable()
          This method should be called to start the table
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TablePrinter

public TablePrinter(int columnCount,
                    PrintStream ps,
                    TablePrinter.PrintConfig config)
Constructs a new table printer.

Parameters:
columnCount - the number of columns in the table. Attemps to print more than these number of columns will result in a runtime exception.
pw - the destination print stream
config - the printing configuration

TablePrinter

public TablePrinter(int columnCount,
                    PrintWriter pw,
                    TablePrinter.PrintConfig config)
Constructs a new table printer.

Parameters:
columnCount - the number of columns in the table. Attemps to print more than these number of columns will result in a runtime exception.
pw - the destination print writer
config - the printing configuration
Method Detail

startTable

public void startTable()
This method should be called to start the table


endTable

public void endTable()
This method should be called to finish the table


startRow

public void startRow()
This method should be called to start a new row


endRow

public void endRow()
This method should be called to finish the existing row


printCell

public void printCell(String str)
This method should be called to print a new cell in the current row. This method should not be invoked for more columns than the table was instantiated with, otherwise a runtime exception will be thrown.


toString

public String toString()
Overrides:
toString in class Object

main

public static void main(String[] args)