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.
ApplicationHeader
and the ISO BusinessApplicationHeaderV01
.AbstractMX
by Prowide Integrator.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 java.lang.String |
DOCUMENT_LOCALNAME |
static java.lang.String |
HEADER_LOCALNAME |
Constructor and Description |
---|
MxParser()
Deprecated.
the generic constructor is discouraged, use a constructor with
specific source parameter instead
|
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()
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 |
MxPayload |
mx()
Deprecated.
|
MxNode |
parse()
Non-namespace aware parse.
Parses the complete message content into an MxNode tree structure. |
MxNode |
parse(java.io.InputStream stream)
Deprecated.
initialize the parser with the stream instead an call the generic
parse() method |
MxNode |
parse(java.io.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(org.w3c.dom.Element e)
Parse the business header from an XML Element node
|
MxPayload |
payload()
Deprecated.
use
stripDocument() and stripHeader() instead |
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
@Deprecated @ProwideDeprecated(phase4=_2018) public MxParser()
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)
@Deprecated @ProwideDeprecated(phase4=_2018) public MxNode parse(java.io.InputStream stream)
parse()
method@Deprecated @ProwideDeprecated(phase4=_2018) public MxNode parse(java.io.Reader reader) throws java.io.IOException
parse()
methodjava.io.IOException
public MxNode parse()
MxNode
tree structure.
The parser should be initialized with a valid source.@Deprecated @ProwideDeprecated(phase3=_2018) public MxPayload payload()
stripDocument()
and stripHeader()
insteadpublic BusinessHeader parseBusinessHeader()
null
if the content cannot be parsed or the header is not present in the XMLpublic static BusinessHeader parseBusinessHeader(org.w3c.dom.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 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 analizeMessage()
. 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 analizeMessage()
. The XML is not converted into DOM.
If the message contains more than one AppHdr element the expected result is as follows: