FormatterLineAggregator, BeanWrapperFieldExtractor, ItemProcessor
I have a basic question on how to use the 3 clases, FieldExtractor, Aggregator, Processor.
I have a fixed width file I need to generate that has multiple record types some of which can have up to as many as 100 fields (probably more got sick of counting).
I think I understand the general relationship, I would use a reader (from db) to create my domain objects. The Extractor to reflectively create my fieldset for writing to the file. The ItemProcessor would sit in the middle and would be responsible for transforming any attributes that arent simply 1:1 with my db input source. Then the aggregator would take the fieldset and push out to the file in the fixed width format.
The question is how do I delineate the lengths of the strings/digits for the 100+ fields? One colossal printf format property string, whose tokens have to match the order of an object array of 100 elements? Seems like a maintenance nightmare. I am guessing I must be missing something here.
I am using the following as my reference:
Code:
<bean id="tradeLineAggregator"
class="org.springframework.batch.item.file.transform.FormatterLineAggregator">
<property name="fieldExtractor">
<bean class="org.springframework.batch.item.file.transform.BeanWrapperFieldExtractor">
<property name="names" value="isin,quantity,price,customer" />
</bean>
</property>
<property name="format" value="TRAD%-12s%-3d%6s%-9s" />
</bean>
Thanks in advance
-Trunks