public class SwiftMessageUtils extends Object
SwiftMessage
Constructor and Description |
---|
SwiftMessageUtils() |
SwiftMessageUtils(SwiftMessage m) |
Modifier and Type | Method and Description |
---|---|
static String |
calculateChecksum(SwiftMessage model)
Proprietary checksum for message integrity verification.
|
static SwiftTagListBlock |
createSequenceSingle(Class<? extends AbstractMT> mt,
String sequenceName,
Tag... tags) |
static SwiftTagListBlock |
createSubsequenceWithParents(Class<? extends AbstractMT> mt,
String sequenceName,
Tag... tags)
Creates a sequence and all it's containing parents.
|
List<String> |
currencyStrings() |
static List<String> |
currencyStrings(SwiftMessage m)
Mirrors logic on
CurrencyContainer.currencyStrings() including all fields |
static SwiftTagListBlock |
join(List<? extends SwiftTagListBlock> sequences)
Joins all the given sequences in one single list.
|
static String |
reference(SwiftMessage m)
Gets the message reference from field 20 (if present)
or from field 20C 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 Map<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 List<SwiftTagListBlock> |
splitByField15(SwiftMessage msg,
String letterOption)
Helper method to retrieve all sequences starting with 15X where X is the letterOption parameter
|
static Map<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 List<SwiftTagListBlock> |
splitByField15(SwiftTagListBlock block,
String letterOption)
Helper method to retrieve all sequences starting with 15X where X is the letterOption parameter.
|
Calendar |
valueDate() |
static 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 static List<String> currencyStrings(SwiftMessage m)
CurrencyContainer.currencyStrings()
including all fieldsm
- public Calendar valueDate()
valueDate(SwiftMessage)
public static SwiftTagListBlock removeInnerSequences(SwiftTagListBlock sequence)
sequence
- a block with a sequence to filterIllegalArgumentException
- if the starting tag is not 16R or the ending tag is not the matching 16Spublic static Calendar valueDate(SwiftMessage m)
m
- the message where the value date is to be foundnull
if the message does not defines a value date, or if the defined value date field is not present in the messagepublic static String calculateChecksum(SwiftMessage model)
model
- public static Map<String,SwiftTagListBlock> splitByField15(SwiftMessage msg)
splitByField15(SwiftTagListBlock)
public static Map<String,SwiftTagListBlock> splitByField15(SwiftTagListBlock block)
block
- the content to splitpublic static List<SwiftTagListBlock> splitByField15(SwiftMessage msg, String letterOption)
splitByField15(SwiftTagListBlock, String)
public static List<SwiftTagListBlock> splitByField15(SwiftTagListBlock block, String letterOption)
block
- the content to split into subsequencesletterOption
- a letter option for the field boundarypublic static String reference(SwiftMessage m)
m
- the message where the reference is to be foundnull
if the message does not defines a reference, or if the defined reference field is not present in the messagepublic static SwiftTagListBlock join(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(Class<? extends AbstractMT> mt, 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(Class<? extends AbstractMT> mt, String sequenceName, Tag... tags)