|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.supercsv.io.AbstractCsvReader
org.supercsv.io.CsvBeanReader
public class CsvBeanReader
This class reads a line from a csv file, instantiates a bean and populate its fields.
| Field Summary | |
|---|---|
protected MethodCache |
cache
|
protected List<? super Object> |
lineResult
object used for storing intermediate result of a processing of cell processors and before put into maps/objects etc.. |
| Fields inherited from class org.supercsv.io.AbstractCsvReader |
|---|
line, preferences, tokenizer |
| Constructor Summary | |
|---|---|
CsvBeanReader(Reader reader,
CsvPreference preferences)
Create a csv reader with a specific preference. |
|
| Method Summary | ||
|---|---|---|
void |
close()
close the stream |
|
String |
get(int N)
Get column N of the current line This is useful for parsing e.g. first column and react by reading the line on the basis of that first argument |
|
String[] |
getCSVHeader(boolean firstLineCheck)
This method is used to get an optional header of the csv file and move the file curser to the first row containing data (the second row from the top) The header can subsequently be used as the nameMapper for read
operations. |
|
int |
getLineNumber()
gets the current position in the file. |
|
int |
length()
returns the length of the current line |
|
|
read(Class<T> clazz,
String... nameMapping)
Read a line and populate an instance of the specified type. |
|
|
read(Class<T> clazz,
String[] nameMapping,
CellProcessor[] processors)
Read a line of a csv file and populate a bean with the data. |
|
org.supercsv.io.ICsvReader |
setPreferences(CsvPreference preference)
Determine how the reader reads the input source. |
|
org.supercsv.io.ICsvReader |
setTokenizer(ITokenizer tokenizer)
Determine how the reader reads the csv file. |
|
| Methods inherited from class org.supercsv.io.AbstractCsvReader |
|---|
close, get, getCSVHeader, getLineNumber, length, setInput, setPreferences, setTokenizer |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected List<? super Object> lineResult
protected MethodCache cache
| Constructor Detail |
|---|
public CsvBeanReader(Reader reader,
CsvPreference preferences)
| Method Detail |
|---|
public <T> T read(Class<T> clazz,
String... nameMapping)
throws IOException,
SuperCSVReflectionException
read in interface ICsvBeanReaderclazz - the type to instantiate. If the type is a class type, an instance can be created straight away. If the
type is an interface type, a proxy is created on the fly which acts as an implementation.nameMapping - an array describing the property name of the line read. The position of the property array corresponds to
the column in the csv file. null denote the column in the csv file is ignored.
IOException
SuperCSVReflectionException
public <T> T read(Class<T> clazz,
String[] nameMapping,
CellProcessor[] processors)
throws IOException,
SuperCSVReflectionException,
SuperCSVException
read in interface ICsvBeanReaderclazz - the type to instantiate. If the type is a class type, an instance can be created straight away. If the
type is an interface type, a proxy is created on the fly which acts as an implementation.nameMapping - an array describing the property name of the line read. The position of the property array corresponds to
the column in the csv file. null denote the column in the csv file.processors - an array of CellProcessor. The position in the array must match the position of the nameMapping. Null
entries in the array denotes columns that should not be processed.
IOException
SuperCSVReflectionException
SuperCSVException
public void close()
throws IOException
IOException
public String get(int N)
throws IOException,
IndexOutOfBoundsException
IOException
IndexOutOfBoundsException
public String[] getCSVHeader(boolean firstLineCheck)
throws IOException
nameMapper for read
operations.
firstLineCheck - denotes whether a check should be made to ensure only the first line of the file can represent a header
IOException - if an I/O error occurs or if the method is not called as the first read operation on a source. *public int getLineNumber()
public int length()
throws IOException
IOExceptionpublic org.supercsv.io.ICsvReader setPreferences(CsvPreference preference)
public org.supercsv.io.ICsvReader setTokenizer(ITokenizer tokenizer)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||