Class MxParseUtils
- java.lang.Object
-
- com.prowidesoftware.swift.model.mx.MxParseUtils
-
public class MxParseUtils extends java.lang.Object
- Since:
- 9.1.2
-
-
Constructor Summary
Constructors Constructor Description MxParseUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
getBICFromDN(java.lang.String dn)
Distinguished Name structure: cn=name,ou=payment,o=bank,o=swift
Example: o=spxainjj,o=swiftstatic java.util.Optional<MxId>
identifyMessage(java.lang.String xml)
Takes an XML with an MX message and detects the specific message type parsing just the namespace from the Document element.static java.lang.String
makeXmlLenient(java.lang.String xml)
This method is intended to fix some malformed XML content that is not compliant with the XML specification to enable the parsing and processing of the payload to be lenient.
-
-
-
Method Detail
-
getBICFromDN
public static java.lang.String getBICFromDN(java.lang.String dn)
Distinguished Name structure: cn=name,ou=payment,o=bank,o=swift
Example: o=spxainjj,o=swift- Parameters:
dn
- the DN element content- Returns:
- returns capitalized "bank", in the example SPXAINJJ
-
identifyMessage
public static java.util.Optional<MxId> identifyMessage(java.lang.String xml)
Takes an XML with an MX message and detects the specific message type parsing just the namespace from the Document element. If the Document element is not present, or without the namespace or if the namespace url contains invalid content, then attempts to identify the message from the AppHdr. From the header tries to get the message type from the 'MsgDefIdr' that is present in the Business Application Header, and if that is not present tries to get the 'MsgName' assuming it is a legacy Application Header. If none of the above is present or cannot be parsed, then returns empty.Example of a recognizable Document element:
<Doc:Document xmlns:Doc="urn:swift:xsd:camt.003.001.04" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">The implementation is intended to be lightweight and efficient, based on
XMLStreamReader
- Returns:
- id with the detected MX message type or empty if it cannot be determined.
-
makeXmlLenient
public static java.lang.String makeXmlLenient(java.lang.String xml)
This method is intended to fix some malformed XML content that is not compliant with the XML specification to enable the parsing and processing of the payload to be lenient. For the moment, current implementation will just fix invalid case in the XML declaration, if present.- Parameters:
xml
- original XML content- Returns:
- modified XML content with the XML declaration fixed to be compliant with the XML specification
- Since:
- 9.3.9
-
-