Search code examples
jpos

JPOS Generic Packager: subfields within subfields?


According to my ISO Spec manual, I have a bitmapped F126, which I have defined in my Generic Packager as follows:

<isofieldpackager
        id="126"
        length="255"
        name="FIELD 63 - Privately-Defined Data"
        bitmapField="0"
        firstField="1"
        class="org.jpos.iso.IFB_LLHBINARY"
        packager="org.jpos.iso.packager.GenericSubFieldPackager">
    <isofield
            id="0"
            length="8"
            name="Bit Map"
            class="org.jpos.iso.IFB_BITMAP"/>
    <isofield
            id="5"
            length="8"
            name="Visa Merchant Indentifier"
            class="org.jpos.iso.IFE_CHAR"/>
    <isofield
            id="6"
            length="34"
            name="Cardholder Certificate Serial Number"
            class="org.jpos.iso.IFB_HEX"/>
........

According to my specification manual for this field, one of the subfields appears to be made up of additional subfields

Field 126.18 – Attributes
Fixed length
binary value 11, 1 byte, +
5 ANS, EBCDIC, 5 bytes +
48 N bit string, 6 bytes
12 bytes total

I'm unsure of how to implement this in the generic packager. In my head, I imagine this looking like

<isofieldpackager
        id="126"
        length="255"
        name="FIELD 63 - Privately-Defined Data"
        bitmapField="0"
        firstField="1"
        class="org.jpos.iso.IFB_LLHBINARY"
        packager="org.jpos.iso.packager.GenericSubFieldPackager">
    <isofield
            id="0"
            length="8"
            name="Bit Map"
            class="org.jpos.iso.IFB_BITMAP"/>
    <isofieldpackager id="18" name="subfield 18" length="12" class="org.jpos.iso.IFB_LLHBINARY" packager="packager="org.jpos.iso.packager.GenericSubFieldPackager">
                          
        <isofield
                id="1"
                length="1"
                name="Binary Value 11"
                class="org.jpos.iso.IFB_BINARY"/>
        <isofield
                id="2"
                length="5"
                name="5 ANS EBCIDIC"
                class="org.jpos.iso.IFE_LLCHAR"/>
           <isofield
                id="3"
                length="6"
                name="Remaining 48N bit string"
                class="org.jpos.iso.IFB_LLBINARY"/>
    </isofieldpackager>
</isofieldpackager>

But obviously we can't have a isofieldpackager inside of another one. So how can I implement nested subfields while utilizing the generic packager XML still? All other subfields I have working except for this one, since it seems to combine binary + ebcid


Solution

  • Short answer, you can have inner subfield packagers. However, you have to specify all the fields inside the isofieldpackager, as you do in the packager.

    I also spotted an error in the sub sub fields, according to the psec fragment you shared, they are fixed size and you are defining them as LLVAR, so they should be:

                <isofield
                        id="1"
                        length="1"
                        name="Binary Value 11"
                        class="org.jpos.iso.IFB_BINARY"/>
                <isofield
                        id="2"
                        length="5"
                        name="5 ANS EBCIDIC"
                        class="org.jpos.iso.IFE_CHAR"/>
                <isofield
                        id="3"
                        length="6"
                        name="Remaining 48N bit string"
                        class="org.jpos.iso.IFB_BINARY"/>
    

    You could also handle the 126.18 DE as an opaque field and get the fields from the byte array in your application code. At least as a first approach to check the outer packager before going inside.