1

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.

André Gasser
  • 1,065
  • 2
  • 14
  • 34
rockersdeal
  • 71
  • 12

1 Answers1

-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.

Sumeet Tiwari
  • 343
  • 2
  • 11
  • I used the WIFE Provide core. Can you please help me on the multimap scenario. or you can check this here also : http://stackoverflow.com/q/37025495/5599600 – rockersdeal May 04 '16 at 13:00
  • till now i didn't try with multimap but i would like to suggest you from SwiftMessage you have to create object particular fields by using java reflection concept by passing the method name.But first check that block should be not null. – Sumeet Tiwari May 04 '16 at 13:13