Java Reference
In-Depth Information
Date readDate(String name, String pattern, Date defaultValue);
int getFieldCount();
Properties getProperties();
Note Unlike the JDBC ResultSet, which begins indexing columns at 1, the index used by Spring Batch's FieldSet
is zero-based.
To put the CustomerFieldSetMapper to use, you need to update the configuration to use it. Replace
the BeanWrapperFieldSetMapper reference with your own bean reference, as shown in Listing 7-15.
Listing 7-15. customerFileReader Configured with the CustomerFieldSetMapper
<beans:bean id="customerFile"
class="" scope="step">
<beans:constructor-arg value="#{jobParameters[customerFile]}"/>
<beans:bean id="customerFileReader"
<beans:property name="resource" ref="customerFile" />
<beans:property name="lineMapper">
<beans:property name="lineTokenizer">
<beans:bean class="org.springframework.batch.item.file.transform.
<beans:property name="names"
<beans:property name="delimiter" value=","/>
<beans:property name="fieldSetMapper">
Note that with your new CustomerFieldSetMapper, you don't need to configure the reference to the
Customer bean. Since you handle the instantiation yourselves, this is no longer needed.
Parsing files with the standard Spring Batch parsers, as you have shown, requires nothing more than
a few lines of XML. However, not all files consist of Unicode characters laid out in a format that is easy
for Java to understand. When dealing with legacy systems, it's common to come across data storage
Search WWH ::

Custom Search