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 Modifier and Type Method Description voidcopyTo(MtSwiftMessage msg)Creates a full copy of the current message object into another message.booleanequals(java.lang.Object o)static MtSwiftMessagefromJson(java.lang.String json)This method deserializes the JSON data into an MT message object.java.lang.StringgetCategory()For MT messages returns the category number and for MX messages return the business process.java.lang.StringgetMessageName()Get the value of the property under theAbstractSwiftMessage.PROPERTY_NAMEkey or the result ofAbstractSwiftMessage.getMessageType()java.lang.IntegergetMessageTypeInt()Get the integer value of theAbstractSwiftMessage.getMessageType()or null if the identifier attribute is not set or not a number.java.lang.StringgetMir()Gets the MIR (Message Input Reference)MtIdgetMtId()Returns this message MT identificationjava.lang.StringgetMur()Gets the MUR (Message User Reference) from block 3java.lang.StringgetPde()Gets PDE (Possible Duplicate Emission) flag from the trailer block or null if the trailer or the PDE field is not presentjava.lang.StringgetPdm()Gets PDM from the trailer block or null if the trailer or the PDM field is not presentjava.lang.StringgetUuid()Gets a UUID (User Unique Identifier).MTVariantgetVariant()Returns the message type variantinthashCode()booleanisType(int type)Test if this message is a given specific type.booleanisType(java.lang.Integer... type)Tell if this message is any of the given types.SwiftMessagemodelMessage()Parses the raw message content into aSwiftMessageobject.static MtSwiftMessageparse(java.io.File file)Creates a new message reading the message the content from a file.static MtSwiftMessageparse(java.io.InputStream stream)Creates a new message reading the message the content from an input stream.static MtSwiftMessageparse(java.lang.String fin)Creates a new message reading the message the content from a string.voidsetMir(java.lang.String mir)Sets the MIR attribute.voidsetMur(java.lang.String mur)Sets the MUR attribute.voidsetPde(java.lang.String pde)Sets the PDE attribute.voidsetPdm(java.lang.String pdm)Sets the PDM attribute.voidsetUuid(java.lang.String uuid)Sets a UUID.java.lang.StringtoString()voidupdateFromFIN(java.lang.String fin)voidupdateFromFIN(java.lang.String fin, MessageMetadataStrategy metadataStrategy)Updates the attributes with the raw message and its metadata from the given raw (FIN) message content.protected voidupdateFromMessage()protected voidupdateFromMessage(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.voidupdateFromModel(AbstractMT mt)voidupdateFromModel(AbstractMT mt, MessageMetadataStrategy metadataStrategy)The AbstractMT is serialized to its FIN raw format to set the internal raw message attribute.voidupdateFromModel(SwiftMessage model)voidupdateFromModel(SwiftMessage model, MessageMetadataStrategy metadataStrategy)The SwiftMessage is serialized to its FIN raw format to set the internal raw message attribute.voidupdateMetadata(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.IOExceptionCreates 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.IOExceptionCreates 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:
updateFromMessagein classAbstractSwiftMessage- Throws:
java.lang.IllegalArgumentException- Since:
- 7.7
-
updateFromMessage
protected void updateFromMessage(MessageMetadataStrategy metadataStrategy) throws java.lang.IllegalArgumentException
Description copied from class:AbstractSwiftMessageUpdates 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:
updateFromMessagein classAbstractSwiftMessage- Throws:
java.lang.IllegalArgumentException- if the source format is notFileFormat.FINor if the message cannot be parsed into aMtSwiftMessageobject- 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 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
-
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 aSwiftMessageobject.- 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_NAMEkey or the result ofAbstractSwiftMessage.getMessageType()- Overrides:
getMessageNamein 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:
trueif the current message type is any of the integers given as parameters, andfalsein 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:
trueif this message type is thetypegiven, orfalsein any other case
-
toString
public java.lang.String toString()
- Overrides:
toStringin 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:
equalsin classAbstractSwiftMessage
-
hashCode
public int hashCode()
- Overrides:
hashCodein 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:
getCategoryin 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
-
-