Class SwiftBlock2

  • All Implemented Interfaces:
    java.io.Serializable
    Direct Known Subclasses:
    SwiftBlock2Input, SwiftBlock2Output

    public abstract class SwiftBlock2
    extends SwiftValueBlock
    implements java.io.Serializable
    Base class for SWIFT Application Header Block (block 2)

    The Application Header contains information about the message type and the destination of the message.

    There are two types of application headers: Input and Output. Both, input and output block 2 flavors are fixed-length and continuous with no field delimiters. The fields that conform the blocks's value are represented in the subclasses as individual attributes for easier management.

    This is an abstract class so specific block 2 subclasses should be instantiated.

    Since:
    4.0
    See Also:
    Serialized Form
    • Field Detail

      • messagePriority

        protected java.lang.String messagePriority
        String of 1 character containing the message priority as follows:
        S = System
        N = Normal
        U = Urgent
      • messageType

        protected java.lang.String messageType
        String of 3 character containing the Message Type (MT) as classified and numbered by SWIFT. Three-digit FIN message type, example 103.
    • Constructor Detail

      • SwiftBlock2

        public SwiftBlock2()
        Default Constructor
    • Method Detail

      • setBlockNumber

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

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

        public java.lang.Integer getNumber()
        Returns the block number (the value 2 as an integer)
        Specified by:
        getNumber in class SwiftBlock
        Returns:
        Integer containing the block's number
      • getName

        public java.lang.String getName()
        Returns the block name (the value 2 as a string)
        Specified by:
        getName in class SwiftBlock
        Returns:
        block name
        Since:
        5.0
      • toString

        public java.lang.String toString()
        convert this to string
        Overrides:
        toString in class SwiftBlock
      • getMessageType

        public java.lang.String getMessageType()
        Gets the Message Type (MT) as classified and numbered by SWIFT.
        Returns:
        messageType String of 3 character
      • setMessageType

        public void setMessageType​(java.lang.String messageType)
        Sets the Message Type (MT) as classified and numbered by SWIFT. Three-digit FIN message type, example 103.
        Parameters:
        messageType - String of 3 character
      • getMessagePriority

        public java.lang.String getMessagePriority()
        Gets the message priority
        Returns:
        message priority
      • setMessagePriority

        public void setMessagePriority​(java.lang.String messagePriority)
        Set the message priority
        Parameters:
        messagePriority - the message priority
      • getMessagePriorityType

        public SwiftBlock2.MessagePriority getMessagePriorityType()
        Gets the message priority as enum
        Returns:
        message priority enum value or null if the priority is not set or contains an invalid value
        Since:
        7.8.4
      • isInput

        public boolean isInput()
        Returns true if this block 2 is an input block 2.
        Returns:
        true if block 2 is input, of false in other case
      • isOutput

        public boolean isOutput()
        Returns true if this block 2 is an output block 2.
        Returns:
        true if block 2 is output, of false in other case
      • clean

        public void clean()
        Sets all attributes to null
        Since:
        6.4
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class SwiftBlock
      • toJson

        public java.lang.String toJson()
        Specific serialization is provided for block 2 input and output.
        Returns:
        JSON representation of this block 2
        Since:
        7.9.8 current block 2 implementation, based on Gson (method signature with null implementation is available since 7.5)
      • field

        public java.lang.String field​(SwiftBlock2Field field)
        Generic getter for block attributes based on qualified names from SwiftBlock2Field
        Parameters:
        field - field to get
        Returns:
        field value or null if attribute is not set
        Since:
        7.7
      • setField

        public void setField​(SwiftBlock2Field field,
                             java.lang.String value)
        Generic setter for block attributes based on qualified names from SwiftBlock2Field
        Parameters:
        field - field to set
        value - content to set
        Since:
        7.8