Class ServiceMessage21

  • All Implemented Interfaces:
    JsonSerializable

    public class ServiceMessage21
    extends AbstractMT
    Generic MT representation for service messages with service id 21 = GPA/FIN Message (ACK/NAK/UAK/UNK). It can hold both a positive or negative acknowledge.
    For system messages, category 0, see the MT0xx classes.
    Since:
    7.10.4
    • Constructor Detail

      • ServiceMessage21

        public ServiceMessage21​(SwiftMessage aMessage)
        Throws:
        java.lang.RuntimeException - if the message is not a service message with service id 21 (meaning positive or negative acknowledge)
      • ServiceMessage21

        public ServiceMessage21​(java.io.InputStream stream)
                         throws java.io.IOException
        Creates a new ServiceMessage21 by parsing a input stream with the message content in its swift FIN format, using "UTF-8" as encoding.
        If the message content is null or cannot be parsed, the internal message object will be initialized (blocks will be created) but empty.
        If the stream contains multiple messages, only the first one will be parsed.
        Parameters:
        stream - an input stream in UTF-8 encoding with the MT message in its FIN swift format.
        Throws:
        java.io.IOException
      • ServiceMessage21

        public ServiceMessage21​(java.io.File file)
                         throws java.io.IOException
        Creates a new ServiceMessage21 by parsing a file with the message content in its swift FIN format.
        If the file content is null or cannot be parsed as a message, the internal message object will be initialized (blocks will be created) but empty.
        If the file contains multiple messages, only the first one will be parsed.
        Parameters:
        file - a file with the MT message in its FIN swift format.
        Throws:
        java.io.IOException
      • ServiceMessage21

        public ServiceMessage21​(java.lang.String fin)
        Creates a new ServiceMessage21 by parsing a String with the message content in its swift FIN format.
        If the fin parameter is null or the message cannot be parsed, the internal message object will be initialized (blocks will be created) but empty.
        If the string contains multiple messages, only the first one will be parsed.
        Parameters:
        fin - a string with the MT message in its FIN swift format
        Throws:
        java.lang.RuntimeException - if the message is not a service message with service id 21 (meaning positive or negative acknowledge)
    • Method Detail

      • newInstance

        public static AbstractMT newInstance​(SwiftMessage swiftMessage)
        Throws:
        java.lang.RuntimeException - if the message is not a service message with service id 21 (meaning positive or negative acknowledge)
      • parse

        public static ServiceMessage21 parse​(MtSwiftMessage m)
        Creates an ServiceMessage21 initialized with the parameter MtSwiftMessage.
        Parameters:
        m - swift message with the ServiceMessage21 content
        Returns:
        the created object or null if the parameter is null
        See Also:
        ServiceMessage21(String)
      • parse

        public static ServiceMessage21 parse​(java.io.InputStream stream)
                                      throws java.io.IOException
        Creates a new ServiceMessage21 by parsing a input stream with the message content in its swift FIN format, using "UTF-8" as encoding.
        If the stream contains multiple messages, only the first one will be parsed.
        Parameters:
        stream - an input stream in UTF-8 encoding with the MT message in its FIN swift format.
        Returns:
        a new instance of ServiceMessage21 or null if stream is null or the message cannot be parsed
        Throws:
        java.io.IOException
      • parse

        public static ServiceMessage21 parse​(java.io.File file)
                                      throws java.io.IOException
        Creates a new ServiceMessage21 by parsing a file with the message content in its swift FIN format.
        If the file contains multiple messages, only the first one will be parsed.
        Parameters:
        file - a file with the MT message in its FIN swift format.
        Returns:
        a new instance of ServiceMessage21 or null if; file is null, does not exist, can't be read, is not a file or the message cannot be parsed
        Throws:
        java.io.IOException
      • parse

        public static ServiceMessage21 parse​(java.lang.String fin)
        Creates a new ServiceMessage21 by parsing a String with the message content in its swift FIN format.
        If the file contains multiple messages, only the first one will be parsed.
        Parameters:
        fin - a string with the MT message in its FIN swift format
        Returns:
        a new instance of ServiceMessage21 or null if; fin is null or the message cannot be parsed
        Throws:
        java.lang.RuntimeException - if the message is not a service message with service id 21 (meaning positive or negative acknowledge)
      • mtId

        public static MtId mtId()
        The identifier for system messages will always be gpa.021
        Returns:
        gpa.021
        Since:
        8.0.3
      • getMessageType

        public java.lang.String getMessageType()
        Will always return null because service messages do not contain a message type.
        Specified by:
        getMessageType in class AbstractMT
        Returns:
        the message type number of this MT
      • isAck

        public final boolean isAck()
        Returns true if this message is an ACK (positive acknowledge). This is determined by testing if the value of field 451 is 0. If Field 451 is not present, returns false.
      • isNack

        public final boolean isNack()
        Returns true if this message is an NACK (negative acknowledge). This is determined by testing if the value of field 451 is 1. If Field 451 is not present, returns false.
      • getErrorCode

        public java.lang.String getErrorCode()
        Returns the error code present in NAK messages in field 405
        Returns:
        error code found or null if the error code field is not present
      • getErrorLine

        public java.lang.String getErrorLine()
        Returns the error line present in NAK messages in field 405
        Returns:
        error code found or null if the error code field is not present
      • getField177

        public Field177 getField177()
        Local date time of the submitting user message on to the SWIFT network
        Since:
        8.0.3
      • getField451

        public Field451 getField451()
        The ACK/NAK flag field
        Since:
        8.0.3
      • getField108

        public Field108 getField108()
        gets the MUR field
        Since:
        8.0.3
      • getMtId

        public MtId getMtId()
        Description copied from class: AbstractMT
        Returns the MT message identification.
        Composed by the business process, message type and variant. Example: fin.103.STP
        Overrides:
        getMtId in class AbstractMT
        Returns:
        gpa.021
        Since:
        8.0.3