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 | Constructor and Description |
---|---|
protected |
AbstractMX() |
protected |
AbstractMX(BusinessHeader businessHeader) |
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.
|
protected static <T> T |
fromJson(java.lang.String json,
java.lang.Class<T> classOfT)
Used by subclasses to implement JSON deserialization.
|
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 business header as an XML string.
|
java.lang.String |
header(java.lang.String prefix,
boolean includeXMLDeclaration)
Get this message business header as an XML string.
|
java.lang.String |
message()
Get this message document as an XML string (headers not included).
|
java.lang.String |
message(java.lang.String rootElement)
Same as
message(String) with includeXMLDeclaration set to true |
protected static java.lang.String |
message(java.lang.String namespace,
AbstractMX obj,
java.lang.Class[] classes,
java.lang.String prefix,
boolean includeXMLDeclaration) |
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.
|
protected static AbstractMX |
read(java.lang.Class<? extends AbstractMX> targetClass,
java.lang.String xml,
java.lang.Class[] classes) |
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
protected AbstractMX()
protected AbstractMX(BusinessHeader businessHeader)
protected static java.lang.String message(java.lang.String namespace, AbstractMX obj, java.lang.Class[] classes, java.lang.String prefix, boolean includeXMLDeclaration)
protected static AbstractMX read(java.lang.Class<? extends AbstractMX> targetClass, java.lang.String xml, java.lang.Class[] classes)
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()
message(String, boolean)
public java.lang.String message(java.lang.String rootElement, boolean includeXMLDeclaration)
rootElement
- optional specification of the root elementpublic java.lang.String message(java.lang.String rootElement)
message(String)
with includeXMLDeclaration set to truepublic java.lang.String header()
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 declaration (false by default)BusinessHeader.xml(String, boolean)
public java.lang.String document()
message()
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 declaration (false by default)public 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
protected 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 message