|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object olg.csv.bean.BeanWriter<E>
E
- object this writer deals with.public class BeanWriter<E>
Class specialized in writing objects into a file Used a IWriter to write a
list of Strings into a file Uses a list of PropertyFormatter to transform an
E
object into a list of Strings.
IWriter
,
PropertyFormatter
Field Summary | |
---|---|
private IWriter |
baseWriter
the writer. |
private static org.slf4j.Logger |
LOGGER
The class logger. |
private IRowProcessor<E> |
rowProcessor
The row processor. |
Constructor Summary | |
---|---|
BeanWriter(File configFile,
IWriter writer)
|
|
BeanWriter(File configFile,
IWriter writer,
boolean skipEmptyRow)
|
|
BeanWriter(IRowProcessor<E> rowProcessor,
IWriter writer)
Construct a BeanWriter with a rowProcessor and a writer. |
Method Summary | |
---|---|
void |
close()
|
void |
write(E element)
Writes a bean on a dedicated output. |
void |
writeHeaders()
Allows to write a header line to describe the fields. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final org.slf4j.Logger LOGGER
private final IWriter baseWriter
private final IRowProcessor<E> rowProcessor
Constructor Detail |
---|
public BeanWriter(File configFile, IWriter writer) throws LoadException
configFile
- the file which describes how to load the field formatters used
to transform an object into a list of Strings. XML
Configuration must be a bean-writer or bean-row XML type, See
bean-row.xsd file. Must be not null
.writer
- Allows to write a list of Strings on a dedicated output. Must
be not null
.
LoadException
- if an error occurs during loading field formatters from filepublic BeanWriter(File configFile, IWriter writer, boolean skipEmptyRow) throws LoadException
configFile
- the file which describe how to load the field formatters used
to transform an object into a list of Strings. XML
Configuration must be a bean-writer or bean-row XML type, See
bean-row.xsd file. Must be not null
.writer
- Allows to write a list of Strings on a dedicated output. Must
be not null
.skipEmptyRow
- if true avoids writing blank lines.
LoadException
- if an error occurs during loading field formatters from file.public BeanWriter(IRowProcessor<E> rowProcessor, IWriter writer)
rowProcessor
- the rowProcessor. If the rowProcessor products empty rows,
blank lines are copied into the file.To avoid this case, use
IgnoreNullWriter. Must be not null
.writer
- the writer.Method Detail |
---|
public void close()
close
in interface Closeable
public void write(E element) throws PropertyException
Throws PropertyException if error occurs during property extraction and formatting.
Throws WriterException if I/O error occurs during writing.
element
- the bean to write. Must be not null
.
PropertyException
public void writeHeaders()
if the configuration file from which this beanWriter is defined is the bean-writer element, try to take the declared name of the column otherwise use "column_"i where i is the column num.
if the configuration file from which this beanWriter is defined is the bean-row element, try to take the name of the declared column, otherwise use the name of the corresponding property.
throws WriterException if this method is called after objects had been wroten or I/O error occurs.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |