'How to get the length value for fields whose length is specified at the beginning of the field in jPos?
For more control and clarity of the unpack ISO8583 message , I wanted to print the length of each field, my first attempt was this:
.getFieldPackager(i).getLength()
In a code like this:
Gp=new GenericPackager("./iso87ascii.xml");
message.setPackager(Gp);
for (int i = 0; i <= 128; i++) {
if (message.hasField(i)) {
System.out.println(message.getPackager().getFieldDescription(message, i) +
Gp.getFieldPackager(i).getLength()+
message.getString(i));
}
For fields with variable lengths, it shows the maximum length, not the actual length.
Can any body help?
Edit:
As stated in the comment, We can calculate the length of field:
message.getString(n).getLength()
but we can not figure out what length Jpos has as the length of the field, and if JPos is wrong, there is no way to control it.
We only need the first number of the field, which represents the length of the field, with Jpos terms
Solution 1:[1]
You are printing out the configuration of the jPOS Packager, you won’t have addressability to data and its field lengths until you parse and unpack a message using a packager into an ISOMsg Object using message.unpack() - once you unpack() you can get the length of the data using message.getString(n).getLength() or equivalent.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | David Bergert |
