Search in sources :

Example 1 with ISOField

use of org.jpos.iso.ISOField in project jPOS by jpos.

the class TagSequenceBase method writeTo.

@Override
public synchronized void writeTo(ISOMsg isoMsg) throws ISOException {
    int maxField = isoMsg.getMaxField();
    List<TagValue> tagValueList = getOrderedList();
    int fieldNumber = 0;
    for (TagValue tagValue : tagValueList) {
        Object value = tagValue.getValue();
        if (value != null) {
            ISOComponent subField;
            if (value instanceof byte[]) {
                subField = new ISOBinaryField(fieldNumber + maxField + 1, (byte[]) value);
            } else if (value instanceof String) {
                subField = new ISOField(fieldNumber + maxField + 1, (String) value);
            } else if (value instanceof TagSequence) {
                TagSequence subSequence = (TagSequence) tagValue;
                subField = new ISOMsg(fieldNumber + maxField + 1);
                subSequence.writeTo((ISOMsg) subField);
            } else if (value instanceof ISOMsg) {
                ISOMsgTagValue subSequence = (ISOMsgTagValue) tagValue;
                subField = subSequence.getValue();
                subField.setFieldNumber(fieldNumber + maxField + 1);
            } else {
                throw new ISOException("Unknown TagValue subclass: " + tagValue.getClass());
            }
            isoMsg.set(new ISOTaggedField(tagValue.getTag(), subField));
        }
        fieldNumber++;
    }
}
Also used : ISOField(org.jpos.iso.ISOField) ISOComponent(org.jpos.iso.ISOComponent) ISOBinaryField(org.jpos.iso.ISOBinaryField) ISOException(org.jpos.iso.ISOException) ISOMsg(org.jpos.iso.ISOMsg)

Example 2 with ISOField

use of org.jpos.iso.ISOField in project jPOS by jpos.

the class IFTA_LLBINARY method unpackTag.

protected void unpackTag(ISOComponent c, InputStream in) throws ISOException, IOException {
    ISOField tagField = new ISOField((Integer) c.getKey());
    getTagPackager().unpack(tagField, in);
    ((ISOTaggedField) c).setTag(tagField.getValue().toString());
}
Also used : ISOField(org.jpos.iso.ISOField) ISOTaggedField(org.jpos.tlv.ISOTaggedField)

Example 3 with ISOField

use of org.jpos.iso.ISOField in project jPOS by jpos.

the class IFTA_LLLBINARY method unpackTag.

protected int unpackTag(ISOComponent c, byte[] tagBytes, int offset) throws ISOException {
    ISOField tagField = new ISOField((Integer) c.getKey());
    int consumed = getTagPackager().unpack(tagField, tagBytes, offset);
    ((ISOTaggedField) c).setTag(tagField.getValue().toString());
    return consumed;
}
Also used : ISOField(org.jpos.iso.ISOField) ISOTaggedField(org.jpos.tlv.ISOTaggedField)

Example 4 with ISOField

use of org.jpos.iso.ISOField in project jPOS by jpos.

the class IFTA_LLLCHAR method unpackTag.

protected void unpackTag(ISOComponent c, InputStream in) throws ISOException, IOException {
    ISOField tagField = new ISOField((Integer) c.getKey());
    getTagPackager().unpack(tagField, in);
    ((ISOTaggedField) c).setTag(tagField.getValue().toString());
}
Also used : ISOField(org.jpos.iso.ISOField) ISOTaggedField(org.jpos.tlv.ISOTaggedField)

Example 5 with ISOField

use of org.jpos.iso.ISOField in project jPOS by jpos.

the class IFTA_LLNUM method unpackTag.

protected int unpackTag(ISOComponent c, byte[] tagBytes, int offset) throws ISOException {
    ISOField tagField = new ISOField((Integer) c.getKey());
    int consumed = getTagPackager().unpack(tagField, tagBytes, offset);
    ((ISOTaggedField) c).setTag(tagField.getValue().toString());
    return consumed;
}
Also used : ISOField(org.jpos.iso.ISOField) ISOTaggedField(org.jpos.tlv.ISOTaggedField)

Aggregations

ISOField (org.jpos.iso.ISOField)50 Test (org.junit.Test)18 ISOException (org.jpos.iso.ISOException)15 ISOTaggedField (org.jpos.tlv.ISOTaggedField)15 IFB_LLNUM (org.jpos.iso.IFB_LLNUM)6 IFE_LLNUM (org.jpos.iso.IFE_LLNUM)6 ISOMsg (org.jpos.iso.ISOMsg)6 ISOMultiFieldPackager (org.jpos.iso.packager.ISOMultiFieldPackager)6 ISOComponent (org.jpos.iso.ISOComponent)5 ISOFieldPackager (org.jpos.iso.ISOFieldPackager)5 ISOVField (org.jpos.iso.ISOVField)5 Vector (java.util.Vector)4 FileInputStream (java.io.FileInputStream)3 Map (java.util.Map)3 ISOBinaryField (org.jpos.iso.ISOBinaryField)3 ByteBuffer (java.nio.ByteBuffer)2 ISOVError (org.jpos.iso.ISOVError)2 GenericPackager (org.jpos.iso.packager.GenericPackager)2 GenericTagSequence (org.jpos.tlv.GenericTagSequence)2 LiteralTagValue (org.jpos.tlv.LiteralTagValue)2