使用BeanIO写入多个分段会导致大小不确定的错误



请帮助写入多个Segment throws错误

示例XML配置为

        <field name="noOfShipmentContents" type="Integer" />
        <segment name="shipmentContentsPart2"
            class="com.ShipmentContentsPart2"
            collection="list" minOccurs="1" maxOccurs="unbounded">
            <field name="shipmentContents" type="String" nillable="true" />
        </segment>
        <field name="noOfSpecialServices" type="Integer" />
        <segment name="specialServicesPart3"
            class="com.SpecialServicePart3"
            collection="list" minOccurs="0" maxOccurs="unbounded">
            <field name="chrgServCode" type="String" nillable="true" />
            <field name="chrgAmt" type="String" nillable="true" />
        </segment>
    </record>

beanio.jar 2.0.7版和2.1.0版都给出了相同的错误JDK的版本是什么?1.6.0.35

从beanIO Kevin的开发人员那里得到了答案(感谢),可以在出现次数依赖于同一记录中前一个字段的段上使用occursRef="[字段名称]"。

技巧是配置

<field name="noOfSpecialServices" type="Integer" />
    <segment name="specialServicesPart3" class="com.SpecialServicePart3"
   collection="list" occursRef="noOfSpecialServices">

此功能在beanIO2.1.x 中可用

最新更新