|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.projectnine.csvmapper.CsvToObjectMapper
public class CsvToObjectMapper
This class is the only class in which users should be directly interested.
First of all, if you don't want to go insane, use a spring application
context to configure your CsvMappingDefinition
s and add them the
csvMappingDefinitions
Map
.
Check out the test cases for examples (src/test).
Not thread safe. May never be. We'll see.
Field Summary | |
---|---|
static java.lang.String |
ARGUMENT_TOKEN
JEXL expressions for property names in the CsvFieldMapping should
include this token somewhere. |
protected static java.util.Map<java.lang.String,CsvMappingDefinition> |
csvMappingDefinitions
All of the mapping definitions that are available to you. |
Constructor Summary | |
---|---|
CsvToObjectMapper()
Default constructor. |
|
CsvToObjectMapper(org.springframework.core.io.Resource csvResource,
boolean containsHeader,
java.lang.String mappingDefinition)
This constructor is pretty useful. |
Method Summary | |
---|---|
java.lang.Object |
generateNextObjectFromCsv()
Generate the next Object from CSV. |
long |
getCurrentLineNumber()
On what line number is the csvReader? |
void |
init(org.springframework.core.io.Resource csvResource,
boolean containsHeader,
java.lang.String mappingDefinition)
Initializes the object by setting the mappingDefinition and
instantiating the csvReader . |
static void |
main(java.lang.String[] args)
|
void |
seek(long parserPosition)
Move the cursor of the csvReader to the specified line number. |
void |
setCsvMappingDefinitions(java.util.Map<java.lang.String,CsvMappingDefinition> csvMappingDefinitions)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String ARGUMENT_TOKEN
CsvFieldMapping
should
include this token somewhere. The token is a placeholder for the adjusted
RAW CSV Field String value.
So if you want your JEXL expression to do something like this:
getFooMap().put('bar', adjustedCsvValue)
you really want to type this:
getFooMap().put('bar', %ARGUMENT%)
protected static java.util.Map<java.lang.String,CsvMappingDefinition> csvMappingDefinitions
Constructor Detail |
---|
public CsvToObjectMapper()
init(Resource, boolean, String)
!!!
public CsvToObjectMapper(org.springframework.core.io.Resource csvResource, boolean containsHeader, java.lang.String mappingDefinition)
csvResource
- The Resource
containing the CSV file.containsHeader
- Does this CSV file contain a header? I need to know so that I
can skip the header if it's there. There might be problems
otherwise...mappingDefinition
- The name of the mapping definition that we are using from the
csvMappingDefinitions
.Method Detail |
---|
public void init(org.springframework.core.io.Resource csvResource, boolean containsHeader, java.lang.String mappingDefinition)
mappingDefinition
and
instantiating the csvReader
.
CsvToObjectMapper(Resource, boolean, String)
public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception
public java.lang.Object generateNextObjectFromCsv() throws java.lang.Exception
java.lang.Exception
public void setCsvMappingDefinitions(java.util.Map<java.lang.String,CsvMappingDefinition> csvMappingDefinitions)
csvMappingDefinitions
- the csvMappingDefinitions to setpublic long getCurrentLineNumber()
public void seek(long parserPosition)
parserPosition
-
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |