public abstract class AbstractMX
extends com.prowidesoftware.swift.model.AbstractMessage
implements com.prowidesoftware.JsonSerializable
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 this model.
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.
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
|
static java.lang.String |
DOCUMENT_LOCALNAME |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractMX() |
protected |
AbstractMX(AppHdr appHdr) |
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
document()
Get this message Document as an XML string.
|
java.lang.String |
document(MxWriteParams params)
Get this message Document as an XML string.
|
java.lang.String |
document(java.lang.String prefix,
boolean includeXMLDeclaration)
Deprecated.
use
document(MxWriteParams) instead |
java.lang.String |
document(java.lang.String prefix,
boolean includeXMLDeclaration,
EscapeHandler escapeHandler)
Deprecated.
use
document(MxWriteParams) instead |
org.w3c.dom.Element |
element() |
static AbstractMX |
fromJson(java.lang.String json)
Creates an MX messages from its JSON representation.
|
protected static <T> T |
fromJson(java.lang.String json,
java.lang.Class<T> classOfT)
Used by subclasses to implement JSON deserialization.
|
AppHdr |
getAppHdr() |
BusinessHeader |
getBusinessHeader()
Deprecated.
use
getAppHdr() instead |
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(MxWriteParams params)
Get this message AppHdr as an XML string.
|
java.lang.String |
header(java.lang.String prefix,
boolean includeXMLDeclaration)
Deprecated.
use
header(MxWriteParams) instead |
java.lang.String |
header(java.lang.String prefix,
boolean includeXMLDeclaration,
EscapeHandler escapeHandler)
Deprecated.
use
header(MxWriteParams) instead |
java.lang.String |
message()
Get this message as an XML string.
|
java.lang.String |
message(MxWriteConfiguration conf)
Get this message as an XML string.
|
java.lang.String |
message(java.lang.String rootElement)
Deprecated.
use
message(MxWriteConfiguration) instead |
protected static java.lang.String |
message(java.lang.String namespace,
AbstractMX obj,
java.lang.Class[] classes,
java.lang.String prefix,
boolean includeXMLDeclaration)
Deprecated.
|
protected static java.lang.String |
message(java.lang.String namespace,
AbstractMX obj,
java.lang.Class[] classes,
java.lang.String prefix,
boolean includeXMLDeclaration,
EscapeHandler escapeHandler)
Deprecated.
|
java.lang.String |
message(java.lang.String rootElement,
boolean includeXMLDeclaration)
Deprecated.
use
message(MxWriteConfiguration) instead |
static AbstractMX |
parse(org.w3c.dom.Element e)
Parses the XML Element into a specific MX object.
|
static AbstractMX |
parse(java.io.File file,
MxId id)
Deprecated.
use Lib.readFile(file) and any parse from String method
|
static AbstractMX |
parse(java.lang.String xml)
Parses the XML string containing the Document and optional AppHdr into a specific instance of MX message object.
|
static AbstractMX |
parse(java.lang.String xml,
MxId id)
Parses the XML string containing the Document and optional AppHdr into a specific instance of MX message object.
|
static AbstractMX |
parse(java.lang.String xml,
MxId id,
MxReadConfiguration conf)
Parses the XML string containing the Document and optional AppHdr into a specific instance of MX message object.
|
protected static AbstractMX |
read(java.lang.Class<? extends AbstractMX> targetClass,
java.lang.String xml,
java.lang.Class[] classes)
Deprecated.
use any of the available parse methods instead in either this class or the specific subclasses
|
void |
setAppHdr(AppHdr appHdr) |
void |
setBusinessHeader(BusinessHeader businessHeader)
Deprecated.
use
setAppHdr(AppHdr) instead |
java.lang.String |
targetNamespace() |
java.lang.String |
toJson()
Get a JSON representation of this MX message.
|
void |
write(java.io.File file)
Deprecated.
use
message(MxWriteConfiguration) and handle write from String to file with plain Java API |
void |
write(java.io.OutputStream stream)
Deprecated.
use
message(MxWriteConfiguration) and handle write from String to stream with plain Java API |
javax.xml.transform.Source |
xmlSource()
Convenience method to get this message XML as javax.xml.transform.Source.
|
public static final java.lang.String DOCUMENT_LOCALNAME
public static java.lang.String DEFAULT_ROOT_ELEMENT
protected AbstractMX()
protected AbstractMX(AppHdr appHdr)
@Deprecated
@ProwideDeprecated(phase3=SRU2023)
protected static java.lang.String message(java.lang.String namespace,
AbstractMX obj,
java.lang.Class[] classes,
java.lang.String prefix,
boolean includeXMLDeclaration)
MxWriteImpl.write(String, AbstractMX, Class[], MxWriteParams) instead.@Deprecated
@ProwideDeprecated(phase3=SRU2023)
protected static java.lang.String message(java.lang.String namespace,
AbstractMX obj,
java.lang.Class[] classes,
java.lang.String prefix,
boolean includeXMLDeclaration,
EscapeHandler escapeHandler)
MxWriteImpl.write(String, AbstractMX, Class[], MxWriteParams) instead@Deprecated @ProwideDeprecated(phase2=SRU2023) protected static AbstractMX read(java.lang.Class<? extends AbstractMX> targetClass, java.lang.String xml, java.lang.Class[] classes)
public static AbstractMX parse(java.lang.String xml)
The unmarshaller uses the default type adapters. For more parse options use parse(String, MxId, MxReadConfiguration).
xml - the XML content to parsepublic static AbstractMX parse(java.lang.String xml, MxId id)
If the string is empty, does not contain an MX document, the message type cannot be detected or an error occur reading and parsing the message content; this method returns null.
The implementation detects the message type and uses reflection to call the parser in the specific subclass.
The unmarshaller uses the default type adapters. For more parse options use parse(String, MxId, MxReadConfiguration).
xml - string a string containing the Document of an MX message in XML formatid - optional parameter to indicate the specific MX type to create; auto detected from namespace if null.public static AbstractMX parse(java.lang.String xml, MxId id, MxReadConfiguration conf)
If the string is empty, does not contain an MX document, the message type cannot be detected or an error occur reading and parsing the message content; this method returns null.
The implementation detects the message type and uses reflection to call the parser in the specific subclass.
xml - string a string containing the Document of an MX message in XML formatid - optional parameter to indicate the specific MX type to create; auto detected from namespace if null.conf - specific options for the unmarshalling or null to use the default parameters@Deprecated @ProwideDeprecated(phase2=SRU2023) public static AbstractMX parse(java.io.File file, MxId id) throws java.io.IOException
java.io.IOExceptionpublic static AbstractMX parse(org.w3c.dom.Element e)
e - content to parseprotected static <T> T fromJson(java.lang.String json,
java.lang.Class<T> classOfT)
json - a JSON representation of an MX messageclassOfT - the specific MX subclasspublic static AbstractMX fromJson(java.lang.String json)
json - a JSON representation of an MX messagepublic 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 document are generated with the corresponding namespaces and by
default the prefix 'h' is used for the header and the prefix 'Doc' for the document.
For more serialization options see message(MxWriteConfiguration)
To serialize only the header or the document (without header) see header() and document()
message in class com.prowidesoftware.swift.model.AbstractMessage@Deprecated
@ProwideDeprecated(phase3=SRU2023)
public java.lang.String message(java.lang.String rootElement,
boolean includeXMLDeclaration)
message(MxWriteConfiguration) instead@Deprecated @ProwideDeprecated(phase3=SRU2023) public java.lang.String message(java.lang.String rootElement)
message(MxWriteConfiguration) insteadpublic java.lang.String message(MxWriteConfiguration conf)
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 if optional prefixes if present in the configuration.
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.
conf - specific options for the serialization or null to use the default parameterspublic java.lang.String header()
The XML will not include the XML declaration, will bind the namespace to all elements without prefix and will use the default escape handler and content adapters.
For more serialization options use header(MxWriteParams)
@Deprecated
@ProwideDeprecated(phase3=SRU2023)
public java.lang.String header(java.lang.String prefix,
boolean includeXMLDeclaration)
header(MxWriteParams) instead@Deprecated
@ProwideDeprecated(phase3=SRU2023)
public java.lang.String header(java.lang.String prefix,
boolean includeXMLDeclaration,
EscapeHandler escapeHandler)
header(MxWriteParams) insteadpublic java.lang.String header(MxWriteParams params)
public java.lang.String document()
The XML will not include the XML declaration, will bind the namespace to all elements using "Doc" as default
prefix and will use the default escape handler. For more serialization options use document(MxWriteParams)
@Deprecated
@ProwideDeprecated(phase3=SRU2023)
public java.lang.String document(java.lang.String prefix,
boolean includeXMLDeclaration)
document(MxWriteParams) instead@Deprecated
@ProwideDeprecated(phase2=SRU2023)
public java.lang.String document(java.lang.String prefix,
boolean includeXMLDeclaration,
EscapeHandler escapeHandler)
document(MxWriteParams) insteadpublic java.lang.String document(MxWriteParams params)
params - not null marshalling parameterspublic javax.xml.transform.Source xmlSource()
message()@Deprecated
@ProwideDeprecated(phase2=SRU2023)
public void write(java.io.File file)
throws java.io.IOException
message(MxWriteConfiguration) and handle write from String to file with plain Java APIjava.io.IOException@Deprecated
@ProwideDeprecated(phase2=SRU2023)
public void write(java.io.OutputStream stream)
throws java.io.IOException
message(MxWriteConfiguration) and handle write from String to stream with plain Java APIjava.io.IOException@Deprecated @ProwideDeprecated(phase4=SRU2023) public BusinessHeader getBusinessHeader()
getAppHdr() instead@ProwideDeprecated(phase4=SRU2023) @Deprecated public void setBusinessHeader(BusinessHeader businessHeader)
setAppHdr(AppHdr) insteadbusinessHeader - the header to setpublic AppHdr getAppHdr()
public void setAppHdr(AppHdr appHdr)
appHdr - the header to setpublic MxId getMxId()
public org.w3c.dom.Element element()
public java.lang.String toJson()
toJson in interface com.prowidesoftware.JsonSerializablepublic java.lang.String targetNamespace()
getNamespace()