public class SwiftMessageUtils
extends java.lang.Object
SwiftMessage
Constructor and Description |
---|
SwiftMessageUtils()
Deprecated.
use the static API instead
|
SwiftMessageUtils(SwiftMessage m)
Deprecated.
use the static API instead
|
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
calculateChecksum(SwiftBlock4 b4)
Proprietary checksum for message text block (block 4) integrity verification or duplicates detection
|
static java.lang.String |
calculateChecksum(SwiftMessage model)
Proprietary checksum for message integrity verification or duplicates detection.
|
static SwiftTagListBlock |
createSequenceSingle(java.lang.Class<? extends AbstractMT> mt,
java.lang.String sequenceName,
Tag... tags) |
static SwiftTagListBlock |
createSubsequenceWithParents(java.lang.Class<? extends AbstractMT> mt,
java.lang.String sequenceName,
Tag... tags)
Creates a sequence and all it's containing parents.
|
java.util.List<java.lang.String> |
currencyStrings()
Deprecated.
use the static
currencyStrings(SwiftMessage) instead |
static java.util.List<java.lang.String> |
currencyStrings(SwiftMessage m)
Get all message currencies for fields implementing
CurrencyContainer |
static SwiftTagListBlock |
join(java.util.List<? extends SwiftTagListBlock> sequences)
Joins all the given sequences in one single list.
|
protected Money |
money()
Deprecated.
use the static
money(SwiftMessage) instead |
static Money |
money(SwiftMessage m)
Gets the message main amount
|
java.lang.String |
reference()
Deprecated.
use the static
reference(SwiftMessage) instead |
static java.lang.String |
reference(SwiftMessage m)
Gets the message reference from field 20 (if present) or from field 20C:SEME if message category is 5.
|
static SwiftTagListBlock |
removeInnerSequences(SwiftTagListBlock sequence)
Iterates through the parameter tags and removes all inner blocks enclosed between
sequences boundary fields 16R and 16S
This method requires a sequence starting with 16R and ending with 16S, so first and last tags must be those. |
static java.util.Map<java.lang.String,SwiftTagListBlock> |
splitByField15(SwiftMessage msg)
Split the given message by the field 15, returning the letter option in the field 15 as the key in the map.
|
static java.util.List<SwiftTagListBlock> |
splitByField15(SwiftMessage msg,
java.lang.String letterOption)
Helper method to retrieve all sequences starting with 15X where X is the letterOption parameter
|
static java.util.Map<java.lang.String,SwiftTagListBlock> |
splitByField15(SwiftTagListBlock block)
Split the given block content by the field 15, returning the letter option in the field 15 as the key in the map
|
static java.util.List<SwiftTagListBlock> |
splitByField15(SwiftTagListBlock block,
java.lang.String letterOption)
Helper method to retrieve all sequences starting with 15X where X is the letterOption parameter.
|
static java.util.Calendar |
tradeDate(SwiftMessage m)
Gets the trade date of a message.
|
java.util.Calendar |
valueDate()
Deprecated.
use the static
valueDate(SwiftMessage) instead |
static java.util.Calendar |
valueDate(SwiftMessage m)
Gets the value date of a message.
|
@Deprecated @ProwideDeprecated(phase2=SRU2022) public SwiftMessageUtils()
@Deprecated @ProwideDeprecated(phase2=SRU2022) public SwiftMessageUtils(SwiftMessage m)
public static java.util.List<java.lang.String> currencyStrings(SwiftMessage m)
CurrencyContainer
m
- the message instancepublic static SwiftTagListBlock removeInnerSequences(SwiftTagListBlock sequence) throws java.lang.IllegalArgumentException
sequence
- a block with a sequence to filterjava.lang.IllegalArgumentException
- if the starting tag is not 16R or the ending tag is not the matching 16Spublic static java.util.Calendar valueDate(SwiftMessage m)
The value date is meaningful and defined by the standard only for a subset of message types. In most of the cases it is contained in the date subfield of field 32A (for example MT103) or field 30 (for example MT101).
Notice a lot of messages do not define a value date.
Also a few define several fields as value date, or the value date can be repeated.
for those messages the first one is returned as follows:
m
- the message where the value date is to be foundpublic static java.util.Calendar tradeDate(SwiftMessage m)
The implementation tries first to get the trade date from field 30T (present in many category 3 messages) and if not found it tries to get the trade date from field 98a::TRAD (present in many category 5 messages).
Notice a lot of messages do not define a trade date.
m
- the message where the value date is to be foundpublic static java.lang.String calculateChecksum(SwiftMessage model)
Please notice this is not the SWIFT trailer CHK field.
The implementation computes an MD5 on the complete message in FIN format. The result hash is a 32 character string, you may consider encoding it with base64 on top to have the same information stored in 22 characters.
model
- the messagepublic static java.lang.String calculateChecksum(SwiftBlock4 b4)
Please notice this is not the SWIFT trailer CHK field.
The implementation computes an MD5 on the complete message in FIN format. The result hash is a 32 character string, you may consider encoding it with base64 on top to have the same information stored in 22 characters.
b4
- the message text blockpublic static java.util.Map<java.lang.String,SwiftTagListBlock> splitByField15(SwiftMessage msg)
splitByField15(SwiftTagListBlock)
public static java.util.Map<java.lang.String,SwiftTagListBlock> splitByField15(SwiftTagListBlock block)
block
- the content to splitpublic static java.util.List<SwiftTagListBlock> splitByField15(SwiftMessage msg, java.lang.String letterOption)
splitByField15(SwiftTagListBlock, String)
public static java.util.List<SwiftTagListBlock> splitByField15(SwiftTagListBlock block, java.lang.String letterOption)
block
- the content to split into subsequencesletterOption
- a letter option for the field boundarypublic static java.lang.String reference(SwiftMessage m)
m
- the message where the reference is to be foundpublic static SwiftTagListBlock join(java.util.List<? extends SwiftTagListBlock> sequences)
sequences
- the sequences to be joined. Can be null or empty, in which case this method returns SwiftTagListBlock.EMPTY_LIST
SwiftTagListBlock
containing all elements in order of each of the given sequences or SwiftTagListBlock.EMPTY_LIST
if sequences is null or emptypublic static SwiftTagListBlock createSubsequenceWithParents(java.lang.Class<? extends AbstractMT> mt, java.lang.String sequenceName, Tag... tags)
MT535.SequenceB.newInstance(
MT535.SequenceB1b.newInstance(
MT535.SequenceB1b.newInstance(
MT535.SequenceB1b1.newInstance(
tags
)
)
)
);
This method is the same with a much cleaner code literature:
SwiftMessageUtils.createSequenceWithParents(MT535.class, "B1b1", tags);
Note:
SwiftMessageUtils.createSequenceWithParents(MT535.class, "B", tags);
Is virtually the same as:
MT535.SequenceB.newInstance(tags);
mt
- the MT class for which the sequence is to be createdsequenceName
- name of the sequencetags
- the content to put in the sequencepublic static SwiftTagListBlock createSequenceSingle(java.lang.Class<? extends AbstractMT> mt, java.lang.String sequenceName, Tag... tags)
public static Money money(SwiftMessage m)
The amount is meaningful and defined by the standard only for a subset of message types. In most of the cases it is contained in the currency and amount subfields of fields 32a in payments messages and 19A in securities.
This implementation is a work in progress and the interpretation of which field is consider the main amount for each message type may change from time to time adding more cases or even changing the used field.
m
- a message with some amount field@Deprecated @ProwideDeprecated(phase2=SRU2022) public java.util.List<java.lang.String> currencyStrings()
currencyStrings(SwiftMessage)
instead@Deprecated @ProwideDeprecated(phase2=SRU2022) public java.util.Calendar valueDate()
valueDate(SwiftMessage)
instead@Deprecated @ProwideDeprecated(phase2=SRU2022) public final java.lang.String reference()
reference(SwiftMessage)
instead@Deprecated @ProwideDeprecated(phase2=SRU2022) protected Money money()
money(SwiftMessage)
instead