How to Compare two Swift-MT message?

做~自己de王妃 提交于 2019-12-24 06:22:44

问题


I have two SWIFT files to compare containing different SWIFT messages. Is there any library to compare the SWIFT messages and show the exact difference between them?

I have a two SWIFT message as follows :

{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-}

and

{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-}

How do I compare these two SWIFT messages?

EDITED : I have used the following procedure to compare the records but stuck in comparing the values :

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

Now the multimap has the key-value pairs single key- multiple values. I want to display the record as :

if(source_multimap.get(key).equals(target_multimap.get(key))) then compare the values in both the multimap and print the values which are different with the multimap.


回答1:


you can use prowidesoftware for wife parser dependency and using this you can read all the block of mt message and each field's in each block.you can compare all things.



来源:https://stackoverflow.com/questions/36712698/how-to-compare-two-swift-mt-message

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!