This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

Retrieveing column boundaries in fixed length file parsing

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.

Comment

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

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