|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.Writer java.io.PrintWriter net.sf.basedb.util.export.TableWriter
public class TableWriter
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'),
setNullValue(String)
(default is an empty string)
and an setEncoder(EncoderDecoder)
(no default).
Use tablePrintData(Object...)
to print a singe line
with data. Other PrintWriter
methods are not affected
by those settings.
Field Summary | |
---|---|
private String |
dataSeparator
|
private EncoderDecoder |
encoder
|
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. |
EncoderDecoder |
getEncoder()
Get the current default encoder for this writer. |
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 |
setEncoder(EncoderDecoder encoder)
Change the encoder. |
void |
setNullValue(String nullValue)
Change the null value string. |
String |
tableEncode(String s)
Encode the given string with the default encoder. |
void |
tablePrintData(EncoderDecoder encoder,
Object... data)
Print a data line to the parent writer. |
void |
tablePrintData(Object... data)
Print a data line to the parent writer using the default encoder. |
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 |
---|
private String dataSeparator
private String nullValue
private EncoderDecoder encoder
Constructor Detail |
---|
public TableWriter(Writer out)
out
- The writer to write the data toMethod Detail |
---|
public String getDataSeparator()
public void setDataSeparator(String dataSeparator)
setEncoder(EncoderDecoder)
.
dataSeparator
- The new data separatorpublic String getNullValue()
public void setNullValue(String nullValue)
nullValue
- The new null value stringpublic EncoderDecoder getEncoder()
public void setEncoder(EncoderDecoder encoder)
encoder
- The new encoder or null to not encodepublic String tableEncode(String s)
s
- The string to encode
public void tablePrintData(Object... data)
data
- The values to writepublic void tablePrintData(EncoderDecoder encoder, Object... data)
EncoderDecoder.encode(String)
.
data
- The values to writeencoder
- The encoder to use, or null to not use any encoder
|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |