public class SwiftMessageUtils
extends java.lang.Object
SwiftMessage
Constructor and Description |
---|
SwiftMessageUtils() |
SwiftMessageUtils(SwiftMessage m) |
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.
|
protected com.prowidesoftware.swift.model.CurrencyAmount |
currencyAmount()
Gets the message main amount
|
java.util.List<java.lang.String> |
currencyStrings() |
static java.util.List<java.lang.String> |
currencyStrings(SwiftMessage m)
Mirrors logic on
CurrencyContainer.currencyStrings() including all fields |
static SwiftTagListBlock |
join(java.util.List<? extends SwiftTagListBlock> sequences)
Joins all the given sequences in one single list.
|
java.lang.String |
reference()
Gets the message reference
|
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.
|
java.util.Calendar |
valueDate()
Gets the message value date
|
static java.util.Calendar |
valueDate(SwiftMessage m)
Gets the value date of a message.
The value date is meaningful and defined by the standard only for a subset of message types. |
public SwiftMessageUtils()
public SwiftMessageUtils(SwiftMessage m)
public java.util.List<java.lang.String> currencyStrings()
public static java.util.List<java.lang.String> currencyStrings(SwiftMessage m)
CurrencyContainer.currencyStrings()
including all fieldsm
- public java.util.Calendar valueDate()
valueDate(SwiftMessage)
public static SwiftTagListBlock removeInnerSequences(SwiftTagListBlock sequence)
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)
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 final java.lang.String reference()
reference(SwiftMessage)
public 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 final 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)
protected com.prowidesoftware.swift.model.CurrencyAmount currencyAmount()
currencyAmount(SwiftMessage)