gautamdudeja90 / beanio

Automatically exported from code.google.com/p/beanio
Apache License 2.0
0 stars 1 forks source link

Identify a record based on number of field? #46

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I have a delimited file with following structure:

550 3034 244 1 0 660 0 0 0 0 0 0 0 0 01
3090 120
3082 202
424 3180 219 1 0 660 0 0 0 0 0 0 0 0 05
3300 300
3300 390
3220 390

The longer line(with 15 fields) is mapped to a parent class, and the short line 
(with 2 fields) is mapped to a list inside the parent class.

The problem is that I cannot identify a record correctly because the first 2 
fields are both integer. Is there a way to identify a record based on number of 
field??

I am using BeanIO version 2.0.1 with JDK6.

Many thanks,
Steve

Original issue reported on code.google.com by steve...@gmail.com on 23 Nov 2012 at 8:01

Attachments:

GoogleCodeExporter commented 9 years ago
I agree this functionality would be helpful and will look into adding it.

Thanks,
Kevin

Original comment by kevin.s...@gmail.com on 26 Nov 2012 at 7:19

GoogleCodeExporter commented 9 years ago
That would be great! Please kindly keep me posted when this feature is included 
in the new version.

Original comment by steve...@gmail.com on 26 Nov 2012 at 10:30

GoogleCodeExporter commented 9 years ago
A 2.0.3 snapshot JAR is attached that supports this functionality.  Simply set 
ridLength="..." on a record definition in a mapping file to identify records 
based on length (field count for delimited/CSV and character count for fixed 
length).  The 'ridLength' setting follows the same format as 'occurs' (e.g. 
"2", "1-3", "1+").  There is no validation for overlapping ranges, in which 
case record identification behavior is undefined and subject to change.

Original comment by kevin.s...@gmail.com on 29 Nov 2012 at 3:50

Attachments:

GoogleCodeExporter commented 9 years ago
Hi Kevin,

Many thanks for the prompt action! I have integrated the snapshot JAR and it 
works perfectly fine. Now I can only wait until it's integrated in the new 
release!

Great work!
Steve

Original comment by steve...@gmail.com on 4 Dec 2012 at 12:02

GoogleCodeExporter commented 9 years ago
Fixed in release 2.0.3.

Original comment by kevin.s...@gmail.com on 22 Dec 2012 at 4:26