Class SwiftBlock4

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Iterable<Tag>

    public class SwiftBlock4
    extends SwiftTagListBlock
    implements java.io.Serializable
    Base class for SWIFT Body Block (block 4).
    This block is where the actual message content is specified and is what most users see. Generally the other blocks are stripped off before presentation. It mainly contains a list of tags and its format representation, which is variable length and requires use of CRLF as a field delimiter.
    Since:
    4.0
    See Also:
    Serialized Form
    • Constructor Detail

      • SwiftBlock4

        public SwiftBlock4()
        Default constructor
      • SwiftBlock4

        public SwiftBlock4​(java.util.List<Tag> tags)
        Constructor with tag initialization
        Parameters:
        tags - the list of tags to initialize
        Throws:
        java.lang.IllegalArgumentException - if parameter tags is null
        java.lang.IllegalArgumentException - if parameter tags is not composed of Strings
        Since:
        5.0
    • Method Detail

      • removeRepeatedBoundaries

        public static SwiftBlock4 removeRepeatedBoundaries​(SwiftBlock4 b4)
        Creates a new block removing all the duplicated sequence boundaries (16R, 16S).

        The implementation uses as sequence boundaries the fields: 16R, 16S. Two or more consecutive 16R (start of sequence) or 16S (end of sequence) with the same qualifier are considered duplicated entries, so all repeated boundary fields 16R or 16S will be dropped.

        Parameters:
        b4 - a block with sequences to filter
        Returns:
        a new block containing all tags without repeated boundaries or null if the parameter block is null
        Since:
        9.2.19
      • removeEmptySequences

        public static SwiftBlock4 removeEmptySequences​(SwiftBlock4 b4)
        Creates a new block with all empty sequences removed.

        The implementation uses as sequence boundaries the fields: 16R, 16S and 15a. Two consecutive 16R (start of sequence) and 16S (end of sequence) with the same qualifier are considered an empty sequence so both boundary fields 16R and 16S will be dropped. For field 15a (start of sequence) there is no end of sequence boundary so if two consecutive 15a are found, the first one will be dropped. Also a 15a at the end of the block will be considered and empty sequence.

        Parameters:
        b4 - a block with sequences to filter
        Returns:
        a new block containing all tags that are outside a empty 16R/S or 15a sub-block, or null if the parameter block is null
        Since:
        7.8.8
      • fromJson

        public static SwiftBlock4 fromJson​(java.lang.String json)
        This method deserializes the JSON data into an block 4 object.
        Since:
        7.9.8
        See Also:
        SwiftTagListBlock.toJson()
      • setBlockNumber

        protected void setBlockNumber​(java.lang.Integer blockNumber)
        Sets the block number. Will cause an exception unless setting block number to 4.
        Overrides:
        setBlockNumber in class SwiftTagListBlock
        Parameters:
        blockNumber - the block number to set
        Throws:
        java.lang.IllegalArgumentException - if parameter blockName is not the integer 4
        Since:
        5.0
      • setBlockName

        protected void setBlockName​(java.lang.String blockName)
        Sets the block name. Will cause an exception unless setting block number to "4".
        Overrides:
        setBlockName in class SwiftTagListBlock
        Parameters:
        blockName - the block name to set
        Throws:
        java.lang.IllegalArgumentException - if parameter blockName is not the string "4"
        Since:
        5.0
      • getNumber

        public java.lang.Integer getNumber()
        Returns the block number (the value 4 as an integer)
        Overrides:
        getNumber in class SwiftTagListBlock
        Returns:
        Integer containing the block's number
      • getName

        public java.lang.String getName()
        Returns the block name (the value 4 as a string)
        Overrides:
        getName in class SwiftTagListBlock
        Returns:
        block name
        Since:
        5.0