Announcement Announcement Module
Collapse
No announcement yet.
Printing original line after using tokenizers Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

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

  • #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,

    Comment


    • #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.

      Comment


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

        Comment


        • #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 )

          Comment


          • #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.

            Comment


            • #7
              Thank you very much.

              Comment

              Working...
              X