I have a scenario to map user information to Map of Objects (Map or List).
I have say user info as follows CommonHeader(CX) block followed by 0 or more ID blocks followed by 0 or more Address blocks
Below are valid formats for user records
CX|19981222|19981222|ID|DriversLicence|111111111|ID|Passport|ABC12345|AD|123 Main Street|Atlanta|GA|30316|AD|100 PeachTree RD|Atlanta|Ga|3007|
CX|19981222|19981222|ID|DriversLicence|111111111|ID|Passport|ABC12345|
CX|19981222|19981222|AD|123 Main Street|Atlanta|GA|30316|AD|100 PeachTree RD|Atlanta|Ga|3007|
Is it possible to map such scenarios using beanio ?
Whats the best solution to handle these cases ?
I am using Beanio-2.1
My beanio mapping file is as follows
<stream name="userrRecord" format="delimited">
<parser>
<property name="delimiter" value="|"/>
</parser>
<record name="urecord" class="map" minOccurs="0" maxOccurs="unbounded" >
<segment name="CX" class="map">
<field name="CX"/>
<field name="DateFirstReported" type="date" format="yyyyMMdd"/>
<field name="DateLastReported" type="date" format="yyyyMMdd"/>
</segment>
<segment name="ID" class="map" minOccurs="0" maxOccurs="unbounded" collection="list">
<field name="ID"/>
<field name="IDType"/>
<field name="DocumentID"/>
</segment>
< segment name="AD" class="map" minOccurs="0" maxOccurs="unbounded" collection="list">
<field name="AD"/>
<field name="Street"/>
<field name="City"/>
<field name="State"/>
<field name="Zipcode"/>
</segment>
</record>
</stream>
When I try to unmarshall a record with 2 ID segmenst and 0 AD segments running into InvalidRecord exception.
Any help is highly appreciated.