Class MxSwiftMessage
- java.lang.Object
-
- com.prowidesoftware.swift.model.AbstractSwiftMessage
-
- com.prowidesoftware.swift.model.MxSwiftMessage
-
- All Implemented Interfaces:
com.prowidesoftware.JsonSerializable
,java.io.Serializable
@Entity(name="mx") public class MxSwiftMessage extends com.prowidesoftware.swift.model.AbstractSwiftMessage
MX (ISO 20022) messages entity for JPA persistence.The class holds the full xml content plus message identification metadata gathered from the application header.
Notice, the scope of Prowide MX model is the message payload (the actual message or body data) which is the fundamental purpose of the transmission. The transmission wrappers (overhead data) are excluded and intentionally ignored if found.
MX messages are uniquely identify by their business process, message functionality, variant and version.
Consider the following example: trea.001.001.02- trea refers to 'Treasury'
- 001 refers to 'NDF opening (notification)'
- 001 refers to the variant
- 02 refers to the version message format, in this case version 2 of 'NDF opening' type.
businessProcess: Alphabetic code in four positions (fixed length) identifying the Business Process
functionality: Alphanumeric code in three positions (fixed length) identifying the Message Functionality
variant: Numeric code in three positions (fixed length) identifying a particular flavor (variant) of Message Functionality
version: Numeric code in two positions (fixed length) identifying the version.- Since:
- 7.0
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description MxSwiftMessage()
MxSwiftMessage(AbstractMX mx)
MxSwiftMessage(AbstractMX mx, com.prowidesoftware.swift.model.MessageMetadataStrategy metadataStrategy)
Creates a new message serializing to xml the parameter message object.MxSwiftMessage(java.io.File file)
MxSwiftMessage(java.io.File file, com.prowidesoftware.swift.model.MessageMetadataStrategy metadataStrategy)
Creates a new message reading the message the content from a file.MxSwiftMessage(java.io.InputStream stream)
MxSwiftMessage(java.io.InputStream stream, com.prowidesoftware.swift.model.MessageMetadataStrategy metadataStrategy)
Creates a new message reading the message the content from an input stream.MxSwiftMessage(java.lang.String xml)
MxSwiftMessage(java.lang.String xml, com.prowidesoftware.swift.model.MessageMetadataStrategy metadataStrategy)
Creates a new message reading the message the content from a string.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
copyTo(MxSwiftMessage msg)
Creates a full copy of the current message object into another message.boolean
equals(java.lang.Object o)
static MxSwiftMessage
fromJson(java.lang.String json)
This method deserializes the JSON data into an MX message object.AppHdr
getAppHdr()
If present in the message content, returns the business header (SWIFT or ISO version) Notice this header is optional and may not be present.MxBusinessProcess
getBusinessProcess()
java.lang.String
getCategory()
For MT messages returns the category number and for MX messages return the business process.java.lang.String
getFunctionality()
MxId
getMxId()
Returns this message MX identificationjava.lang.String
getVariant()
java.lang.String
getVersion()
int
hashCode()
static MxSwiftMessage
parse(java.io.File file)
Creates a new message reading the message the content from a file.static MxSwiftMessage
parse(java.io.InputStream stream)
Creates a new message reading the message the content from an input stream.static MxSwiftMessage
parse(java.lang.String xml)
Creates a new message reading the message the content from a string.void
setBusinessProcess(MxBusinessProcess businessProcess)
void
setFunctionality(java.lang.String functionality)
void
setVariant(java.lang.String variant)
void
setVersion(java.lang.String version)
java.lang.String
toString()
protected void
updateFromMessage()
protected void
updateFromMessage(com.prowidesoftware.swift.model.MessageMetadataStrategy metadataStrategy)
Updates the object attributes with metadata parsed from the message raw content using the provided strategy implementation for several of the metadata fields.void
updateFromModel(AbstractMX mx)
Updates the attributes with the raw message and its metadata from the given raw (XML) message content.void
updateFromModel(AbstractMX mx, com.prowidesoftware.swift.model.MessageMetadataStrategy metadataStrategy)
void
updateFromXML(java.lang.String xml)
void
updateFromXML(java.lang.String xml, MxId id)
void
updateFromXML(java.lang.String xml, MxId id, com.prowidesoftware.swift.model.MessageMetadataStrategy metadataStrategy)
Updates the the attributes with the raw message and its metadata from the given raw (XML) message content.void
updateMetadata(com.prowidesoftware.swift.model.MessageMetadataStrategy strategy)
Enables injecting your own implementation for the entity metadata extraction, to set the generic properties shared by all message types: main reference, main amount and currency, value date, trade date.-
Methods inherited from class com.prowidesoftware.swift.model.AbstractSwiftMessage
addNote, addRevision, addStatus, bic11, contains, contains, copyTo, createRevision, findStatusInfo, findStatusInfo, findStatusInfoLast, findStatusInfoLast, formattedAmount, formattedAmount, getAmount, getChecksum, getChecksumBody, getCorrespondentBIC, getCreationDate, getCreationDayOfMonth, getCreationMonth, getCreationYear, getCurrency, getDirection, getFileFormat, getFilename, getId, getIdentifier, getLastData, getLastData, getLastModified, getMessage, getMessageName, getMessageType, getNotes, getPaddedId, getPreviousStatusInfo, getProperties, getProperty, getProperty, getPropertyBoolean, getPropertyBoolean, getReceiver, getReference, getRevisions, getSender, getStatus, getStatusInfo, getStatusTrail, getTradeDate, getValueDate, identifiedAsACK, identifiedAsNAK, isIncoming, isInput, isMT, isMX, isOutgoing, isOutput, isStatus, isStatus, isStatus, isStatus, match, message, messageStandardType, propertyEquals, propertyEquals, propertyEquals, sanityCheckProperties, setAmount, setChecksum, setChecksumBody, setCreationDate, setCurrency, setDirection, setFileFormat, setFilename, setId, setIdentifier, setLastModified, setMessage, setNotes, setProperties, setProperty, setProperty, setReceiver, setReference, setRevisions, setSender, setStatus, setStatus, setStatusTrail, setTradeDate, setValueDate, toJson, toJsonImpl
-
-
-
-
Constructor Detail
-
MxSwiftMessage
public MxSwiftMessage()
-
MxSwiftMessage
public MxSwiftMessage(java.lang.String xml)
-
MxSwiftMessage
public MxSwiftMessage(java.lang.String xml, com.prowidesoftware.swift.model.MessageMetadataStrategy metadataStrategy)
Creates a new message reading the message the content from a string.Performs a fast parsing of the header to identify the message.
If the string contains several messages, the whole passed content will be save in the message attribute but identification and metadata will be parser from the first one found only.
- Parameters:
xml
- the plain ISO 20022 XML content, with or without the optional headermetadataStrategy
- a strategy for metadata extraction- Since:
- 9.1.6
-
MxSwiftMessage
public MxSwiftMessage(java.io.InputStream stream) throws java.io.IOException
- Throws:
java.io.IOException
- Since:
- 7.7
-
MxSwiftMessage
public MxSwiftMessage(java.io.InputStream stream, com.prowidesoftware.swift.model.MessageMetadataStrategy metadataStrategy) throws java.io.IOException
Creates a new message reading the message the content from an input stream.- Parameters:
stream
- a stream containing the XML messagemetadataStrategy
- a strategy for metadata extraction- Throws:
java.io.IOException
- Since:
- 9.1.6
-
MxSwiftMessage
public MxSwiftMessage(java.io.File file) throws java.io.IOException
- Throws:
java.io.IOException
- Since:
- 7.7
-
MxSwiftMessage
public MxSwiftMessage(java.io.File file, com.prowidesoftware.swift.model.MessageMetadataStrategy metadataStrategy) throws java.io.IOException
Creates a new message reading the message the content from a file.- Parameters:
file
- an existing file containing the XMLmetadataStrategy
- a strategy for metadata extraction- Throws:
java.io.IOException
- Since:
- 9.1.6
-
MxSwiftMessage
public MxSwiftMessage(AbstractMX mx)
- Parameters:
mx
- a message object
-
MxSwiftMessage
public MxSwiftMessage(AbstractMX mx, com.prowidesoftware.swift.model.MessageMetadataStrategy metadataStrategy)
Creates a new message serializing to xml the parameter message object.If the business header is present, the sender and receiver attributes will be set with content from the header; also the internal raw XML will include both 'AppHdr' and 'Document' under a default root element tag as returned by
AbstractMX.message()
If the header is not present, sender and receiver will be left null and the raw internal XML will include just the 'Document' element.- Parameters:
mx
- a message objectmetadataStrategy
- a strategy for metadata extraction- Since:
- 9.1.6
-
-
Method Detail
-
parse
public static MxSwiftMessage parse(java.lang.String xml)
Creates a new message reading the message the content from a string. This is a static version of the constructorMxSwiftMessage(String)
- Since:
- 7.7
-
parse
public static MxSwiftMessage parse(java.io.InputStream stream) throws java.io.IOException
Creates a new message reading the message the content from an input stream. This is a static version of the constructorMxSwiftMessage(InputStream)
- Throws:
java.io.IOException
- Since:
- 7.7
-
parse
public static MxSwiftMessage parse(java.io.File file) throws java.io.IOException
Creates a new message reading the message the content from a file. This is a static version of the constructorMxSwiftMessage(File)
- Throws:
java.io.IOException
- Since:
- 7.7
-
fromJson
public static MxSwiftMessage fromJson(java.lang.String json)
This method deserializes the JSON data into an MX message object.- Since:
- 7.10.3
- See Also:
AbstractSwiftMessage.toJson()
-
updateFromMessage
protected void updateFromMessage()
- Specified by:
updateFromMessage
in classcom.prowidesoftware.swift.model.AbstractSwiftMessage
- Since:
- 7.7
-
updateFromMessage
protected void updateFromMessage(com.prowidesoftware.swift.model.MessageMetadataStrategy metadataStrategy)
Updates the object attributes with metadata parsed from the message raw content using the provided strategy implementation for several of the metadata fields. The method is called during message creation or update.- Overrides:
updateFromMessage
in classcom.prowidesoftware.swift.model.AbstractSwiftMessage
- Since:
- 9.1.6
-
updateFromModel
public void updateFromModel(AbstractMX mx)
Updates the attributes with the raw message and its metadata from the given raw (XML) message content.- Parameters:
mx
- the new message content- Since:
- 7.8.4
- See Also:
updateFromMessage()
-
updateFromModel
public void updateFromModel(AbstractMX mx, com.prowidesoftware.swift.model.MessageMetadataStrategy metadataStrategy)
-
updateFromXML
public void updateFromXML(java.lang.String xml)
- Since:
- 7.8.4
-
updateFromXML
public void updateFromXML(java.lang.String xml, MxId id)
- Since:
- 7.8.4
-
updateFromXML
public void updateFromXML(java.lang.String xml, MxId id, com.prowidesoftware.swift.model.MessageMetadataStrategy metadataStrategy)
Updates the the attributes with the raw message and its metadata from the given raw (XML) message content. Wrapper around AppHdr/Document, if present, are preserved and ignored.- Parameters:
xml
- the XML content of an MX message containing the Document and optional AppHdr elementsid
- the specific Mx type identification or null if message is unknownmetadataStrategy
- the strategy implementation to use for metadata extraction- Since:
- 9.1.6
-
getBusinessProcess
public MxBusinessProcess getBusinessProcess()
-
setBusinessProcess
public void setBusinessProcess(MxBusinessProcess businessProcess)
-
getFunctionality
public java.lang.String getFunctionality()
-
setFunctionality
public void setFunctionality(java.lang.String functionality)
-
getVariant
public java.lang.String getVariant()
-
setVariant
public void setVariant(java.lang.String variant)
-
getVersion
public java.lang.String getVersion()
-
setVersion
public void setVersion(java.lang.String version)
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classcom.prowidesoftware.swift.model.AbstractSwiftMessage
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classcom.prowidesoftware.swift.model.AbstractSwiftMessage
-
getAppHdr
public AppHdr getAppHdr()
If present in the message content, returns the business header (SWIFT or ISO version) Notice this header is optional and may not be present.- Returns:
- found header or null if not present or cannot be parsed into a header object
- Since:
- 9.0.1
- See Also:
AppHdrParser.parse(String)
-
copyTo
public void copyTo(MxSwiftMessage msg)
Creates a full copy of the current message object into another message.- Parameters:
msg
- target message- Since:
- 7.7
- See Also:
AbstractSwiftMessage.copyTo(AbstractSwiftMessage)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
- Since:
- 7.8.6
-
getMxId
public MxId getMxId()
Returns this message MX identification- Returns:
- the identification object for this message
- Since:
- 7.10.4
-
getCategory
public java.lang.String getCategory()
For MT messages returns the category number and for MX messages return the business process. For example for MT103 returns 1 and for pacs.004.001.06 returns pacs- Specified by:
getCategory
in classcom.prowidesoftware.swift.model.AbstractSwiftMessage
- Returns:
- a string with the category or empty if the identifier is invalid or not present
- Since:
- 7.10.4
-
updateMetadata
public void updateMetadata(com.prowidesoftware.swift.model.MessageMetadataStrategy strategy)
Enables injecting your own implementation for the entity metadata extraction, to set the generic properties shared by all message types: main reference, main amount and currency, value date, trade date.- Since:
- 9.1.6
-
-