Class SwiftBlockUser

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

    public class SwiftBlockUser
    extends SwiftTagListBlock
    implements java.io.Serializable
    Base class for SWIFT User "ad-hoc" Blocks (blocks with number other than 1-5 or names).

    The assumption is that these User Defined Blocks are used and defined as tag blocks (meaning that these blocks behave like a block 3 or 5).

    NOTE: this is not part of SWIFT standard, but seems to be common practice for users to append some locally defined blocks to annotate messages in a semi-compatible way (for example: add block 9 for some local information or block "S" for system reference).

    Since:
    5.0
    See Also:
    Serialized Form
    • Field Detail

      • sortKey

        protected java.lang.Integer sortKey
        Indicates the position of this user block in a message when persisted. This value is used to remember the positions of the blocks inside a message when persisted. This value may not be set when persistence is not used and should not be used by clients.
      • blockName

        protected java.lang.String blockName
        Block name. For integer numbered blocks, this will be the block number converted to string. For other blocks (for example: "S"), this will be the block real identifier and block number (if requested) will be -1.
        Since:
        5.0
    • Constructor Detail

      • SwiftBlockUser

        public SwiftBlockUser()
        Default constructor
        Since:
        5.0
      • SwiftBlockUser

        public SwiftBlockUser​(java.lang.Integer blockNumber)
        Constructor for empty numbered user block
        Parameters:
        blockNumber - the block number to initialize
        Throws:
        java.lang.IllegalArgumentException - if parameter blockNumber is null
        java.lang.IllegalArgumentException - if parameter blockNumber is not a valid User Defined Block number (values 6..9)
        Since:
        5.0
      • SwiftBlockUser

        public SwiftBlockUser​(java.lang.Integer blockNumber,
                              java.util.List<Tag> tags)
        Constructor for numbered user block with tag initialization
        Parameters:
        blockNumber - the block number to initialize
        tags - the list of tags to initialize
        Throws:
        java.lang.IllegalArgumentException - if parameter blockNumber or tags are null
        java.lang.IllegalArgumentException - if parameter blockNumber is not a valid User Defined Block number (values 6..9)
        java.lang.IllegalArgumentException - if parameter tags is not composed of Strings
        Since:
        5.0
      • SwiftBlockUser

        public SwiftBlockUser​(java.lang.String blockName)
        Constructor for named user block
        Parameters:
        blockName - the block name to initialize
        Throws:
        java.lang.IllegalArgumentException - if parameter blockName is null
        java.lang.IllegalArgumentException - if parameter blockName is not a valid User Defined Block name (single letter)
        Since:
        5.0
      • SwiftBlockUser

        public SwiftBlockUser​(java.lang.String blockName,
                              java.util.List<Tag> tags)
        Constructor for named user block with tag initialization
        Parameters:
        blockName - the block name to initialize
        tags - the list of tags to initialize
        Throws:
        java.lang.IllegalArgumentException - if parameter blockName or tags are null
        java.lang.IllegalArgumentException - if parameter blockName is not a valid User Defined Block name (single letter)
        java.lang.IllegalArgumentException - if parameter tags is not composed of Strings
        Since:
        5.0
    • Method Detail

      • isValidName

        public static java.lang.Boolean isValidName​(java.lang.String blockName,
                                                    java.lang.Integer blockNumber)
        Checks if the block name and are valid for a user defined block.
        Parameters:
        blockName - the block name
        blockNumber - the block number
        Returns:
        true if the block name and number are valid
        Since:
        5.0
      • isValidName

        public static java.lang.Boolean isValidName​(java.lang.String blockName)
        Checks if the block name is valid for a user defined block.
        Parameters:
        blockName - the block name
        Returns:
        true if the block name and number are valid
        Since:
        5.0
      • isValidName

        public static java.lang.Boolean isValidName​(java.lang.Integer blockNumber)
        Checks if the block number is valid for a user defined block. Invalid blocks are blocks null or values 1-5 inclusive, all other values are considered valid.
        Parameters:
        blockNumber - the block number
        Returns:
        true if the block name and number are valid
        Since:
        5.0
      • getNumber

        public java.lang.Integer getNumber()
        Returns the block number (if it can be converted to an integer, -1 otherwise).
        Overrides:
        getNumber in class SwiftTagListBlock
        Returns:
        Integer containing the block's name as an integer or -1 if the block name is not numeric
      • getName

        public java.lang.String getName()
        Description copied from class: SwiftBlock
        Returns the block name (this method is to be overwritten for derived classes).
        Overrides:
        getName in class SwiftTagListBlock
        Returns:
        block name
        See Also:
        getBlockName()
      • getBlockName

        public java.lang.String getBlockName()
        The block name.
        Returns:
        the block name
        Since:
        5.0
      • setBlockName

        protected void setBlockName​(java.lang.String blockName)
        Sets the block name.
        Overrides:
        setBlockName in class SwiftTagListBlock
        Parameters:
        blockName - the block name to set
        Throws:
        java.lang.IllegalArgumentException - if parameter blockName is null
        java.lang.IllegalArgumentException - if parameter blockName is not a valid User Defined Block name (single letter)
        Since:
        5.0
      • setBlockNumber

        protected void setBlockNumber​(java.lang.Integer blockNumber)
        Sets the block number. This really sets blockName
        Overrides:
        setBlockNumber in class SwiftTagListBlock
        Parameters:
        blockNumber - the block number to set
        Throws:
        java.lang.IllegalArgumentException - if parameter blockNumber is null
        java.lang.IllegalArgumentException - if parameter blockNumber is not a valid User Defined Block number (values 6..9)
        Since:
        5.0
      • isValidName

        protected java.lang.Boolean isValidName()
        Checks if the block name (and or number) is valid for a user defined block. The block name is considered valid if its numeric value is other than 1-5 and if its named identification value is a one char string, for example "S".
        Returns:
        true if the block name and number are valid
        Since:
        5.0
      • getSortKey

        public java.lang.Integer getSortKey()
        get the sortkey of this user block when persisted
        Returns:
        an integer with the current sortkey
        See Also:
        sortKey
      • setSortKey

        public void setSortKey​(java.lang.Integer sortKey)
        Set the sortkey of this user block when persisted. This value may be changed by clients when persistence is used and the order of the user blocks in a message are being modified.
        Parameters:
        sortKey - the new sortkey