Feb 3rd, 2010, 07:04 AM
Multiple lines, optional field,
In my project I parse a file with edifact format. The file contains multiple lines (records) which have the same configuration. The problem is that some of the fields of a record are optional or mandatory. This depends in which part of the file this record is used.
The following 2 lines explains the problem.
I definend the following in my context:
<bean id="orderFileTokenizer" class="org.springframework.batch.item.file.transfo rm.PatternMatchingCompositeLineTokenizer">
<entry key="FII*" value-ref=FIITokenizer" />
<entry key="*" value-ref="defaultLineTokenizer"/>
<bean id="parentLineTokenizer" class="org.springframework.batch.item.file.transfo rm.DelimitedLineTokenizer" abstract="true">
<property name="delimiter" value="+"/>
<bean id="FIITokenizer" parent="parentLineTokenizer">
<property name="names" value="FII_SEG,FII_PARTY_QUAL,FII_ACCOUNT,FII_INST ITUTION,FII_COUNTRY" />
<!--<property name="names" value="" />-->
In my case the FII_COUNTRY is an optional field which is not possible to configure. How can I handle this problem.
Many thanks for an advice.
Feb 3rd, 2010, 07:19 AM
One point I forgot, is there also a solution to have more delimiters? In my example I have a + as delimeter for the fields(objects). An object can be an aggregation of other fields which are delimeted by the :
In my implementation I retrieve the whole object with the colons. In the custom mapper I parse the fields and set them to the correct field in the object.
Is this the right way to do or is there an better way to do this.