public class MxParser extends 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.
ApplicationHeader
and the ISO BusinessApplicationHeaderV01
.AbstractMX
by Prowide Integrator SDK.Modifier and Type | Class and Description |
---|---|
class |
MxParser.MxStructureInfo
Helper bean used by
analizeMessage() to return
structure information from an MX message |
Modifier and Type | Field and Description |
---|---|
static String |
DOCUMENT_LOCALNAME |
static String |
HEADER_LOCALNAME |
Constructor and Description |
---|
MxParser()
Deprecated.
the generic constructor is discouraged, use a constructor with
specific source parameter instead
|
MxParser(File file)
Construct a parser for a file containing a single MX message
|
MxParser(InputStream stream)
Construct a parser for a stream containing a single MX message
|
MxParser(String message)
Creates the parser initializing its content source from the given string.
|
Modifier and Type | Method and Description |
---|---|
MxParser.MxStructureInfo |
analizeMessage()
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 String |
getBICFromDN(String dn)
Distinguished Name structure: cn=name,ou=payment,o=bank,o=swift
Example: o=spxainjj,o=swift |
MxPayload |
mx()
Deprecated.
|
MxNode |
parse()
Non-namespace aware parse.
Parses the complete message content into an MxNode tree structure. |
MxNode |
parse(InputStream stream)
Deprecated.
initialize the parser with the stream instead an call the generic
parse() method |
MxNode |
parse(Reader reader)
Deprecated.
initialize the parser with the reader instead an call the generic
parse() method |
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(Element e)
Parse the business header from an XML Element node
|
MxPayload |
payload()
Deprecated.
use
stripDocument() and stripHeader() instead |
String |
stripDocument()
Helper API to strip Document portion of message XML.
|
String |
stripHeader()
Helper API to strip AppHdr portion of message XML.
|
public static final String HEADER_LOCALNAME
public static final String DOCUMENT_LOCALNAME
@Deprecated @ProwideDeprecated(phase4=_2018) public MxParser()
public MxParser(File file) throws IOException
file
- the file containing a single unit of a messageIOException
- if an error occurs during the read of the filepublic MxParser(InputStream stream) throws IOException
stream
- non null stream containing a single unit of messageIOException
public MxParser(String message)
@Deprecated @ProwideDeprecated(phase4=_2018) public MxNode parse(InputStream stream)
parse()
method@Deprecated @ProwideDeprecated(phase4=_2018) public MxNode parse(Reader reader) throws IOException
parse()
methodIOException
public MxNode parse()
MxNode
tree structure.
The parser should be initialized with a valid source.@Deprecated @ProwideDeprecated(phase3=_2018) public MxPayload payload()
public BusinessHeader parseBusinessHeader()
null
if the content cannot be parsed or the header is not present in the XMLpublic static BusinessHeader parseBusinessHeader(Element e)
parseBusinessHeader()
public ApplicationHeader parseApplicationHeader()
null
if the content cannot be parsed or the header is not present in the XMLparseBusinessHeader()
public static ApplicationHeader parseApplicationHeader(MxNode tree)
null
if the content cannot be parsed or the header is not present in the XMLparseBusinessHeader()
public BusinessApplicationHeaderV01 parseBusinessApplicationHeaderV01()
null
if the content cannot be parsed or the header is not present in the XMLparseBusinessHeader()
public static BusinessApplicationHeaderV01 parseBusinessApplicationHeaderV01(MxNode tree)
null
if the content cannot be parsed or the header is not present in the XMLparseBusinessHeader()
public MxId detectMessage()
XMLStreamReader
public MxParser.MxStructureInfo analizeMessage()
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
@Deprecated @ProwideDeprecated(phase3=_2018) public MxPayload mx()
public static String getBICFromDN(String dn)
dn
- the DN element contentpublic 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 analizeMessage()
. The XML is not converted into DOM.
If the message contains more than one Document element the expected result is as follows:
public 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 analizeMessage()
. The XML is not converted into DOM.
If the message contains more than one AppHdr element the expected result is as follows: