unlockha / beanio

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

Allow segments with indeterminate length to occur in the middle of a record #57

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I know this is currently not supported, but due to a really wonky file format 
I've inherited, I wanted to see how possible it was to allow segments like the 
following:

 <record name='header'>
   <field length="2" name="record1"/>
   <segment maxOccurs="unbounded">
     <field length="3" name="repeatingFieldInTheMiddleOfARecord"/>
   </segment>
   <field length="2" name="recordN"/>
 </record>

Original issue reported on code.google.com by sreder1...@gmail.com on 4 Feb 2013 at 11:07

GoogleCodeExporter commented 8 years ago
That might be possible if BeanIO works backwards from the end of the record.  I 
don't think its going to be an easy change though, so it may be some time 
before I can get to it.

Original comment by kevin.s...@gmail.com on 6 Feb 2013 at 3:34

GoogleCodeExporter commented 8 years ago
Started looking into this...

Original comment by kevin.s...@gmail.com on 17 Feb 2013 at 5:10

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Added initial support for this in 2.0.4- snapshot JAR attached.  Let me know if 
you find any issues.

Thanks,
Kevin

Original comment by kevin.s...@gmail.com on 23 Feb 2013 at 10:26

Attachments:

GoogleCodeExporter commented 8 years ago

Original comment by kevin.s...@gmail.com on 23 Feb 2013 at 10:26

GoogleCodeExporter commented 8 years ago
Thanks!

I tried the patch out and it worked on a few sample cases, but failed on my 
specific file (did I mention it's a wonky file ;)   )

I believe there's an issue with calculating the (negative) offset for these 
segments.  If you have 2 repeating-segment-record's, one with its 
repeating-segment in the middle and one at the end... the one at the end seems 
to have its offset set to the offset of the other segment.

Confused?  So am I.  Attached is a sample test that should work, but it's late. 
 Let me know if I'm screwing something obvious up.

Original comment by sreder1...@gmail.com on 25 Feb 2013 at 5:35

Attachments:

GoogleCodeExporter commented 8 years ago
That was definitely a bug- thanks for the code!

Try the attached updated JAR and let me know if you can find any more...

Thanks,
Kevin

Original comment by kevin.s...@gmail.com on 1 Mar 2013 at 3:11

Attachments:

GoogleCodeExporter commented 8 years ago

Original comment by kevin.s...@gmail.com on 6 Mar 2013 at 3:14

GoogleCodeExporter commented 8 years ago
Confirming this latest snapshot validates my beanIO.xml and the file seems to 
unmarshal as expected.

Thanks again!

Original comment by sreder1...@gmail.com on 6 Mar 2013 at 4:53