Package com.prowidesoftware.swift.model
Class MtSwiftMessage
- java.lang.Object
-
- com.prowidesoftware.swift.model.AbstractSwiftMessage
-
- com.prowidesoftware.swift.model.MtSwiftMessage
-
- All Implemented Interfaces:
JsonSerializable
,java.io.Serializable
@Entity(name="mt") public class MtSwiftMessage extends AbstractSwiftMessage
MT messages entity for JPA persistence.Contains the raw FIN message content plus metadata shared by all MT types.
- Since:
- 7.0
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class com.prowidesoftware.swift.model.AbstractSwiftMessage
identifier, IDENTIFIER_ACK, IDENTIFIER_NAK, PROPERTY_NAME, receiver, sender
-
-
Constructor Summary
Constructors Constructor Description MtSwiftMessage()
MtSwiftMessage(AbstractMT mt)
MtSwiftMessage(AbstractMT mt, MessageMetadataStrategy metadataStrategy)
Creates an MtSwiftMessage from a subclass ofAbstractMT
.MtSwiftMessage(SwiftMessage model)
MtSwiftMessage(SwiftMessage model, MessageMetadataStrategy metadataStrategy)
Creates an MtSwiftMessage from a SwiftMessage.MtSwiftMessage(java.io.File file)
MtSwiftMessage(java.io.File file, MessageMetadataStrategy metadataStrategy)
Creates a new message reading the message the content from a file.MtSwiftMessage(java.io.InputStream stream)
MtSwiftMessage(java.io.InputStream stream, MessageMetadataStrategy metadataStrategy)
Creates a new message reading the message the content from an input stream.MtSwiftMessage(java.lang.String fin)
MtSwiftMessage(java.lang.String fin, MessageMetadataStrategy metadataStrategy)
Creates a new MT entity reading the message content from the plain message content.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
copyTo(MtSwiftMessage msg)
Creates a full copy of the current message object into another message.boolean
equals(java.lang.Object o)
static MtSwiftMessage
fromJson(java.lang.String json)
This method deserializes the JSON data into an MT message object.java.lang.String
getCategory()
For MT messages returns the category number and for MX messages return the business process.java.lang.String
getMessageName()
Get the value of the property under theAbstractSwiftMessage.PROPERTY_NAME
key or the result ofAbstractSwiftMessage.getMessageType()
java.lang.Integer
getMessageTypeInt()
Get the integer value of theAbstractSwiftMessage.getMessageType()
or null if the identifier attribute is not set or not a number.java.lang.String
getMir()
Gets the MIR (Message Input Reference)MtId
getMtId()
Returns this message MT identificationjava.lang.String
getMur()
Gets the MUR (Message User Reference) from block 3java.lang.String
getPde()
Gets PDE (Possible Duplicate Emission) flag from the trailer block or null if the trailer or the PDE field is not presentjava.lang.String
getPdm()
Gets PDM from the trailer block or null if the trailer or the PDM field is not presentjava.lang.String
getUuid()
Gets a UUID (User Unique Identifier).MTVariant
getVariant()
Returns the message type variantint
hashCode()
boolean
isType(int type)
Test if this message is a given specific type.boolean
isType(java.lang.Integer... type)
Tell if this message is any of the given types.SwiftMessage
modelMessage()
Parses the raw message content into aSwiftMessage
object.static MtSwiftMessage
parse(java.io.File file)
Creates a new message reading the message the content from a file.static MtSwiftMessage
parse(java.io.InputStream stream)
Creates a new message reading the message the content from an input stream.static MtSwiftMessage
parse(java.lang.String fin)
Creates a new message reading the message the content from a string.void
setMir(java.lang.String mir)
Sets the MIR attribute.void
setMur(java.lang.String mur)
Sets the MUR attribute.void
setPde(java.lang.String pde)
Sets the PDE attribute.void
setPdm(java.lang.String pdm)
Sets the PDM attribute.void
setUuid(java.lang.String uuid)
Sets a UUID.java.lang.String
toString()
void
updateFromFIN()
Deprecated.UseupdateFromFIN(String)
insteadvoid
updateFromFIN(java.lang.String fin)
void
updateFromFIN(java.lang.String fin, MessageMetadataStrategy metadataStrategy)
Updates the the attributes with the raw message and its metadata from the given raw (FIN) message content.protected void
updateFromMessage()
protected void
updateFromMessage(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(AbstractMT mt)
void
updateFromModel(AbstractMT mt, MessageMetadataStrategy metadataStrategy)
The AbstractMT is serialized to its FIN raw format to set the internal raw message attribute.void
updateFromModel(SwiftMessage model)
void
updateFromModel(SwiftMessage model, MessageMetadataStrategy metadataStrategy)
The SwiftMessage is serialized to its FIN raw format to set the internal raw message attribute.void
updateMetadata(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, 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
-
MtSwiftMessage
public MtSwiftMessage()
-
MtSwiftMessage
public MtSwiftMessage(java.lang.String fin)
- Parameters:
fin
- the plain FIN message content
-
MtSwiftMessage
public MtSwiftMessage(java.lang.String fin, MessageMetadataStrategy metadataStrategy)
Creates a new MT entity reading the message content from the plain message content.If the FIN content contains several messages (because it is an RJE batch file for example) then the whole content will be stored in the message attribute but the metadata (such as the message type) will be extracted from the first message only.
Notice that if an ACK/NAK message is used as parameter, this object will represent the ACK/NAK. Even if the original message is attached after the service 21 messages.
File format is set to
FileFormat.FIN
- Parameters:
fin
- the plain FIN message contentmetadataStrategy
- a strategy for metadata extraction- Since:
- 9.1.4
-
MtSwiftMessage
public MtSwiftMessage(java.io.InputStream stream) throws java.io.IOException
- Parameters:
stream
- input stream to read- Throws:
java.io.IOException
- on error during file reading
-
MtSwiftMessage
public MtSwiftMessage(java.io.InputStream stream, MessageMetadataStrategy metadataStrategy) throws java.io.IOException
Creates a new message reading the message the content from an input stream.
File format is set toFileFormat.FIN
.- Parameters:
stream
- input stream to readmetadataStrategy
- a strategy for metadata extraction- Throws:
java.io.IOException
- on error during file reading- Since:
- 9.1.4
-
MtSwiftMessage
public MtSwiftMessage(java.io.File file) throws java.io.IOException
- Parameters:
file
- file holding message content- Throws:
java.io.IOException
- on error during file reading
-
MtSwiftMessage
public MtSwiftMessage(java.io.File file, MessageMetadataStrategy metadataStrategy) throws java.io.IOException
Creates a new message reading the message the content from a file.
File format is set toFileFormat.FIN
- Parameters:
file
- file holding message contentmetadataStrategy
- a strategy for metadata extraction- Throws:
java.io.IOException
- on error during file reading- Since:
- 9.1.4
-
MtSwiftMessage
public MtSwiftMessage(AbstractMT mt)
- Since:
- 8.0.2
-
MtSwiftMessage
public MtSwiftMessage(AbstractMT mt, MessageMetadataStrategy metadataStrategy)
Creates an MtSwiftMessage from a subclass ofAbstractMT
.- Parameters:
mt
- the MT message to create this entity frommetadataStrategy
- a strategy for metadata extraction- Since:
- 9.1.4
-
MtSwiftMessage
public MtSwiftMessage(SwiftMessage model)
-
MtSwiftMessage
public MtSwiftMessage(SwiftMessage model, MessageMetadataStrategy metadataStrategy)
Creates an MtSwiftMessage from a SwiftMessage.- Parameters:
model
- the MT message to create this entity frommetadataStrategy
- a strategy for metadata extraction- Since:
- 9.1.4
-
-
Method Detail
-
parse
public static MtSwiftMessage parse(java.lang.String fin)
Creates a new message reading the message the content from a string. This is a static version of the constructorMtSwiftMessage(String)
- Since:
- 7.7
-
parse
public static MtSwiftMessage 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 constructorMtSwiftMessage(InputStream)
- Throws:
java.io.IOException
- Since:
- 7.7
-
parse
public static MtSwiftMessage 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 constructorMtSwiftMessage(File)
- Throws:
java.io.IOException
- Since:
- 7.7
-
fromJson
public static MtSwiftMessage fromJson(java.lang.String json)
This method deserializes the JSON data into an MT message object.- Parameters:
json
- JSON representation- Returns:
- message object
- Since:
- 7.10.3
-
updateFromMessage
protected void updateFromMessage() throws java.lang.IllegalArgumentException
- Specified by:
updateFromMessage
in classAbstractSwiftMessage
- Throws:
java.lang.IllegalArgumentException
- Since:
- 7.7
-
updateFromMessage
protected void updateFromMessage(MessageMetadataStrategy metadataStrategy) throws java.lang.IllegalArgumentException
Description copied from class:AbstractSwiftMessage
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.This method is expected to be overwritten by subclasses. This default implementation will just ignore the parameter strategy.
- Overrides:
updateFromMessage
in classAbstractSwiftMessage
- Throws:
java.lang.IllegalArgumentException
- if the source format is notFileFormat.FIN
or if the message cannot be parsed into aMtSwiftMessage
object- Since:
- 9.1.4
- See Also:
AbstractSwiftMessage.updateFromMessage(MessageMetadataStrategy)
-
updateFromFIN
public void updateFromFIN(java.lang.String fin)
- Parameters:
fin
- raw (FIN) message content to update from
-
updateFromFIN
public void updateFromFIN(java.lang.String fin, MessageMetadataStrategy metadataStrategy)
Updates the the attributes with the raw message and its metadata from the given raw (FIN) message content.- Parameters:
fin
- the new message contentmetadataStrategy
- a strategy implementation to extract the metadata from the FIN content- Since:
- 9.1.4
-
updateFromFIN
@Deprecated @ProwideDeprecated(phase4=SRU2024) public void updateFromFIN()
Deprecated.UseupdateFromFIN(String)
instead
-
updateFromModel
public void updateFromModel(SwiftMessage model)
- Parameters:
model
- model to update from
-
updateFromModel
public void updateFromModel(SwiftMessage model, MessageMetadataStrategy metadataStrategy)
The SwiftMessage is serialized to its FIN raw format to set the internal raw message attribute. And the header attributes are set with data from the parameter SwiftMessage. Notice that the SwiftMessage is not stored as internal attribute.- Parameters:
model
- the new message contentmetadataStrategy
- a strategy implementation to extract the metadata from the model- Since:
- 9.1.4
-
updateFromModel
public void updateFromModel(AbstractMT mt)
- Parameters:
mt
- message to update from- Since:
- 7.8.4
-
updateFromModel
public void updateFromModel(AbstractMT mt, MessageMetadataStrategy metadataStrategy)
The AbstractMT is serialized to its FIN raw format to set the internal raw message attribute. And the header attributes are set with data from the parameter AbstractMT. Notice that the AbstractMT is not stored as internal attribute.- Parameters:
mt
- the new message content to setmetadataStrategy
- a strategy implementation to extract the metadata from the model- Since:
- 9.1.4
-
modelMessage
public SwiftMessage modelMessage()
Parses the raw message content into aSwiftMessage
object.- Returns:
- the parsed message or null if the raw content is not set or cannot be parsed
- Since:
- 7.8.9
-
getMessageTypeInt
public java.lang.Integer getMessageTypeInt()
Get the integer value of theAbstractSwiftMessage.getMessageType()
or null if the identifier attribute is not set or not a number.- Returns:
- message type as integer
-
getMessageName
public java.lang.String getMessageName()
Get the value of the property under theAbstractSwiftMessage.PROPERTY_NAME
key or the result ofAbstractSwiftMessage.getMessageType()
- Overrides:
getMessageName
in classAbstractSwiftMessage
- Returns:
- the set message name or message type
-
isType
public boolean isType(java.lang.Integer... type)
Tell if this message is any of the given types.- Parameters:
type
- a variable list of integers for testing to match as the current message type- Returns:
true
if the current message type is any of the integers given as parameters, andfalse
in any other case
-
isType
public boolean isType(int type)
Test if this message is a given specific type.- Parameters:
type
- the message type given as int, to test- Returns:
true
if this message type is thetype
given, orfalse
in any other case
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getPde
public java.lang.String getPde()
Gets PDE (Possible Duplicate Emission) flag from the trailer block or null if the trailer or the PDE field is not present- Returns:
- the PDE flag or null
-
setPde
public void setPde(java.lang.String pde)
Sets the PDE attribute. This field is automatically updated on message update from FIN or model- Parameters:
pde
- the PDE flag to set- See Also:
updateFromFIN(String)
,updateFromModel(AbstractMT)
,updateFromModel(SwiftMessage)
-
getPdm
public java.lang.String getPdm()
Gets PDM from the trailer block or null if the trailer or the PDM field is not present- Returns:
- PDM flag or null
-
setPdm
public void setPdm(java.lang.String pdm)
Sets the PDM attribute. This field is automatically updated on message update from FIN or model- Parameters:
pdm
- the PDM flag to set- See Also:
updateFromFIN(String)
,updateFromModel(AbstractMT)
,updateFromModel(SwiftMessage)
-
getMir
public java.lang.String getMir()
Gets the MIR (Message Input Reference)- Returns:
- MIR
- See Also:
SwiftMessage.getMIR()
-
setMir
public void setMir(java.lang.String mir)
Sets the MIR attribute. This field is automatically updated on message update from FIN or model- Parameters:
mir
- the MIR to set- See Also:
updateFromFIN(String)
,updateFromModel(AbstractMT)
,updateFromModel(SwiftMessage)
-
getMur
public java.lang.String getMur()
Gets the MUR (Message User Reference) from block 3- Returns:
- the MUR or null if not present in the message
- See Also:
SwiftMessage.getMUR()
-
setMur
public void setMur(java.lang.String mur)
Sets the MUR attribute. This field is automatically updated on message update from FIN or model- Parameters:
mur
- the MUR to set- See Also:
updateFromFIN(String)
,updateFromModel(AbstractMT)
,updateFromModel(SwiftMessage)
-
getUuid
public java.lang.String getUuid()
Gets a UUID (User Unique Identifier).- Returns:
- UUID
- See Also:
SwiftMessage.getUUID()
-
setUuid
public void setUuid(java.lang.String uuid)
Sets a UUID. This field is automatically updated on message update from FIN or model.- Parameters:
uuid
- UUID to set- See Also:
updateFromFIN(String)
,updateFromModel(AbstractMT)
,updateFromModel(SwiftMessage)
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classAbstractSwiftMessage
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classAbstractSwiftMessage
-
copyTo
public void copyTo(MtSwiftMessage 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)
-
getVariant
public MTVariant getVariant()
Returns the message type variant- Returns:
- the variant or null if the message has no variant
- Since:
- 7.10.4
-
getMtId
public MtId getMtId()
Returns this message MT 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 classAbstractSwiftMessage
- Returns:
- a string with the category or empty if the identifier is invalid or not present
- Since:
- 7.10.4
-
updateMetadata
public void updateMetadata(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.- Parameters:
strategy
- meta data strategy- Since:
- 9.1.4
-
-