BeanIO 定长记录中的键值映射

Key-value mapping in BeanIO fixed-length record

我有以下specification定长数据文件(参考record-C类型规范,第4页)

a second part, having a length of 1,800 characters, consisting of a table of 75 elements to be used for the display of the only data present in the communication; each of these elements is constituted by a field-code of 8 characters and by a field-value of 16 characters

这意味着前 89 个字符(在上面的摘要中省略)是普通的旧固定长度,然后,对于剩余的 1800 个,我必须将它们分成一组键值对,每个键值对最多计数 24人物。空格被修剪,并且在此过程中不考虑空对。

理想情况下,我的 bean 可以像这样构造

public class RecordC{

    private List<Pair<String, String>> table = new ArrayList<>(MAX_TABLE_SIZE); //I don't want to use Map **yet**

}

有些东西可以是例如Apache Common 的 Pair<String,String> 或任何适合 KVP 映射的东西。

我知道我可以创建一个完整的 TypeHandler 来占用全部 1800 个字节,但我想利用 BeanIO 的强大功能。

这是我到目前为止所做的

    <record name="RECORD_C" class="it.csttech.ftt.data.beans.ftt2017.RecordC" order="3" minOccurs="1" maxOccurs="1" maxLength="2000">
        <field name="tipoRecord" rid="true" at="0" ignore="true" required="true" length="1" lazy="true" literal="C" />

        <field name="cfContribuente" at="1" length="16" align="left" trim="true" lazy="true" />
        <field name="progressivoModulo" at="17" length="8" padding="0" align="right" trim="true" lazy="true" />
        <field name="spazioDisposizioneUtente" at="25" length="3" align="left" trim="true" lazy="true" />
        <field name="spazioUtente" at="53" length="20" align="left" trim="true" lazy="true" />

        <field name="cfProduttoreSoftware" at="73" length="16" align="left" trim="true" lazy="true" />

        <segment name="table" collection="list" lazy="true" class="org.apache.commons.lang3.tuple.ImmutablePair">
            <field name="key" type="java.lang.String" at="0" length="8" trim="true" lazy="true" setter="#1" />
            <field name="value" type="java.lang.String" at="8" length="16" trim="true" lazy="true" setter="#2" />
        </segment>

        <field name="terminatorA" at="1897" length="1" rid="true" literal="A" ignore="true" />
    </record>

不幸的是,这在测试中不起作用。我在列表中只得到一条记录,在 [0-7] 和 [8-23] 位置解码,而不是预期的 [89-113][114-???][....][.... ]

问题是:如何在 BeanIO 中声明重复的固定长度字段?

我目前已经通过删除 RecordC 规范中的所有 at 属性解决了我的解组问题。正如我发现的那样,"at" 属性对于记录是绝对的,而不是相对于重复段的。然而,这迫使我在解组中添加一些被忽略的字段,而代价是 ignores。

一旦我有数据,我将针对官方控制器测试编组