public class MxParser
extends java.lang.Object
IMPORTANT: An MX message is conformed by a set of optional headers and a message payload or document with the actual specific MX message. The name of the envelope element that binds a Header to the message to which it applies is implementation/network specific and not part of the scope of the parser.
This parser has three main utilities;
ApplicationHeader
and the ISO BusinessApplicationHeaderV01
.Notice that support for MX in Prowide Core is limited. Complete model and parser implementation for each MX
message type is implemented into subclasses of AbstractMX
by
Prowide Integrator.
Modifier and Type | Class and Description |
---|---|
class |
MxParser.MxStructureInfo
Helper bean used by
analyzeMessage() to return
structure information from an MX message |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DOCUMENT_LOCALNAME |
static java.lang.String |
HEADER_LOCALNAME |
Constructor and Description |
---|
MxParser(java.io.File file)
Construct a parser for a file containing a single MX message
|
MxParser(java.io.InputStream stream)
Construct a parser for a stream containing a single MX message
|
MxParser(java.lang.String message)
Creates the parser initializing its content source from the given string.
|
Modifier and Type | Method and Description |
---|---|
MxParser.MxStructureInfo |
analizeMessage()
Deprecated.
use
analyzeMessage() instead |
MxParser.MxStructureInfo |
analyzeMessage()
Convenient API to get structure information from an MX message.
|
MxId |
detectMessage()
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 |
getBICFromDN(java.lang.String dn)
Distinguished Name structure: cn=name,ou=payment,o=bank,o=swift
Example: o=spxainjj,o=swift |
MxNode |
parse()
Non-namespace aware parse.
Parses the complete message content into an MxNode tree structure. |
ApplicationHeader |
parseApplicationHeader()
Parses the application header (SWIFT legacy) from the internal message source.
|
static ApplicationHeader |
parseApplicationHeader(MxNode tree)
Parses the application header (SWIFT legacy) from the parameter node.
|
BusinessApplicationHeaderV01 |
parseBusinessApplicationHeaderV01()
Parses the application header (ISO) from the internal message source.
|
static BusinessApplicationHeaderV01 |
parseBusinessApplicationHeaderV01(MxNode tree)
Parses the application header (ISO) from the parameter node.
|
BusinessHeader |
parseBusinessHeader()
Detects the type of header and parses it as a legacy SWIFT Application Header or ISO Business Application Header.
|
static BusinessHeader |
parseBusinessHeader(org.w3c.dom.Element e)
Parse the business header from an XML Element node
|
java.lang.String |
stripDocument()
Helper API to strip Document portion of message XML.
|
java.lang.String |
stripHeader()
Helper API to strip AppHdr portion of message XML.
|
public static final java.lang.String HEADER_LOCALNAME
public static final java.lang.String DOCUMENT_LOCALNAME
public MxParser(java.io.File file) throws java.io.IOException
file
- the file containing a single unit of a messagejava.io.IOException
- if an error occurs during the read of the filepublic MxParser(java.io.InputStream stream) throws java.io.IOException
stream
- non null stream containing a single unit of messagejava.io.IOException
public MxParser(java.lang.String message)
public MxNode parse()
MxNode
tree structure.
The parser should be initialized with a valid source.public BusinessHeader parseBusinessHeader()
public static BusinessHeader parseBusinessHeader(org.w3c.dom.Element e)
parseBusinessHeader()
public ApplicationHeader parseApplicationHeader()
parseBusinessHeader()
public static ApplicationHeader parseApplicationHeader(MxNode tree)
parseBusinessHeader()
public BusinessApplicationHeaderV01 parseBusinessApplicationHeaderV01()
parseBusinessHeader()
public static BusinessApplicationHeaderV01 parseBusinessApplicationHeaderV01(MxNode tree)
parseBusinessHeader()
public MxId detectMessage()
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
@Deprecated @ProwideDeprecated(phase3=SRU2020) public MxParser.MxStructureInfo analizeMessage()
analyzeMessage()
insteadpublic MxParser.MxStructureInfo analyzeMessage()
This can be helpful when the actual content of an XML is unknown and some preprocessing of the XML must be done in order to parse or validate its content properly.
The implementation is intended to be lightweight and efficient, based on XMLStreamReader
If the message contains more than one Document element, the first one will be picked. The same applies for the header, only the first AppHdr will be picked
public static java.lang.String getBICFromDN(java.lang.String dn)
dn
- the DN element contentpublic java.lang.String stripDocument()
This API is convenient when only the Document element of an MX message is needed and the wrapper/payload structure is unknown.
This implementation is intended to be lightweight and efficient so it actually
does a simple substring operation on the XML using information provided
by the result of analyzeMessage()
. The XML is not converted into DOM.
If the message contains more than one Document element the expected result is as follows:
public java.lang.String stripHeader()
This API is convenient when only the header element of an MX message is needed and the wrapper/payload structure is unknown.
To gather the header already parsed into objects see parseBusinessHeader()
This implementation is intended to be lightweight and efficient so it actually
does a simple substring operation on the XML using information provided
by the result of analyzeMessage()
. The XML is not converted into DOM.
If the message contains more than one AppHdr element the expected result is as follows: