-
Jul 2nd, 2010, 06:32 PM
#1
Printing original line after using tokenizers
How can I get original line read from file after I have read and tokenized it using tokenizers and field-set mappers ? I want to split good and bad lines . After reading/searching I believe I have lost original item once once I mapped to Java object.
Thanks.
-
Jul 6th, 2010, 02:36 AM
#2
It's not as common a requirement as you might think, so you don't find a ready-made API for it in the framework. A FieldSet is a very low level abstraction, so you can pretty much get the line from there. The best solution I have seen is a composite item type that contains a domain object and the input field set,
-
Jul 6th, 2010, 12:58 PM
#3
Dave, Thanks for your reply. I would have been able to recreate the line from FieldSet if I would have read all the fields. I am reading limited number of fields from my long fixed-length line. It will be redundant to read all fields. Even if I do that and use composite item type, I will have to "recreate" the line which is not good idea as I will have to know formats of all other fields.
I am not sure if this is not common requirement. Its common to send back problematic records back to the sender of the file . The sender may correct it manually and send all the records again as new input file.
Is there any type of reader which just reads line as is ? Something like "PassThroughReader" ? May be I can use composite pattern there to collect lines as is and also map to my domain objects using FieldSet mappers.
-
Jul 6th, 2010, 10:20 PM
#4
That's another option. In either case you don't need a custom reader, just plug a LineMapper into the existing reader. A pass through LineMapper is trivial to write (so not in the framework a far as I know).
-
Jul 6th, 2010, 11:56 PM
#5
Hi Dave,
Thanks for response again. I just checked, PassThroughLineMapper is already there !. I think its for same purpose . My current reader is already PatternMatchingCompositeLineMapper using LineTokenizer mapping to domain objects. How can I plug in additional PassThroughLineMapper into it , is it possible to map input line to more than one domain object ? ( Here second domain will be just String )
-
Jul 8th, 2010, 01:05 AM
#6
Sounds like you just need to push the PatternMatchingCompositeLineMapper down to an ItemProcessor. Or use an extra composite wrapper around the PatternMatchingCompositeLineMapper and the PassThroughLineMapper.
-
Jul 8th, 2010, 12:43 PM
#7
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules