2.14.1: 2009-11-05

net.sf.basedb.util.export
Class TableWriter

java.lang.Object
  extended by java.io.Writer
      extended by java.io.PrintWriter
          extended by net.sf.basedb.util.export.TableWriter
All Implemented Interfaces:
Closeable, Flushable, Appendable
Direct Known Subclasses:
BaseFileWriter

public class TableWriter
extends PrintWriter

Wraps a writer stream and provides methods for easier writing of tabular data. The writer can be configured with a setDataSeparator(String) (default is 'tab') and setNullValue(String) (default is an empty string). Use tablePrintData(Object...) to print a singe line with data.

Version:
2.12
Author:
Nicklas
Last modified
$Date: 2009-06-15 11:05:06 +0200 (Mon, 15 Jun 2009) $

Field Summary
private  String dataSeparator
           
private  String nullValue
           
 
Fields inherited from class java.io.PrintWriter
out
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
TableWriter(Writer out)
          Create a new table writer that is writing it's output to the given writer.
 
Method Summary
 String getDataSeparator()
          The data separator string is written between each data column in the output.
 String getNullValue()
          The null value string is written to the output instead of null data values.
 void setDataSeparator(String dataSeparator)
          Change the data separator string.
 void setNullValue(String nullValue)
          Change the null value string.
 void tablePrintData(Object... data)
          Print a data line to the parent writer.
 
Methods inherited from class java.io.PrintWriter
append, append, append, checkError, clearError, close, flush, format, format, print, print, print, print, print, print, print, print, print, printf, printf, println, println, println, println, println, println, println, println, println, println, setError, write, write, write, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dataSeparator

private String dataSeparator

nullValue

private String nullValue
Constructor Detail

TableWriter

public TableWriter(Writer out)
Create a new table writer that is writing it's output to the given writer.

Parameters:
out - The writer to write the data to
Method Detail

getDataSeparator

public String getDataSeparator()
The data separator string is written between each data column in the output. The default value is 'tab'.

Returns:
The current value of the data separator string

setDataSeparator

public void setDataSeparator(String dataSeparator)
Change the data separator string.

Parameters:
dataSeparator - The new data separator

getNullValue

public String getNullValue()
The null value string is written to the output instead of null data values. The default value is an empty string.

Returns:
The current value of the null value string

setNullValue

public void setNullValue(String nullValue)
Change the null value string.

Parameters:
nullValue - The new null value string

tablePrintData

public void tablePrintData(Object... data)
Print a data line to the parent writer. Each value is separated by the data separator string ('tab' by default). Null values are replaced with the null value string (empty string by default). Non-null objects are converted to strings values by calling their toString() method.

Parameters:
data - The values to write

2.14.1: 2009-11-05