Apr 8th, 2009, 01:39 PM
firstLineIsHeader in 2.0.0.RC3
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
Apr 8th, 2009, 03:59 PM
I could extend FlatFileItemReader and override the doOpen but I was hoping that there is something already that has this functionality ...
Apr 8th, 2009, 04:15 PM
Set the linesToSkip property, and then implement a LineCallbackHandler, which will be called for each skipped line.
Apr 8th, 2009, 04:21 PM
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).
Originally Posted by vova123
Apr 14th, 2009, 03:27 AM
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.
Apr 14th, 2009, 09:48 AM
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.
Feb 11th, 2010, 08:04 AM
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.
Feb 11th, 2010, 12:51 PM
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.