0

I created a beanio for a file. The issue is the file can be varying lengths which throws an error when a certain field is expected to occur or have a certain length. I was able to get past the issue where the beanio was expecting a certain field that never occured by just setting the minOccurs to 0. The issue i have now is if any field is partially filled out, it'll throw a error saying it expected the field to be of the length set. Here's my beanio stream setup

         <record name="Record" minOccurs="0" maxOccurs="unbounded"
                class="com.common.vo.Record">
            <field name="record_type" length="3" default="REC" literal="REC" rid="true"/>
            <field name="idNumber" length="19" trim="true" />
            <field name="centerCode" length="20" />
        </record>
      </stream>

I tried setting the minLength to 0, but it still throws the same error that it expects the length to be 20. I tried removing the length field and using the min and max length fields instead but with this format, it expects that length field and throws an error. Any ideas? I would like to avoid creating multiple different streams if possible

Cris Manrique
  • 83
  • 1
  • 7

1 Answers1

0

Quite late, but maybe helpful:

What about creating your own RecordParserFactory and dealing there with your individual deviations? Some of them maybe expected, others are maybe real errors which you need to throw?

Add your own ParserFactory to streamBuilder

StreamBuilder sb = new StreamBuilder(...).parser(myRecordParserInstance)...