title: Usage of CustomEditor with BeanWrapperFieldExtractor just like with BeanWrapperFieldSetMapper
body: <p>I have written a simple Spring Batch application that reads a CSV file, does some transforming and writes a modified CSV to the disk.</p>
  
  <p>The reading of the file into domain objects works like a charm. I use <em>DelimitedLineTokenizer</em> to tokenize the lines and a <em>BeanWrapperFieldSetMapper</em> to feed the values into a bean:</p>
  
  <pre><code>&lt;bean id="reader" class="org.springframework.batch.item.file.FlatFileItemReader" scope="step"&gt;
      &lt;property name="resource" value="#{jobParameters['inputResource']}" /&gt;
      &lt;property name="linesToSkip" value="1" /&gt;
      &lt;property name="lineMapper"&gt;
          &lt;bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper"&gt;
              &lt;property name="lineTokenizer"&gt;
                  &lt;bean class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer"&gt;
                      &lt;property name="delimiter" value=";" /&gt;
                      &lt;property name="names"
                          value="ID,NAME,DESCRIPTION,PRICE,DATE" /&gt;
                  &lt;/bean&gt;
              &lt;/property&gt;
              &lt;property name="fieldSetMapper"&gt;
                  &lt;bean class="org.springframework.batch.item.file.mapping.BeanWrapperFieldSetMapper"&gt;
                      &lt;property name="targetType" value="myapp.MyDomainObject" /&gt;
                      &lt;property name="customEditors"&gt;
                          &lt;map&gt;
                              &lt;entry key="java.util.Date" value-ref="dateEditor" /&gt;
                              &lt;entry key="java.math.BigDecimal" value-ref="numberEditor" /&gt;
                          &lt;/map&gt;
                      &lt;/property&gt;
                  &lt;/bean&gt;
              &lt;/property&gt;
          &lt;/bean&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>I especially like the features of <em>BeanWrapperFieldSetMapper</em> to "guess" the field names and the possibility to define <em>CustomEditors</em> which I use to define the special date and number formats used in the input file.</p>
  
  <p>Now I would like to write the modified file in the same format like the input file. 
  I use the following configuration:</p>
  
  <pre><code>&lt;bean id="writer" class="org.springframework.batch.item.file.FlatFileItemWriter" scope="step"&gt;
      &lt;property name="resource" value="#{jobParameters['outputResource']}" /&gt;
      &lt;property name="lineAggregator"&gt;
          &lt;bean class="org.springframework.batch.item.file.transform.DelimitedLineAggregator"&gt;
              &lt;property name="delimiter" value=";" /&gt;
              &lt;property name="fieldExtractor"&gt;
                  &lt;bean class="org.springframework.batch.item.file.transform.BeanWrapperFieldExtractor"&gt;
                      &lt;property name="names" value="id,name,description,price,date" /&gt;
                  &lt;/bean&gt;
              &lt;/property&gt;
          &lt;/bean&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>There are two things I miss with this configuration:</p>
  
  <ol>
  <li><em>BeanWrapperFieldSetMapper</em> allowed me to set <em>CustomEditors</em>, but <em>BeanWrapperFieldExtractor</em> has no such possibility. Is there a way to use these?</li>
  <li>Is there a way to define the headings in the first line of the file? I have not found any way to write an initial line that is not a bean... It would be great to use the same names here as in <em>BeanWrapperFieldSetMapper</em> such that <em>BeanWrapperFieldExtractor</em> writes the inital line and guesses the bean property namens as <em>BeanWrapperFieldSetMapper</em> does.</li>
  </ol>
  
  <p>The process to load files is so comfortable in Spring Batch. Why is the writing of files so different? Am I missing something?</p>
  
  <p>I have to use Spring Batch 2.1.x because we are using Spring 3.0.x . Therefor an upgrade to 2.2.x would not be an option.</p>