com.prowidesoftware.swift.model
Class AbstractSwiftMessage

java.lang.Object
  extended by com.prowidesoftware.swift.model.AbstractSwiftMessage
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
MtSwiftMessage, MxSwiftMessage

public class AbstractSwiftMessage
extends java.lang.Object
implements java.io.Serializable

Base class for common attributes of MT and MX SWIFT messages.
Most of the attributes are derived from the raw message, so it is an application responsibility to grant consistency of the redundant information.

Since:
7.0
Author:
www.prowidesoftware.com
See Also:
Serialized Form

Field Summary
 java.lang.String PROPERTY_NAME
           
 
Constructor Summary
AbstractSwiftMessage()
           
 
Method Summary
 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(java.lang.Enum... statuses)
          Tell if this message has any of the given statuses in his status trail
 boolean contains(java.lang.String... statuses)
          Tell if this message has any of the given statuses in his status trail
 boolean equals(java.lang.Object obj)
           
 SwiftMessageStatusInfo findStatusInfo(java.lang.String statusName)
          Finds the first status info from the status trail, with the given name or returns null if not found
 java.lang.String getChecksum()
           
 java.util.Calendar getCreationDate()
           
 MessageIOType getDirection()
           
 java.lang.String getFilename()
           
 java.lang.Long getId()
           
 java.lang.String getIdentifier()
           
 java.lang.String getLastData()
           
 java.lang.String getLastData(java.lang.String... statuses)
          Get the last saved status data of this message or empty string if not found
 java.util.Calendar getLastModified()
           
 java.lang.String getMessage()
           
 java.lang.String getMessageName()
          Get the value of the property under the PROPERTY_NAME key or null if not found
 java.util.List<SwiftMessageNote> getNotes()
           
 java.lang.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.
 java.util.Map<java.lang.String,java.lang.String> getProperties()
           
 java.lang.String getProperty(java.lang.Enum key)
           
 java.lang.String getProperty(java.lang.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(java.lang.Enum key)
           
 boolean getPropertyBoolean(java.lang.String key)
          Returns true if the message has a property with the given key name and value "true"
 java.lang.String getReceiver()
           
 java.lang.String getSender()
           
 java.lang.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.
 java.util.List<SwiftMessageStatusInfo> getStatusTrail()
           
 int hashCode()
           
 java.lang.Boolean isIncoming()
           
 boolean isInput()
           
 boolean isOutgoing()
           
 java.lang.Boolean isOutput()
           
 boolean isStatus(java.lang.Enum... statuses)
          Tell if this message has any of the given statuses as current status
 boolean isStatus(java.lang.Enum status)
          Returns true if the current status is equals to the parameter status
 boolean isStatus(java.lang.String... statuses)
          Tell if this message has any of the given statuses as current status
 boolean isStatus(java.lang.String status)
          Returns true if the current status is equals to the parameter status
 void sanityCheckProperties()
          Iterate message properties and truncate all needed values issuing a log entry for each truncated one
 void setChecksum(java.lang.String checksum)
           
 void setCreationDate(java.util.Calendar creationDate)
           
 void setDirection(MessageIOType direction)
           
 void setFilename(java.lang.String filename)
           
 void setId(java.lang.Long id)
           
 void setIdentifier(java.lang.String identifier)
           
 void setLastModified(java.util.Calendar lastModified)
           
 void setMessage(java.lang.String message)
           
 void setNotes(java.util.List<SwiftMessageNote> notes)
           
 void setProperties(java.util.Map<java.lang.String,java.lang.String> properties)
           
 void setProperty(java.lang.Enum key, java.lang.String value)
           
 void setProperty(java.lang.String key, java.lang.String value)
          Sets a property using the given key and value, if the key exists the value is overwritten.
 void setReceiver(java.lang.String receiver)
           
 void setSender(java.lang.String sender)
           
 void setStatus(java.lang.String status)
          Sets the status attribute.
 void setStatus(SwiftMessageStatusInfo status)
           
 void setStatusTrail(java.util.List<SwiftMessageStatusInfo> statusTrail)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_NAME

public java.lang.String PROPERTY_NAME
Constructor Detail

AbstractSwiftMessage

public AbstractSwiftMessage()
Method Detail

getId

public java.lang.Long getId()

setId

public void setId(java.lang.Long id)

getMessage

public java.lang.String getMessage()

setMessage

public void setMessage(java.lang.String message)

getIdentifier

public java.lang.String getIdentifier()

setIdentifier

public void setIdentifier(java.lang.String identifier)

getChecksum

public java.lang.String getChecksum()

setChecksum

public void setChecksum(java.lang.String checksum)

getLastModified

public java.util.Calendar getLastModified()

setLastModified

public void setLastModified(java.util.Calendar lastModified)

getCreationDate

public java.util.Calendar getCreationDate()

setCreationDate

public void setCreationDate(java.util.Calendar creationDate)

getNotes

public java.util.List<SwiftMessageNote> getNotes()

setNotes

public void setNotes(java.util.List<SwiftMessageNote> notes)

getProperties

public java.util.Map<java.lang.String,java.lang.String> getProperties()

setProperties

public void setProperties(java.util.Map<java.lang.String,java.lang.String> properties)

getStatusTrail

public java.util.List<SwiftMessageStatusInfo> getStatusTrail()

setStatusTrail

public void setStatusTrail(java.util.List<SwiftMessageStatusInfo> statusTrail)

getStatus

public java.lang.String getStatus()
Get the name of the last status set to this message, or null if none is found.


setStatus

public void setStatus(java.lang.String status)
Sets the status attribute. Notice that this method does not update the status trail.

Parameters:
status -
See Also:
addStatus(SwiftMessageStatusInfo)

getSender

public java.lang.String getSender()

setSender

public void setSender(java.lang.String sender)

getReceiver

public java.lang.String getReceiver()

setReceiver

public void setReceiver(java.lang.String receiver)

getDirection

public MessageIOType getDirection()

setDirection

public void setDirection(MessageIOType direction)

getMessageName

public java.lang.String getMessageName()
Get the value of the property under the PROPERTY_NAME key or null if not found


addStatus

public void addStatus(SwiftMessageStatusInfo status)
Adds a status to the message's status trail and current status attribute, initializing the statuses trail list if necessary.

Parameters:
status - the status to add

isOutgoing

public boolean isOutgoing()
Returns:
true if the message is outgoing (sent to SWIFT), false other case; using the direction attribute.

isInput

public boolean isInput()
See Also:
isOutgoing()

isIncoming

public java.lang.Boolean isIncoming()
Returns:
true if the message is incoming (received from SWIFT), false other case; using the direction attribute.

isOutput

public java.lang.Boolean isOutput()
See Also:
isIncoming()

setStatus

public void setStatus(SwiftMessageStatusInfo status)
See Also:
addStatus(SwiftMessageStatusInfo)

isStatus

public boolean isStatus(java.lang.String status)
Returns true if the current status is equals to the parameter status

Parameters:
status -

isStatus

public boolean isStatus(java.lang.Enum status)
Returns true if the current status is equals to the parameter status

Parameters:
status -

getStatusInfo

public SwiftMessageStatusInfo getStatusInfo()
Retrieves from the status trail, the current status info; or null if none is found.


getPreviousStatusInfo

public SwiftMessageStatusInfo getPreviousStatusInfo()
Retrieves from the status trail, the status info before the current one; or null if none is found.


contains

public boolean contains(java.lang.Enum... statuses)
Tell if this message has any of the given statuses in his status trail

Parameters:
statuses - a list of statuses to check in the status trail

contains

public boolean contains(java.lang.String... statuses)
Tell if this message has any of the given statuses in his status trail

Parameters:
statuses - a list of statuses to check in the status trail

isStatus

public boolean isStatus(java.lang.String... statuses)
Tell if this message has any of the given statuses as current status

Parameters:
statuses -

isStatus

public boolean isStatus(java.lang.Enum... statuses)
Tell if this message has any of the given statuses as current status

Parameters:
statuses -

getLastData

public java.lang.String getLastData(java.lang.String... statuses)
Get the last saved status data of this message or empty string if not found

Parameters:
statuses - an array of statuses to check data into, if null all message statuses are checked for data
Returns:
the most recent (last) status data found

getLastData

public java.lang.String getLastData()

findStatusInfo

public SwiftMessageStatusInfo findStatusInfo(java.lang.String statusName)
Finds the first status info from the status trail, with the given name or returns null if not found


addNote

public void addNote(SwiftMessageNote n)
Adds a new note to the messages, initializing the notes list if necessary.

Parameters:
n - note to add

sanityCheckProperties

public void sanityCheckProperties()
Iterate message properties and truncate all needed values issuing a log entry for each truncated one


getProperty

public java.lang.String getProperty(java.lang.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


getProperty

public java.lang.String getProperty(java.lang.Enum key)
See Also:
getProperty(String)

setProperty

public void setProperty(java.lang.String key,
                        java.lang.String value)
Sets a property using the given key and value, if the key exists the value is overwritten.


setProperty

public void setProperty(java.lang.Enum key,
                        java.lang.String value)
See Also:
setProperty(String, String)

getPropertyBoolean

public boolean getPropertyBoolean(java.lang.String key)
Returns true if the message has a property with the given key name and value "true"


getPropertyBoolean

public boolean getPropertyBoolean(java.lang.Enum key)
See Also:
getPropertyBoolean(String)

getPaddedId

public java.lang.String getPaddedId()
Returns the internal unique id as fixed length string, padded with zeros.

Returns:
string with 10 characters with this message identifier

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

getFilename

public java.lang.String getFilename()

setFilename

public void setFilename(java.lang.String filename)