Class SwiftWriter


  • public class SwiftWriter
    extends java.lang.Object
    Writes MT messages content into FIN format (raw SWIFT format for MT messages).
    • Constructor Summary

      Constructors 
      Constructor Description
      SwiftWriter()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String ensureEols​(java.lang.String content)
      Makes sure all EOLs are swift compatible by replacing any line break in the parameter String with CRLF
      static java.lang.String getInternalXml​(SwiftMessage msg)
      Get a string with the internal xml representation of a message.
      static java.lang.String writeBlock1​(SwiftBlock1 b1)
      Returns the given block content in its native SWIFT format
      static void writeBlock1​(SwiftBlock1 b1, java.io.Writer writer)
      Write the given block to writer in its native SWIFT format
      static java.lang.String writeBlock2​(SwiftBlock2 b2)
      Returns the given block content in its native SWIFT format
      static void writeBlock2​(SwiftBlock2 b2, java.io.Writer writer)
      Write the given block to writer in its native SWIFT format
      static java.lang.String writeBlock3​(SwiftBlock3 b3)
      Returns the given block content in its native SWIFT format
      static void writeBlock3​(SwiftBlock3 b3, java.io.Writer writer)
      Write the given block to writer in its native SWIFT format
      static java.lang.String writeBlock4​(SwiftBlock4 b4)
      Returns the given block content in its native SWIFT format
      static void writeBlock4​(SwiftBlock4 b4, java.io.Writer writer)
      Write the given block to writer in its native SWIFT format
      static java.lang.String writeBlock5​(SwiftBlock5 b5)
      Returns the given block content in its native SWIFT format
      static void writeBlock5​(SwiftBlock5 b5, java.io.Writer writer)
      Write the given block to writer in its native SWIFT format
      static void writeMessage​(SwiftMessage msg, java.io.Writer writer)
      Writes the given message content to writer in its FIN format (raw SWIFT format for MT messages).
      static void writeMessage​(SwiftMessage msg, java.io.Writer writer, boolean ignoreEmptyBlocks)
      Writes the given message content to writer in its FIN format (raw SWIFT format for MT messages), controlling how to handle empty blocks.
      static void writeMessage​(SwiftMessage msg, java.io.Writer writer, boolean ignoreEmptyBlocks, boolean trimTagValues)
      Writes the given message content to writer in its FIN format (raw SWIFT format for MT messages), controlling how to handle empty blocks and spaces in field values.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SwiftWriter

        public SwiftWriter()
    • Method Detail

      • writeMessage

        public static void writeMessage​(SwiftMessage msg,
                                        java.io.Writer writer)
        Writes the given message content to writer in its FIN format (raw SWIFT format for MT messages).

        This method call will preserve and write empty blocks present in the message parameter, and also any starting or trailing spaces in the field values. For a fine-grain control on how to handle empty blocks and spaces in field values use writeMessage(SwiftMessage, Writer, boolean, boolean).

        As for the EOL characters, they are written as found in the message content. You can always write into String and use ensureEols(String) on the result if you need to ensure compliance with SWIFT.

        Parameters:
        msg - the message to write
        writer - the writer that will actually receive all the write operations
        Throws:
        java.lang.IllegalArgumentException - if msg or writer are null
      • writeMessage

        public static void writeMessage​(SwiftMessage msg,
                                        java.io.Writer writer,
                                        boolean ignoreEmptyBlocks)
        Writes the given message content to writer in its FIN format (raw SWIFT format for MT messages), controlling how to handle empty blocks.

        Starting and trailing spaces in field values will be preserve. For a fine-grain control on how to handle spaces in field values use writeMessage(SwiftMessage, Writer, boolean, boolean).

        As for the EOL characters, they are written as found in the message content. You can always write into String and use ensureEols(String) on the result if you need to ensure compliance with SWIFT.

        Parameters:
        msg - the message to write
        writer - the writer that will actually receive all the write operations
        ignoreEmptyBlocks - if true, empty blocks will not be written
        Throws:
        java.lang.IllegalArgumentException - if msg or writer are null
        Since:
        8.0.1
      • writeMessage

        public static void writeMessage​(SwiftMessage msg,
                                        java.io.Writer writer,
                                        boolean ignoreEmptyBlocks,
                                        boolean trimTagValues)
        Writes the given message content to writer in its FIN format (raw SWIFT format for MT messages), controlling how to handle empty blocks and spaces in field values.
        Parameters:
        msg - the message to write
        writer - the writer that will actually receive all the write operations
        ignoreEmptyBlocks - if true, empty blocks will not be written
        trimTagValues - if true, starting and trailing spaces in field values will be trimmed.
        Throws:
        java.lang.IllegalArgumentException - if msg or writer are null
        Since:
        8.0.2
      • getInternalXml

        public static java.lang.String getInternalXml​(SwiftMessage msg)
        Get a string with the internal xml representation of a message.
        Parameters:
        msg - the message to write
        Returns:
        a string with an internal xml representation of the message
        Throws:
        java.lang.IllegalArgumentException - if msg is null
      • writeBlock1

        public static void writeBlock1​(SwiftBlock1 b1,
                                       java.io.Writer writer)
        Write the given block to writer in its native SWIFT format
        Parameters:
        b1 - a not null block 1
        Since:
        7.8.6
      • writeBlock1

        public static java.lang.String writeBlock1​(SwiftBlock1 b1)
        Returns the given block content in its native SWIFT format
        Parameters:
        b1 - a not null block 1
        Since:
        7.8.6
      • writeBlock2

        public static void writeBlock2​(SwiftBlock2 b2,
                                       java.io.Writer writer)
        Write the given block to writer in its native SWIFT format
        Parameters:
        b2 - a not null block 2
        Since:
        7.8.6
      • writeBlock2

        public static java.lang.String writeBlock2​(SwiftBlock2 b2)
        Returns the given block content in its native SWIFT format
        Parameters:
        b2 - a not null block 2
        Since:
        7.8.6
      • writeBlock3

        public static void writeBlock3​(SwiftBlock3 b3,
                                       java.io.Writer writer)
        Write the given block to writer in its native SWIFT format
        Parameters:
        b3 - a not null block 3
        Since:
        7.8.6
      • writeBlock3

        public static java.lang.String writeBlock3​(SwiftBlock3 b3)
        Returns the given block content in its native SWIFT format
        Parameters:
        b3 - a not null block 3
        Since:
        7.8.6
      • writeBlock4

        public static void writeBlock4​(SwiftBlock4 b4,
                                       java.io.Writer writer)
        Write the given block to writer in its native SWIFT format
        Parameters:
        b4 - a not null block 4
        Since:
        7.8.6
      • writeBlock4

        public static java.lang.String writeBlock4​(SwiftBlock4 b4)
        Returns the given block content in its native SWIFT format
        Parameters:
        b4 - a not null block 4
        Since:
        7.8.6
      • writeBlock5

        public static void writeBlock5​(SwiftBlock5 b5,
                                       java.io.Writer writer)
        Write the given block to writer in its native SWIFT format
        Parameters:
        b5 - a not null block 5
        Since:
        7.8.6
      • writeBlock5

        public static java.lang.String writeBlock5​(SwiftBlock5 b5)
        Returns the given block content in its native SWIFT format
        Parameters:
        b5 - a not null block 5
        Since:
        7.8.6
      • ensureEols

        public static java.lang.String ensureEols​(java.lang.String content)
        Makes sure all EOLs are swift compatible by replacing any line break in the parameter String with CRLF
        Parameters:
        content - the complete or partial FIN text to process
        Returns:
        the source parameter with CRLF for all line breaks or an empty or incomplete string if an error occurs
        Since:
        7.10.4