Results 1 to 8 of 8

Thread: firstLineIsHeader in 2.0.0.RC3

  1. #1
    Join Date
    Apr 2009
    Posts
    2

    Default 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. #2
    Join Date
    Apr 2009
    Posts
    2

    Default

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

  3. #3
    Join Date
    Dec 2006
    Posts
    1,061

    Default

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

  4. #4
    Join Date
    Jun 2005
    Posts
    4,231

    Default

    Quote 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).

  5. #5
    Join Date
    Jul 2007
    Posts
    27

    Default

    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.

  6. #6
    Join Date
    Feb 2008
    Posts
    488

    Default

    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.

  7. #7

    Default

    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.

  8. #8
    Join Date
    Jun 2005
    Posts
    4,231

    Default

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •