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