Announcement Announcement Module
Collapse
No announcement yet.
Retrieveing column boundaries in fixed length file parsing Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Retrieveing column boundaries in fixed length file parsing

    Hi All,

    I am parsing a fixed length file using FlatFileItemReader and mapping the valus to bean using BeanWrapperFieldSetMapper.

    I have a property of a bean as position. Which needs to hold the boundaries of particular column (or property of bean) in a record of flat file being parsed.

    Example: ABBxyz

    Here let ABB represents firstname and mapped to bean as a property and xyz the lastname again mapped to bean. Here i need to retrieve the position of firstname i.e., 0-3 and position of last name i.e., 4-6 progrmmatically.

    How to achieve this. Please let me know?

    Thank you.

  • #2
    I think this is too much logic for the BeanWrapperFieldSetMapper, you should perhaps think about implementing your own FieldSetMapper.

    Comment


    • #3
      Thank you very much for the reply.

      Do you have any suggestions or did u come across a method inside FiledSet class or any other class in Spring Batch API to retrieve the boundaries of field in flat file?

      Please help me in this regard. Thank you.

      Comment


      • #4
        in the custom FieldSetMapper, just read the String from the FieldSet and use String methods to extract the first name and the last name.

        but you should be doing tokenization inside the LineTokenizer. Basically, the FieldSet shouldn't come to the FieldSetMapper with 2 properties inside one field.

        Comment


        • #5
          Thanks for reply arno.

          I need some more help regrading this. As you said i have no problem in retrieving the values from flat file after tokenization. But my requirement is to know the position of particular filed of the line in falt file and make it available inside processor class..
          IN other words the position of xyz in the example given is from 4-6 i.e., 4th chratcter to 6th character. hence by any means spring cache this in some other method or class so that i can retrieve it and use it inside classes.

          Please help.

          Comment


          • #6
            Spring Batch doesn't cache tokenization information. The point is to clearly separate concerns, so tokenization shouldn't leak to the processor. I don't know exactly what you want to do, but you should check how the flat file item reader works and provides your own implementations of some of its collaborators to address your use case (e.g. LineTokenizer.)

            Comment

            Working...
            X