net.sf.doolin.tabular.csv
Class CSVWriter<T>

java.lang.Object
  extended by net.sf.doolin.tabular.csv.CSVWriter<T>
Type Parameters:
T - Type of object per row
All Implemented Interfaces:
TabularWriter<T>

public class CSVWriter<T>
extends Object
implements TabularWriter<T>

Writer for CSV format.

Author:
Damien Coraboeuf

Constructor Summary
CSVWriter()
           
 
Method Summary
protected  String getCSVValue(Object value)
          Adapts a value for CSV
 CSVAdapter getDefaultAdapter()
          Returns the defaultAdapter property.
 String getEncoding()
          Returns the encoding property.
 String getSeparator()
          Returns the separator property.
 void setDefaultAdapter(CSVAdapter defaultAdapter)
          Sets the defaultAdapter property.
 void setEncoding(String encoding)
          Sets the encoding property.
 void setSeparator(String separator)
          Sets the separator property.
 void write(OutputStream output, TabularModel<T> model)
          Writes the given tabular data into the given output stream
protected  void writeLine(PrintWriter writer, List<String> line)
          Writes a line in the CSV destination.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CSVWriter

public CSVWriter()
Method Detail

getDefaultAdapter

public CSVAdapter getDefaultAdapter()
Returns the defaultAdapter property.

Returns:
defaultAdapter property.

getEncoding

public String getEncoding()
Returns the encoding property. It defaults to UTF-8.

Returns:
encoding property.

getSeparator

public String getSeparator()
Returns the separator property. It defaults to ",".

Returns:
separator property.

setDefaultAdapter

public void setDefaultAdapter(CSVAdapter defaultAdapter)
Sets the defaultAdapter property.

Parameters:
defaultAdapter - defaultAdapter property.

setEncoding

public void setEncoding(String encoding)
Sets the encoding property. It defaults to UTF-8.

Parameters:
encoding - encoding property.

setSeparator

public void setSeparator(String separator)
Sets the separator property. It defaults to ",".

Parameters:
separator - separator property.

write

public void write(OutputStream output,
                  TabularModel<T> model)
           throws IOException
Description copied from interface: TabularWriter
Writes the given tabular data into the given output stream

Specified by:
write in interface TabularWriter<T>
Parameters:
output - Output stream to write to
model - Data to write
Throws:
IOException - Thrown if an error occurs during the writing.

getCSVValue

protected String getCSVValue(Object value)
Adapts a value for CSV

Parameters:
value - Value to adapt
Returns:
Adapted value

writeLine

protected void writeLine(PrintWriter writer,
                         List<String> line)
Writes a line in the CSV destination.

Parameters:
writer - Writer to write to
line - Line to write


Copyright © 2011. All Rights Reserved.