Hi,
UPDATE:
we implemented a new class in this way:
import org.jpos.iso.BcdPrefixer;
import org.jpos.iso.ISOTagBinaryFieldPackager;
import org.jpos.iso.LiteralBinaryInterpreter;
import org.jpos.iso.NullPadder;
public class IFB_TTLLBINARY2 extends ISOTagBinaryFieldPackager {
public IFB_TTLLBINARY2() {
super(0,null, BcdPrefixer.LLL, NullPadder.INSTANCE,
LiteralBinaryInterpreter.INSTANCE, BcdPrefixer.LL);
}
public IFB_TTLLBINARY2 (int len, String description) {
super(len, description, BcdPrefixer.LLL, NullPadder.INSTANCE,
LiteralBinaryInterpreter.INSTANCE, BcdPrefixer.LL);
}
}
and use it in the xml structure as follows:
<isofieldpackager id="48"
name="additional data - private"
length="999"
class="org.jpos.iso.IFB_LLLBINARY"
emitBitmap="false"
tagMapper="org.jpos.iso.packager.TTTDecimalTagMapper"
packager="org.jpos.iso.packager.GenericTaggedFieldsPackager">
<isofield id="0" length="0" name="" class="org.jpos.iso.IF_CHAR"/>
<isofield id="1"
length="2"
name="Item Number"
class="IFB_TTLLBINARY2"/>
<isofield id="2"
length="3"
name="Elavon STAN"
class="IFB_TTLLBINARY2"/>
<isofield id="3"
length="6"
name="Elavon date and time"
class="IFB_TTLLBINARY2"/>
<isofield id="4"
length="6"
name="Elavon Retrieval ref number"
class="IFB_TTLLBINARY2"/>
</isofieldpackager>
it seems that pack works correctly, TAGs and LENGTHs are in bcd when we load every 48 subfield defined in the package.
In a particular case we receive the 48 field without the first subfield filled and the unpack throws the following exception:
"Field length 3 too long. Max: 2"
Debugging the code we found that the exception is raised by the class ISOTagBinaryFieldPackager in the unpack method. The 48 field test value is 0024 0002 03 123456 0003 06 123456123456 0004 06 123456123456 (bcd tags and lengths).
int tagLen = tagPrefixer.getPackedLength();
c.setFieldNumber(tagPrefixer.decodeLength(b, offset));
int len = prefixer.decodeLength(b, offset + tagLen);
if (len == -1) {
// The prefixer doesn't know how long the field is, so use
// maxLength instead
len = getLength();
}
else if (getLength() > 0 && len > getLength())
throw new ISOException("Field length " + len + " too long. Max: " + getLength());
the getLength() is referred to the first packager field (length = 2), but the actual found is the second (length = 3), so that len > getLength().
Does it mean that it's not possible to skip some subfield in a GenericTaggedFieldsPackager ? Or are we in the wrong way ?
many thanks