如何比较两个Swift-MT消息?

How to Compare two Swift-MT message?

我有两个要比较的 SWIFT 文件,其中包含不同的 SWIFT 消息。是否有任何库可以比较 SWIFT 消息并显示它们之间的确切区别?

我有两条 SWIFT 消息如下:

{1:ABC}{2:DEF}{3:{108:valid}} 
{4::16R:GENL:20C::CORP//0000000519765434:20C::SEME//525200100000002:16S-} 
{1:ABC}{2:DEF}{3:{108:valid}} 
{4::16R:GENL:20C::CORP//0000000519765434:20C::SEME//528200100000009:16S-}

{1:ABC}{2:DEF}{3:{108:valid}} 
{4::16R:GENL:20C::CORP//0000000519765434:20C::SEME//610300100000001:16S-} 
{1:ABC}{2:DEF}{3:{108:valid}} 
{4::16R:GENL:20C::CORP//0000000519765434:20C::SEME//528200100000009:16S-}

如何比较这两个 SWIFT 消息?

已编辑: 我使用以下程序比较记录但坚持比较值:

IConversionService ics = new ConversionService();
        SwiftMessage sm1 = ics.getMessageFromFIN(source);
        SwiftMessage sm2 = ics.getMessageFromFIN(target);

        SwiftBlock4 source_block4 = sm1.getBlock4();
        SwiftBlock4 target_block4 = sm2.getBlock4();

        List<SwiftTagListBlock> source_tagListBlock = source_block4.getSubBlocks("16R", "16S");
        List<SwiftTagListBlock> target_tagListBlock = target_block4.getSubBlocks("16R", "16S");

        //SetMultimap<String, String> source_multimap1 = HashMultimap.create();

        ListMultimap<String, String> source_multimap = ArrayListMultimap.create();
        ListMultimap<String, String> target_multimap = ArrayListMultimap.create();

        for (SwiftTagListBlock s : source_tagListBlock) {
            Iterator<Tag> sourcetag_iterator = s.tagIterator();

            while (sourcetag_iterator.hasNext()) {
                Tag tag = (Tag) sourcetag_iterator.next();
                source_multimap.put(tag.getName(), tag.getValue());
            }
        }
        for (SwiftTagListBlock t : target_tagListBlock) {
            Iterator<Tag> targettag_iterator = t.tagIterator();

            while (targettag_iterator.hasNext()) {
                Tag tag = (Tag) targettag_iterator.next();
                target_multimap.put(tag.getName(), tag.getValue());
            }
        }

现在 multimap 有键值对单键多值。我想将记录显示为:

if(source_multimap.get(key).equals(target_multimap.get(key)))然后比较multimap中的值并打印与multimap不同的值。

您可以将 prowidesoftware 用于 wife 解析器依赖项,使用它您可以读取 mt 消息的所有块,并且每个 block.you 中的每个字段都可以比较所有内容。