Class SwiftBlock

  • All Implemented Interfaces:
    java.io.Serializable
    Direct Known Subclasses:
    SwiftTagListBlock, SwiftValueBlock

    public abstract class SwiftBlock
    extends java.lang.Object
    implements java.io.Serializable
    Base class for a generic SWIFT block.
    This is an abstract class so specific block classes for each block (block 1, 2, 3, etc...) should be instantiated.

    Instances of this class may have a list of unparsed texts (UnparsedTextList). For easy access, methods have been created that first ensure the lists exists (the real object is created and then call the base method).
    However, not all the base list methods have been implemented. If you need to use not exposed functionality, retrieve the underlying list with (see getUnparsedTexts method)
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.String blockType
      helper for hibernate mapping
      protected java.lang.Boolean input
      Only valid for block2, only when using hibernate for persistence
      protected java.lang.Boolean output
      Only valid for block2, only when using hibernate for persistence
      protected UnparsedTextList unparsedTexts
      List of unparsed texts.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected SwiftBlock()
      Default constructor, shouldn't be used normally.
        SwiftBlock​(UnparsedTextList unparsedText)
      Constructor for an unparsed text list
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object o)  
      java.lang.String getBlockType()  
      java.lang.Boolean getInput()
      Deprecated.
      abstract java.lang.String getName()
      Returns the block name (this method is to be overwritten for derived classes).
      abstract java.lang.Integer getNumber()
      Returns the block number (this method is to be overwritten for derived classes).
      java.lang.Boolean getOutput()
      Deprecated.
      UnparsedTextList getUnparsedTexts()
      Returns the unparsed text list attached to the Block.
      java.lang.Integer getUnparsedTextsSize()
      returns the size of the unparsed text list
      int hashCode()  
      boolean isTagBlock()
      Tell if this block is a block that contains a list of tags (3-5) or is a block with fixed length value (1-2)
      protected abstract void setBlockName​(java.lang.String blockName)
      Sets the block name (this method is to be overwrite for derived classes).
      protected abstract void setBlockNumber​(java.lang.Integer blockNumber)
      Sets the block number (this method is to be overwrite for derived classes).
      void setBlockType​(java.lang.String blockType)
      should not be normally called
      void setInput​(java.lang.Boolean input)
      Only valid for block2, only when using hibernate for persistence
      void setOutput​(java.lang.Boolean output)
      Only valid for block2, only when using hibernate for persistence
      void setUnparsedTexts​(UnparsedTextList texts)
      sets the list of unparsed texts
      java.lang.String toString()  
      void unparsedTextAddText​(SwiftMessage message)
      adds a new unparsed text from a message
      void unparsedTextAddText​(java.lang.String text)
      adds a new unparsed text
      SwiftMessage unparsedTextGetAsMessage​(java.lang.Integer index)
      get an unparsed text as a parsed swift message
      java.lang.String unparsedTextGetText​(java.lang.Integer index)
      get an unparsed text
      java.lang.Boolean unparsedTextIsMessage​(java.lang.Integer index)
      decides if a specific text (by index) is likely a SWIFT FIN message.
      protected void unparsedTextVerify()
      verifies that the unparsed text list exists
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • unparsedTexts

        protected UnparsedTextList unparsedTexts
        List of unparsed texts. For performance reasons, this will be null until really needed.
      • input

        protected java.lang.Boolean input
        Only valid for block2, only when using hibernate for persistence
      • output

        protected java.lang.Boolean output
        Only valid for block2, only when using hibernate for persistence
      • blockType

        protected java.lang.String blockType
        helper for hibernate mapping
    • Constructor Detail

      • SwiftBlock

        protected SwiftBlock()
        Default constructor, shouldn't be used normally. DO NOT USE: present only for subclasses
      • SwiftBlock

        public SwiftBlock​(UnparsedTextList unparsedText)
        Constructor for an unparsed text list
        Parameters:
        unparsedText - the list of unparsed texts
    • Method Detail

      • equals

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

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • getBlockType

        public java.lang.String getBlockType()
        Returns:
        a string identifying block type or null if not implemented
      • setBlockType

        public void setBlockType​(java.lang.String blockType)
        should not be normally called
        Parameters:
        blockType - block type
      • setBlockNumber

        protected abstract void setBlockNumber​(java.lang.Integer blockNumber)
        Sets the block number (this method is to be overwrite for derived classes).
        Parameters:
        blockNumber - the block number to set
        Since:
        5.0
      • setBlockName

        protected abstract void setBlockName​(java.lang.String blockName)
        Sets the block name (this method is to be overwrite for derived classes).
        Parameters:
        blockName - the block name to set
        Since:
        5.0
      • getNumber

        public abstract java.lang.Integer getNumber()
        Returns the block number (this method is to be overwritten for derived classes).
        Returns:
        Integer containing the block's number
      • getName

        public abstract java.lang.String getName()
        Returns the block name (this method is to be overwritten for derived classes).
        Returns:
        block name
        Since:
        5.0
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • isTagBlock

        public boolean isTagBlock()
        Tell if this block is a block that contains a list of tags (3-5) or is a block with fixed length value (1-2)
        Returns:
        true if this object contains a list of tags (which may be empty or null
      • unparsedTextVerify

        protected void unparsedTextVerify()
        verifies that the unparsed text list exists
      • getUnparsedTexts

        public UnparsedTextList getUnparsedTexts()
        Returns the unparsed text list attached to the Block.
        Returns:
        the unparsed texts attached to the block
      • setUnparsedTexts

        public void setUnparsedTexts​(UnparsedTextList texts)
        sets the list of unparsed texts
        Parameters:
        texts - the new list of unparsed texts (may be null)
      • getUnparsedTextsSize

        public java.lang.Integer getUnparsedTextsSize()
        returns the size of the unparsed text list
        Returns:
        the count of unparsed test attached to the block
      • unparsedTextIsMessage

        public java.lang.Boolean unparsedTextIsMessage​(java.lang.Integer index)
        decides if a specific text (by index) is likely a SWIFT FIN message. Exceptions are inherited from base implementation methods.
        Parameters:
        index - the unparsed text number
        Returns:
        true if the unparsed text at position index is a full SWIFT Message
        Throws:
        java.lang.IllegalArgumentException - if parameter index is null
        java.lang.IndexOutOfBoundsException - if parameter index is out of bounds
      • unparsedTextGetText

        public java.lang.String unparsedTextGetText​(java.lang.Integer index)
        get an unparsed text
        Parameters:
        index - the unparsed text number
        Returns:
        the requested text
        Throws:
        java.lang.IllegalArgumentException - if parameter index is null
        java.lang.IndexOutOfBoundsException - if parameter index is out of bounds
      • unparsedTextGetAsMessage

        public SwiftMessage unparsedTextGetAsMessage​(java.lang.Integer index)
        get an unparsed text as a parsed swift message
        Parameters:
        index - the unparsed text number
        Returns:
        the blocks unparsed text at position index, parsed into a SwiftMessage object
        Throws:
        java.lang.IllegalArgumentException - if parameter index is null
      • unparsedTextAddText

        public void unparsedTextAddText​(java.lang.String text)
        adds a new unparsed text
        Parameters:
        text - the unparsed text to append
        Throws:
        java.lang.IllegalArgumentException - if parameter text is null
      • unparsedTextAddText

        public void unparsedTextAddText​(SwiftMessage message)
        adds a new unparsed text from a message
        Parameters:
        message - the message to be appended
        Throws:
        java.lang.IllegalArgumentException - if parameter message is null
      • getInput

        @Deprecated
        public java.lang.Boolean getInput()
        Deprecated.
        Only valid for block2, only when using hibernate for persistence
        Returns:
        true if the message block type is 2I
      • setInput

        public void setInput​(java.lang.Boolean input)
        Only valid for block2, only when using hibernate for persistence
        Parameters:
        input - the is input parameter
      • getOutput

        @Deprecated
        public java.lang.Boolean getOutput()
        Deprecated.
        Only valid for block2, only when using hibernate for persistence
        Returns:
        true if message block type is 2O
      • setOutput

        public void setOutput​(java.lang.Boolean output)
        Only valid for block2, only when using hibernate for persistence
        Parameters:
        output - the is output parameter