public abstract class AbstractSwiftMessage extends Object implements Serializable
Modifier and Type | Field and Description |
---|---|
protected String |
identifier
Message type identification as specify by SWIFT.
For MT messages this will contain the three digits for the message type, ex: 103 For MX messages this will contain the business process, functionality, variant and version concatenated by a dot, ex: acmt.001.001.01 |
static String |
PROPERTY_NAME |
protected String |
receiver
Receivers BIC8 code.
For MT messages this is the BIC8 portion of the receiver logical terminal; for outgoing messages the LT at block 2 is used, and for incoming messages it is the LT at block 1. |
protected String |
sender
Senders BIC8 code.
For MT messages this is the BIC8 portion of the sender logical terminal; for outgoing messages the LT at block 1 is used, and for incoming messages it is the LT at the MIR of block 2. |
Modifier | Constructor and Description |
---|---|
|
AbstractSwiftMessage()
Empty constructor provided for ORM persistence.
|
protected |
AbstractSwiftMessage(File file)
Creates a new message reading the message the content from a file.
|
protected |
AbstractSwiftMessage(InputStream stream)
Creates a new message reading the message the content from an input stream, using UTF-8 as encoding.
|
protected |
AbstractSwiftMessage(String content)
Creates a new message reading the message the content from a string.
|
Modifier and Type | Method and Description |
---|---|
void |
addNote(SwiftMessageNote n)
Adds a new note to the messages, initializing the notes list if necessary.
|
void |
addStatus(SwiftMessageStatusInfo status)
Adds a status to the message's status trail and current status attribute, initializing the statuses trail list if necessary.
|
boolean |
contains(Enum... statuses)
Tell if this message has any of the given statuses in his status trail
|
boolean |
contains(String... statuses)
Tell if this message has any of the given statuses in his status trail
|
void |
copyTo(AbstractSwiftMessage msg)
Copies attributes from the current object to msg.
|
boolean |
equals(Object obj) |
SwiftMessageStatusInfo |
findStatusInfo(String statusName)
Finds the first status info from the status trail, with the given name or returns
null if not found |
String |
getChecksum() |
Calendar |
getCreationDate() |
MessageIOType |
getDirection() |
String |
getFilename() |
Long |
getId()
Returns the persisted message unique identifier.
|
String |
getIdentifier() |
String |
getLastData() |
String |
getLastData(String... statuses)
Get the last saved status data of this message or empty string if not found
|
Calendar |
getLastModified() |
String |
getMessage()
Same as {
message() } |
String |
getMessageName()
Get the value of the property under the
PROPERTY_NAME key or null if not found |
List<SwiftMessageNote> |
getNotes() |
String |
getPaddedId()
Returns the internal unique id as fixed length string, padded with zeros.
|
SwiftMessageStatusInfo |
getPreviousStatusInfo()
Retrieves from the status trail, the status info before the current one; or
null if none is found. |
Map<String,String> |
getProperties() |
String |
getProperty(Enum key) |
String |
getProperty(String key)
Get the value of the property under the given key or
null if the key is not found or its value is empty |
boolean |
getPropertyBoolean(Enum key) |
boolean |
getPropertyBoolean(String key)
Returns true if the message has a property with the given key name and value "true"
|
String |
getReceiver() |
String |
getSender() |
String |
getStatus()
Get the name of the last status set to this message, or
null if none is found. |
SwiftMessageStatusInfo |
getStatusInfo()
Retrieves from the status trail, the current status info; or
null if none is found. |
List<SwiftMessageStatusInfo> |
getStatusTrail() |
int |
hashCode() |
Boolean |
isIncoming() |
boolean |
isInput() |
boolean |
isOutgoing() |
Boolean |
isOutput() |
boolean |
isStatus(Enum... statuses)
Tell if this message has any of the given statuses as current status
|
boolean |
isStatus(Enum status)
Returns true if the current status is equals to the parameter status
|
boolean |
isStatus(String... statuses)
Tell if this message has any of the given statuses as current status
|
boolean |
isStatus(String status)
Returns true if the current status is equals to the parameter status
|
String |
message()
Returns the internal swift message in its original raw format.
|
abstract AbstractSwiftMessage |
readFile(File file)
Deprecated.
use the constructor
AbstractSwiftMessage(File) instead |
void |
sanityCheckProperties()
Iterate message properties and truncate all needed values issuing a log entry for each truncated one
|
void |
setChecksum(String checksum) |
void |
setCreationDate(Calendar creationDate) |
void |
setDirection(MessageIOType direction) |
void |
setFilename(String filename) |
void |
setId(Long id)
Used by the ORM to set the database unique identifier.
|
void |
setIdentifier(String identifier) |
void |
setLastModified(Calendar lastModified) |
void |
setMessage(String message)
Set the raw content of the message.
|
void |
setNotes(List<SwiftMessageNote> notes) |
void |
setProperties(Map<String,String> properties) |
void |
setProperty(Enum key,
String value) |
void |
setProperty(String key,
String value)
Sets a property using the given key and value, if the key exists the value is overwritten.
|
void |
setReceiver(String receiver) |
void |
setSender(String sender) |
void |
setStatus(String status)
Sets the status attribute.
|
void |
setStatus(SwiftMessageStatusInfo status) |
void |
setStatusTrail(List<SwiftMessageStatusInfo> statusTrail) |
protected abstract void |
updateFromMessage()
This method updates the object attributes with metadata parsed from the message,
identifier, sender, receiver, direction and specific data for MT/MX.
If the raw content contains multiple messages, only the first one will be read for metadata an message identification. |
protected String identifier
protected String sender
protected String receiver
public static final transient String PROPERTY_NAME
public AbstractSwiftMessage()
protected AbstractSwiftMessage(String content)
updateFromMessage()
} to fill the specific metadata attributes.content
- a swift message contentprotected AbstractSwiftMessage(InputStream stream) throws IOException
updateFromMessage()
} to fill the specific metadata attributes.stream
- IOException
protected AbstractSwiftMessage(File file) throws IOException
updateFromMessage()
} to fill the specific metadata attributes.file
- an existing file name containing only one message.IOException
protected abstract void updateFromMessage()
public Long getId()
public void setId(Long id)
public String message()
public void setMessage(String message)
message
- raw content of the messagepublic String getIdentifier()
public void setIdentifier(String identifier)
public String getChecksum()
public void setChecksum(String checksum)
public Calendar getLastModified()
public void setLastModified(Calendar lastModified)
public Calendar getCreationDate()
public void setCreationDate(Calendar creationDate)
public List<SwiftMessageNote> getNotes()
public void setNotes(List<SwiftMessageNote> notes)
public List<SwiftMessageStatusInfo> getStatusTrail()
public void setStatusTrail(List<SwiftMessageStatusInfo> statusTrail)
public String getStatus()
null
if none is found.public void setStatus(String status)
status
- addStatus(SwiftMessageStatusInfo)
public String getSender()
public void setSender(String sender)
public String getReceiver()
public void setReceiver(String receiver)
public MessageIOType getDirection()
public void setDirection(MessageIOType direction)
public String getFilename()
public void setFilename(String filename)
public String getMessageName()
PROPERTY_NAME
key or null
if not foundpublic void addStatus(SwiftMessageStatusInfo status)
status
- the status to addpublic boolean isOutgoing()
public boolean isInput()
isOutgoing()
public Boolean isIncoming()
public Boolean isOutput()
isIncoming()
public void setStatus(SwiftMessageStatusInfo status)
addStatus(SwiftMessageStatusInfo)
public boolean isStatus(String status)
status
- public boolean isStatus(Enum status)
status
- public SwiftMessageStatusInfo getStatusInfo()
null
if none is found.public SwiftMessageStatusInfo getPreviousStatusInfo()
null
if none is found.public boolean contains(Enum... statuses)
statuses
- a list of statuses to check in the status trailpublic boolean contains(String... statuses)
statuses
- a list of statuses to check in the status trailpublic boolean isStatus(String... statuses)
statuses
- public boolean isStatus(Enum... statuses)
statuses
- public String getLastData(String... statuses)
statuses
- an array of statuses to check data into, if null
all message statuses are checked for datapublic String getLastData()
public SwiftMessageStatusInfo findStatusInfo(String statusName)
null
if not foundpublic void addNote(SwiftMessageNote n)
n
- note to addpublic void sanityCheckProperties()
public String getProperty(String key)
null
if the key is not found or its value is emptypublic String getProperty(Enum key)
getProperty(String)
public void setProperty(String key, String value)
public void setProperty(Enum key, String value)
setProperty(String, String)
public boolean getPropertyBoolean(String key)
public boolean getPropertyBoolean(Enum key)
getPropertyBoolean(String)
public String getPaddedId()
public abstract AbstractSwiftMessage readFile(File file) throws IOException
AbstractSwiftMessage(File)
insteadIOException
public void copyTo(AbstractSwiftMessage msg)
msg
-