如何获取在 jPos 中字段开头指定长度的字段的长度值?

发布于 2025-01-17 02:13:39 字数 708 浏览 5 评论 0原文

为了更好地控制和清晰地解包 ISO8583 消息,我想打印每个字段的长度,我的第一次尝试是这样的:

 .getFieldPackager(i).getLength()

在这样的代码中:

 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));
     }

对于具有可变长度的字段,它显示最大长度,而不是实际长度。

任何机构都可以帮忙吗?

编辑:

正如评论中所述,我们可以计算字段的长度:

message.getString(n).getLength()

但是我们无法计算出Jpos的长度作为字段的长度,如果JPos错误,则无法控制它。

我们只需要字段的第一个数字,它代表字段的长度,用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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

2025-01-24 02:13:39

您正在打印 jPOS Packager 的配置,除非您使用 message.unpack() 使用打包器解析消息并将其解包到 ISOMsg 对象中,否则您将无法寻址数据及其字段长度 - 一旦您 unpack() 您可以使用 message.getString(n).getLength() 或等效方法获取数据的长度。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文