Package me.landmesser.simplecsv
Class CSVWriter<T>
java.lang.Object
me.landmesser.simplecsv.CSVWriter<T>
- Type Parameters:
T- the type of objects that serve as input for the csv output.
- All Implemented Interfaces:
Closeable,AutoCloseable
public class CSVWriter<T> extends Object implements Closeable
Offers the possibility to write a CSV file to an
Appendable, e.g.
a Writer by transforming a stream of objects of type T.
The class of type T is parsed for annotations to
customize the behaviour of the writer.
-
Constructor Summary
Constructors Constructor Description CSVWriter(Appendable writer, Class<T> type, org.apache.commons.csv.CSVFormat format, boolean withHeaders) -
Method Summary
Modifier and Type Method Description voidclose()protected Stringconvert(Class<?> type, Object object)protected StringdetermineGetter(me.landmesser.simplecsv.CSVEntry entry)protected StringdetermineSetter(me.landmesser.simplecsv.CSVEntry entry)ColumnNameStylegetColumnNameStyle()List<me.landmesser.simplecsv.CSVEntry>getEntries()org.apache.commons.csv.CSVFormatgetFormat()Class<T>getType()protected <R> Rparse(Class<R> type, String value)protected List<me.landmesser.simplecsv.CSVEntry>parseClass(Class<T> type)protected voidsetFormat(org.apache.commons.csv.CSVFormat format)voidwrite(Stream<T> objects)
-
Constructor Details
-
CSVWriter
public CSVWriter(Appendable writer, Class<T> type, org.apache.commons.csv.CSVFormat format, boolean withHeaders) throws CSVException, IOException- Throws:
CSVExceptionIOException
-
-
Method Details
-
write
- Throws:
CSVWriteException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
getFormat
public org.apache.commons.csv.CSVFormat getFormat() -
setFormat
protected void setFormat(org.apache.commons.csv.CSVFormat format) -
parseClass
- Throws:
CSVException
-
convert
-
parse
- Throws:
CSVConversionException
-
determineSetter
-
determineGetter
-
getType
-
getEntries
-
getColumnNameStyle
-