public abstract class AbstractMX extends AbstractMessage implements IDocument, JsonSerializable
This class provides the base container model for MX messages including an attribute for the header. Further it supports both versions for the header; the SWIFT Application Header (legacy) and the ISO Business Application Header.
Subclasses in Prowide Integrator SDK implement the Document portion of each specific MX message type.
Serialization of this model into XML text can be done for the with or without the header portion. When the header is set and included into the serialization, the container root element must be provided.
AbstractMT
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_ROOT_ELEMENT
Default root element when an MX is serialized as XML including both AppHdr and Document
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
document()
Get this message Document as an XML string.
|
java.lang.String |
document(java.lang.String prefix,
boolean includeXMLDeclaration)
Get this message Document as an XML string.
|
org.w3c.dom.Element |
element() |
static AbstractMX |
fromJson(java.lang.String json)
Creates an MX messages from its JSON representation.
|
BusinessHeader |
getBusinessHeader() |
abstract java.lang.String |
getBusinessProcess()
get the Alphabetic code in four positions (fixed length) identifying the Business Process
|
abstract java.lang.Class[] |
getClasses()
Get the classes associated with this message
|
abstract int |
getFunctionality()
Get the code identifying the Message Functionality
|
MxId |
getMxId()
Returns the MX message identification.
Composed by the business process, functionality, variant and version. |
abstract java.lang.String |
getNamespace()
Get the XML namespace of the message
|
abstract int |
getVariant()
Get the Message variant
|
abstract int |
getVersion()
Get the message version
|
java.lang.String |
header()
Get this message AppHdr as an XML string.
|
java.lang.String |
header(java.lang.String prefix,
boolean includeXMLDeclaration)
Get this message AppHdr as an XML string.
|
java.lang.String |
message()
Get this message as an XML string.
|
java.lang.String |
message(java.lang.String rootElement)
Same as
message(String, boolean) with includeXMLDeclaration set to true |
java.lang.String |
message(java.lang.String rootElement,
boolean includeXMLDeclaration)
Get this message as an XML string.
|
static AbstractMX |
parse(java.io.File file,
MxId id)
Parses a file content into a specific instance of Mx.
|
static AbstractMX |
parse(java.lang.String xml,
MxId id)
Parses the XML string containing the Document element of an MX message into a specific instance of MX message object.
|
void |
setBusinessHeader(BusinessHeader businessHeader) |
java.lang.String |
toJson()
Get a JSON representation of this MX message.
|
void |
write(java.io.File file)
Writes the message document content into a file in XML format (headers not included).
|
void |
write(java.io.OutputStream stream)
Writes the message document content into a file in XML format, encoding content in UTF-8 (headers not included).
|
javax.xml.transform.Source |
xmlSource()
Convenience method to get this message XML as javax.xml.transform.Source.
|
getMessageStandardType, isMT, isMX
public static java.lang.String DEFAULT_ROOT_ELEMENT
public abstract java.lang.Class[] getClasses()
public abstract java.lang.String getNamespace()
public abstract java.lang.String getBusinessProcess()
public abstract int getFunctionality()
public abstract int getVariant()
public abstract int getVersion()
public java.lang.String message()
If the header is present, then 'AppHdr' and 'Document' elements will be wrapped under a
DEFAULT_ROOT_ELEMENT
Both header and documents are generated with the corresponding namespaces and by default the prefix 'h' is
used for the header and the prefix 'Doc' for the document.
message
in class AbstractMessage
message(String, boolean)
public java.lang.String message(java.lang.String rootElement, boolean includeXMLDeclaration)
If the business header is set, the created XML will include both the 'AppHdr' and the 'Document' elements,
under a the indicated or default root element.
If the header is not present, the created XMl will only include the 'Document'.
Both 'AppHdr' and 'Document' are generated with namespace declaration and default prefixes 'h' and 'Doc'
respectively.
IMPORTANT: The name of the envelope element that binds a Header to the message to which it applies is implementation/network specific. The header root element ‘AppHdr’ and the ISO 20022 MessageDefinition root element ‘Document’ must always be sibling elements in any XML document, with the AppHdr element preceding the Document element.
rootElement
- optional specification of the root element if not provided DEFAULT_ROOT_ELEMENT
is usedincludeXMLDeclaration
- true to include the XML declarationpublic java.lang.String message(java.lang.String rootElement)
message(String, boolean)
with includeXMLDeclaration set to truepublic java.lang.String header()
The XML will not include the XML declaration, and will include de namespace as default (without prefix).
header(String, boolean)
public java.lang.String header(java.lang.String prefix, boolean includeXMLDeclaration)
prefix
- optional prefix for namespace (empty by default)includeXMLDeclaration
- true to include the XML declarationpublic java.lang.String document()
The XML will include the XML declaration, and will use "Doc" as prefix for the elements.
document(String, boolean)
public java.lang.String document(java.lang.String prefix, boolean includeXMLDeclaration)
prefix
- optional prefix for namespace (empty by default)includeXMLDeclaration
- true to include the XML declarationpublic javax.xml.transform.Source xmlSource()
message()
public void write(java.io.File file) throws java.io.IOException
file
- a not null file to write, if it does not exists, it will be createdjava.io.IOException
public void write(java.io.OutputStream stream) throws java.io.IOException
stream
- a non null stream to writejava.io.IOException
- if the stream cannot be writtenpublic BusinessHeader getBusinessHeader()
public void setBusinessHeader(BusinessHeader businessHeader)
businessHeader
- the header to setpublic MxId getMxId()
public org.w3c.dom.Element element()
public static AbstractMX parse(java.lang.String xml, MxId id)
MxParser
xml
- string a string containing the Document of an MX message in XML formatid
- optional parameter to indicate the specific MX type to create; autodetected from namespace if null.public static AbstractMX parse(java.io.File file, MxId id) throws java.io.IOException
MxParser
file
- a file containing a swift MX messageid
- optional parameter to indicate the specific MX type to create; autodetected from namespace if null.java.io.IOException
- if the file cannot be writtenparse(String, MxId)
public java.lang.String toJson()
toJson
in interface JsonSerializable
public static AbstractMX fromJson(java.lang.String json)
json
- a JSON representation of an MX message