-
-
Save apolichronopoulos/ab184196d3ae26d231b9bb031f1a9c5a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gr.datamation.swift.common.SwiftMessage; | |
import gr.datamation.swift.common.SwiftMessageEnvelope; | |
import gr.datamation.swift.processor.SwiftMsgProcessor; | |
import gr.datamation.swift.validator.SwiftMsgValidator; | |
import gr.datamation.swift.validator.SwiftValidObj; | |
public class TradeFinanceParse { | |
private static final String mt798string = "{1:F01ISSUGB2LAXXX0000000000}{2:I798REIMUS33AXXXN}{4:\n" + | |
":20:TRANS1234\n" + | |
":12:770\n" + | |
":77E:FOLLOWS THE ENCLOSED MESSAGE\n" + | |
":27A:1/2\n" + | |
":21A:CUSTOMER1234\n" + | |
":25F:FINAL\n" + | |
":13E:201410251250\n" + | |
":24D:TELE\n" + | |
":53C:/APPLCANT ACCOUNT\n" + | |
":71A:OTH\n" + | |
":73A:CHARGES INFORMATION\n" + | |
":25A:/SETTLEMENT CHARGES ACCOUNT\n" + | |
":58A:TESTBICC\n" + | |
":29T:OTHR/OTHER TRANSPORT MODE\n" + | |
":21E:REFERENCE CONTRACT NUMBER\n" + | |
":45C:UNDERTAKING\n" + | |
"CLAUSE\n" + | |
"OF\n" + | |
"THE\n" + | |
"APPLICANT\n" + | |
":29A:ALEXANDRAKIS ALEXANDROS\n" + | |
"AGIOY GEORGIOY 24\n" + | |
"ZOGRAFOY\n" + | |
"6948212121\n" + | |
":72Z:ADDITIONAL INFORMATION ABOUT\n" + | |
"THE BANK 1\n" + | |
"ADDITIONAL INFORMATION ABOUT\n" + | |
"THE BANK 2\n" + | |
":23X:EMAL/NARRATIVE\n" + | |
":29S:OTHR/PARTY IDENTIFIER\n" + | |
":29U:TESTBICA\n" + | |
"-}"; | |
public static void main(String[] args) { | |
SwiftMsgProcessor smp = new SwiftMsgProcessor("\n"); | |
SwiftMsgValidator smv = new SwiftMsgValidator("\n"); | |
try { | |
// parse default mt798 message | |
SwiftMessage envelope = smp.ParseMsgStringToObject(mt798string); | |
// get the enclosed message (in this case an mt770) | |
SwiftMessage enclosedMessage = ((SwiftMessageEnvelope) envelope).getEnclosedMessage(); | |
// validate the enclosed message | |
SwiftValidObj swiftValidObj = smv.validateMsg(enclosedMessage); | |
if (!swiftValidObj.hasErrors()) { | |
System.out.println("Message is valid"); | |
System.out.println(smp.BuildMsgStringFromObject(swiftValidObj.getSwiftMessages().get(0))); | |
} else { | |
System.out.println(swiftValidObj.getValidationErrorList()); | |
} | |
} catch (Exception e) { | |
e.printStackTrace(); | |
System.err.println("Message cannot be parsed"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment