org.nuiton.util.csv
Class ImportToMap

java.lang.Object
  extended by org.nuiton.util.csv.Import<Map<String,Object>>
      extended by org.nuiton.util.csv.ImportToMap
All Implemented Interfaces:
Closeable, Iterable<Map<String,Object>>

public class ImportToMap
extends Import<Map<String,Object>>

A extended Import to read csv lines into a single map.

Warning: The map used to push values for a csv line is the same for all lines, it means you have to copy to your own object.

Since:
2.4
Author:
tchemit

Field Summary
 
Fields inherited from class org.nuiton.util.csv.Import
model, reader, validate
 
Constructor Summary
protected ImportToMap(ImportModel<Map<String,Object>> mapImportModel, InputStream inputStream)
           
protected ImportToMap(ImportModel<Map<String,Object>> mapImportModel, Reader reader)
           
 
Method Summary
 Iterator<Map<String,Object>> iterator()
          Define iterator over import.
static ImportToMap newImport(ImportModel<Map<String,Object>> model, InputStream inputStream)
           
static ImportToMap newImport(ImportModel<Map<String,Object>> model, Reader reader)
           
 
Methods inherited from class org.nuiton.util.csv.Import
checkAllMandatoryHeadersArePresent, checkHeaderNamesAreAllKnown, checkUniqueModelColumnNames, close, getAllMandatoryHeaders, getHeaders, getNonIgnoredHeaders, newImport, newImport, parseValue, prepareAndValidate, readRow, readValue, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImportToMap

protected ImportToMap(ImportModel<Map<String,Object>> mapImportModel,
                      InputStream inputStream)

ImportToMap

protected ImportToMap(ImportModel<Map<String,Object>> mapImportModel,
                      Reader reader)
Method Detail

newImport

public static ImportToMap newImport(ImportModel<Map<String,Object>> model,
                                    InputStream inputStream)

newImport

public static ImportToMap newImport(ImportModel<Map<String,Object>> model,
                                    Reader reader)

iterator

public Iterator<Map<String,Object>> iterator()
Description copied from class: Import
Define iterator over import. First of all, the input stream will be validated based on defined model. Iteration will be done on all csv rows except first headers line.

Specified by:
iterator in interface Iterable<Map<String,Object>>
Overrides:
iterator in class Import<Map<String,Object>>
Returns:
the Iterator used for csv iteration
See Also:
Import.prepareAndValidate()


Copyright © 2011-2012 CodeLutin. All Rights Reserved.