public class TableWriter extends PrintWriter
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.Modifier and Type | Field and Description |
---|---|
private String |
dataSeparator |
private EncoderDecoder |
encoder |
private String |
nullValue |
out
Constructor and Description |
---|
TableWriter(Writer out)
Create a new table writer that is writing it's output to the
given writer.
|
Modifier and Type | Method and Description |
---|---|
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.
|
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
private String dataSeparator
private String nullValue
private EncoderDecoder encoder
public TableWriter(Writer out)
out
- The writer to write the data topublic 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 encodepublic 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