Announcement Announcement Module
Collapse
No announcement yet.
firstLineIsHeader in 2.0.0.RC3 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • firstLineIsHeader in 2.0.0.RC3

    Hi,

    I an porting 1.1.4 batch job to the 2.0 version and have encountered a problem. The FlatFileItemReader no longer has the firstLineIsHeader property.

    In 2.0 version, how do I now read in the 1st line as a header and utilize it in the mapping of the bean?

    Thank you very much

  • #2
    I could extend FlatFileItemReader and override the doOpen but I was hoping that there is something already that has this functionality ...

    Comment


    • #3
      Set the linesToSkip property, and then implement a LineCallbackHandler, which will be called for each skipped line.

      Comment


      • #4
        Originally posted by vova123 View Post
        In 2.0 version, how do I now read in the 1st line as a header and utilize it in the mapping of the bean?
        Actually I don't think you can do that out of the box with 2.0. Shame. Open a JIRA and we might put that feature back, but probably not for 2.0.0 (since it was removed for a reason: when the LineMapper interface was introduced the reader no longer has control over the tokenisation).

        Comment


        • #5
          Has a JIRA been opened for this yet? I just ran across this issue as well.

          By the way, table 6.1 in the manual should be updated; the firstLineIsHeader property is still listed.

          Cheers.

          Comment


          • #6
            What's the problem with the linesToSkip + LineCallbackHandler approach? Can create a LineMapper (or FieldSetMapper) that implements LineCallbackHandler and then inject that into the FFIR? That way you can store any relevant information from the header directly on the Mapper for use when mapping.

            Comment


            • #7
              Any update on this for 2.1.0? I don't think there's any way to do this by having the FieldSetMapper implement the LineCallbackHandler interface as well for handling skipped lines, because there's no way to get to the FieldSet to set the column names on it (it's a method parameter of the mapFieldSet method).

              What would be the way to re-implement this in Spring Batch? I'd be happy to do it.

              Comment


              • #8
                No-one opened a JIRA as far as I know. 2.1.0 is out.

                You can definitely implement this feature with some combination of FieldSetFactory and LineCallbackHandler.

                Comment

                Working...
                X