fubar-coder / beanio

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

usage of at/position property on fields in fixedlength format #95

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I am cross-posting this as an issue as well as in google groups
https://groups.google.com/forum/#!topic/beanio/QM-DriwZm8w

I have run in to a problem relating to the fact that the interpretation of the 
"at" property is different for delimited and fixedlength formats

We have a use case where we have a file spec that supports both formats, and 
some clients use one, and other clients use the other.

We would like to be able to define one record to be used on either format.  We 
are using annotations to define our records

Currently, for delimited formats, "at" designates the order of the fields, and 
for fixedlength it designates the starting position. these values are almost 
always different.

I propose that the "at" property be interpreted as the order of the field in 
both cases, and the starting position of fixedlength fields can be derived from 
the order of the fields and the length of each field.

I believe that this would lead to more consistent usage of the property.

Please let me know if it makes sense to make this change in your library.  If 
not, some direction on where to make this change in the code if we were to fork 
it would be helpful. Thanks

Original issue reported on code.google.com by jbu...@ersinc.com on 13 Dec 2013 at 3:52

GoogleCodeExporter commented 9 years ago
The 'at' property will not be changed.  Current behavior cannot be broken and 
was designed that way to allow for skipping fields that can be ignored.

I will investigate adding a new property that controls annotated field sort 
order, so that if you do declare all fields, BeanIO can determine field 
positioning.  In the meantime, you can still achieve the behavior you want 
using a mapping file instead of annotations.

Thanks,
Kevin

Original comment by kevin.s...@gmail.com on 14 Dec 2013 at 7:45

GoogleCodeExporter commented 9 years ago
OK. Thanks for the feedback.  Your idea would work for our use case as well.  
We look forward to being able to achieve this functionality with annotations.
Thanks

Original comment by jbu...@ersinc.com on 16 Dec 2013 at 6:23

GoogleCodeExporter commented 9 years ago
Try the attached snapshot JAR.  I've added an 'ordinal' property on @Field and 
@Segment that I think will accomplish what you are looking for.  A few caveats: 
 you should define every field in a record and you won't be able to use 'until' 
logic (although it won't stop you from trying).

Thanks,
Kevin

Original comment by kevin.s...@gmail.com on 17 Dec 2013 at 4:25

Attachments:

GoogleCodeExporter commented 9 years ago
Kevin,
Thanks! This does work as intended.

Original comment by jbu...@ersinc.com on 18 Dec 2013 at 9:34

GoogleCodeExporter commented 9 years ago

Original comment by kevin.s...@gmail.com on 17 Jan 2014 at 3:12

GoogleCodeExporter commented 9 years ago

Original comment by kevin.s...@gmail.com on 7 Sep 2014 at 2:16