|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.nuiton.util.csv.Import<E>
public class Import<E>
Import engine for a given import model.
It acts as anIterable, you can use directly inside a foreach.
The method prepareAndValidate() will be invoked before all and
only once. It mainly obtain header from the csv input, pass it to the model
and then validate the model.
| Field Summary | |
|---|---|
protected ImportModel<E> |
model
Csv import model. |
protected com.csvreader.CsvReader |
reader
Csv reader (this is the input). |
protected boolean |
validate
A flag to know if model was already validated. |
| Constructor Summary | |
|---|---|
protected |
Import(ImportModel<E> model,
InputStream inputStream)
|
protected |
Import(ImportModel<E> model,
Reader reader)
|
| Method Summary | ||
|---|---|---|
protected void |
checkAllMandatoryHeadersArePresent(String[] headers)
|
|
protected void |
checkHeaderNamesAreAllKnown(String[] headers)
|
|
protected void |
checkUniqueModelColumnNames()
|
|
void |
close()
|
|
protected List<ImportableColumn<E,?>> |
getAllMandatoryHeaders()
|
|
protected String[] |
getHeaders()
|
|
protected List<ImportableColumn<E,Object>> |
getNonIgnoredHeaders()
|
|
Iterator<E> |
iterator()
Define iterator over import. |
|
static
|
newImport(ImportModel<E> model,
InputStream inputStream)
|
|
static
|
newImport(ImportModel<E> model,
Reader reader)
|
|
protected
|
parseValue(ImportableColumn<E,T> field,
int lineNumber,
String value)
|
|
void |
prepareAndValidate()
Read the first mandatory headers line and validate it with the input model. |
|
protected boolean |
readRow()
Read the next row from the reader and return true if line
was successfully read. |
|
protected
|
readValue(ImportableColumn<E,T> field,
int lineNumber)
|
|
protected
|
setValue(ImportableColumn<E,T> field,
int lineNumber,
E element,
T parsedValue)
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected ImportModel<E> model
protected com.csvreader.CsvReader reader
protected boolean validate
| Constructor Detail |
|---|
protected Import(ImportModel<E> model,
InputStream inputStream)
protected Import(ImportModel<E> model,
Reader reader)
| Method Detail |
|---|
public static <E> Import<E> newImport(ImportModel<E> model,
InputStream inputStream)
public static <E> Import<E> newImport(ImportModel<E> model,
Reader reader)
public Iterator<E> iterator()
iterator in interface Iterable<E>prepareAndValidate()public void close()
close in interface Closeablepublic void prepareAndValidate()
ImportModel.pushCsvHeaderNames(List) call.
protected <T> String readValue(ImportableColumn<E,T> field,
int lineNumber)
protected <T> T parseValue(ImportableColumn<E,T> field,
int lineNumber,
String value)
protected <T> void setValue(ImportableColumn<E,T> field,
int lineNumber,
E element,
T parsedValue)
protected void checkHeaderNamesAreAllKnown(String[] headers)
protected void checkUniqueModelColumnNames()
protected void checkAllMandatoryHeadersArePresent(String[] headers)
protected String[] getHeaders()
throws ImportRuntimeException
ImportRuntimeExceptionprotected List<ImportableColumn<E,Object>> getNonIgnoredHeaders()
protected List<ImportableColumn<E,?>> getAllMandatoryHeaders()
protected boolean readRow()
throws ImportRuntimeException
true if line
was successfully read.
true if line was successfully read, says in fact there is
something after this line.
ImportRuntimeException - if could not read line
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||