Package me.landmesser.simplecsv
Class CSVReader<T>
java.lang.Object
me.landmesser.simplecsv.CSVReader<T>
- Type Parameters:
T
- the type of objects that should be created out of the csv input.
- All Implemented Interfaces:
Closeable
,AutoCloseable
public class CSVReader<T> extends Object implements Closeable
Offers the possibility to read a CSV file from a
Reader
and
transfer the result in a stream of objects of type T
The class of type T
is parsed for annotations to
customize the behaviour of the parser.
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description void
close()
protected String
convert(Class<?> type, Object object)
protected String
determineGetter(me.landmesser.simplecsv.CSVEntry entry)
protected String
determineSetter(me.landmesser.simplecsv.CSVEntry entry)
ColumnNameStyle
getColumnNameStyle()
List<me.landmesser.simplecsv.CSVEntry>
getEntries()
org.apache.commons.csv.CSVFormat
getFormat()
Class<T>
getType()
protected <R> R
parse(Class<R> type, String value)
protected List<me.landmesser.simplecsv.CSVEntry>
parseClass(Class<T> type)
Stream<T>
read()
protected void
setFormat(org.apache.commons.csv.CSVFormat format)
-
Constructor Details
-
CSVReader
public CSVReader(Reader reader, Class<T> type, org.apache.commons.csv.CSVFormat format) throws CSVException, IOException- Throws:
CSVException
IOException
-
-
Method Details
-
read
- Throws:
CSVParseException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in 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
-