Class AbstractMX

    • Field Detail

      • DOCUMENT_LOCALNAME

        public static final java.lang.String DOCUMENT_LOCALNAME
        See Also:
        Constant Field Values
      • DEFAULT_ROOT_ELEMENT

        public static java.lang.String DEFAULT_ROOT_ELEMENT
        Default root element when an MX is serialized as XML including both AppHdr and Document
        Since:
        8.0.2
    • Constructor Detail

      • AbstractMX

        protected AbstractMX()
      • AbstractMX

        protected AbstractMX​(AppHdr appHdr)
    • Method Detail

      • read

        @Deprecated
        @ProwideDeprecated(phase2=SRU2023)
        protected static AbstractMX read​(java.lang.Class<? extends AbstractMX> targetClass,
                                         java.lang.String xml,
                                         java.lang.Class[] classes)
        Deprecated.
        use any of the available parse methods instead in either this class or the specific subclasses
      • parse

        public static AbstractMX parse​(java.lang.String xml)
        Parses the XML string containing the Document and optional AppHdr into a specific instance of MX message object. The message and header types and version is auto detected.

        The unmarshaller uses the default type adapters. For more parse options use parse(String, MxId, MxReadConfiguration).

        Parameters:
        xml - the XML content to parse
        Returns:
        parsed message or null if string content could not be parsed into an Mx
        Since:
        9.0.1
      • parse

        public static AbstractMX parse​(java.lang.String xml,
                                       MxId id)
        Parses the XML string containing the Document and optional AppHdr into a specific instance of MX message object. The header version, if present, is auto detected from its namespace.

        If the string is empty, does not contain an MX document, the message type cannot be detected or an error occur reading and parsing the message content; this method returns null.

        The implementation detects the message type and uses reflection to call the parser in the specific subclass.

        The unmarshaller uses the default type adapters. For more parse options use parse(String, MxId, MxReadConfiguration).

        Parameters:
        xml - string a string containing the Document of an MX message in XML format
        id - optional parameter to indicate the specific MX type to create; auto detected from namespace if null.
        Returns:
        parsed message or null if string content could not be parsed into an Mx
        Since:
        7.8.4
      • parse

        @Deprecated
        @ProwideDeprecated(phase2=SRU2023)
        public static AbstractMX parse​(java.io.File file,
                                       MxId id)
                                throws java.io.IOException
        Deprecated.
        use Lib.readFile(file) and any parse from String method
        Throws:
        java.io.IOException
      • parse

        public static AbstractMX parse​(org.w3c.dom.Element e)
        Parses the XML Element into a specific MX object. The Mx to create is detected from the namespace.
        Parameters:
        e - content to parse
        Returns:
        specific Mx instance, for example, MxCamt0010101; or null if XML cannot be parsed or specific Mx cannot be detected
        Since:
        9.0
      • parse

        public static AbstractMX parse​(java.lang.String xml,
                                       MxId id,
                                       MxReadConfiguration conf)
        Parses the XML string containing the Document and optional AppHdr into a specific instance of MX message object. The header version, if present, is auto detected from its namespace.

        If the string is empty, does not contain an MX document, the message type cannot be detected or an error occur reading and parsing the message content; this method returns null.

        The implementation detects the message type and uses reflection to call the parser in the specific subclass.

        Parameters:
        xml - string a string containing the Document of an MX message in XML format
        id - optional parameter to indicate the specific MX type to create; auto detected from namespace if null.
        conf - specific options for the unmarshalling or null to use the default parameters
        Returns:
        parsed message or null if string content could not be parsed into an Mx
        Since:
        9.2.6
      • fromJson

        protected static <T> T fromJson​(java.lang.String json,
                                        java.lang.Class<T> classOfT)
        Used by subclasses to implement JSON deserialization.
        Parameters:
        json - a JSON representation of an MX message
        classOfT - the specific MX subclass
        Returns:
        a specific deserialized MX message object
        Since:
        7.10.3
      • fromJson

        public static AbstractMX fromJson​(java.lang.String json)
        Creates an MX messages from its JSON representation.
        Parameters:
        json - a JSON representation of an MX message
        Returns:
        a specific deserialized MX message object, for example MxPain00100108
        Since:
        7.10.3
      • message

        @Deprecated
        @ProwideDeprecated(phase3=SRU2023)
        public java.lang.String message​(java.lang.String rootElement,
                                        boolean includeXMLDeclaration)
        Deprecated.
      • message

        public java.lang.String message​(MxWriteConfiguration conf)
        Get this message as an XML string.

        If the business header is set, the created XML will include both the 'AppHdr' and the 'Document' elements, under a the indicated or default root element. If the header is not present, the created XMl will only include the 'Document'. Both 'AppHdr' and 'Document' are generated with namespace declaration and if optional prefixes if present in the configuration.

        IMPORTANT: The name of the envelope element that binds a Header to the message to which it applies is implementation/network specific. The header root element ‘AppHdr’ and the ISO 20022 MessageDefinition root element ‘Document’ must always be sibling elements in any XML document, with the AppHdr element preceding the Document element.

        Parameters:
        conf - specific options for the serialization or null to use the default parameters
        Returns:
        the XML content or null if errors occur during serialization
      • header

        public java.lang.String header​(MxWriteParams params)
        Get this message AppHdr as an XML string.
        Since:
        9.2.6
      • document

        public java.lang.String document​(MxWriteParams params)
        Get this message Document as an XML string.
        Parameters:
        params - not null marshalling parameters
        Since:
        9.2.6
      • getClasses

        public abstract java.lang.Class[] getClasses()
        Get the classes associated with this message
        Since:
        7.7
      • getNamespace

        public abstract java.lang.String getNamespace()
        Get the XML namespace of the message
        Since:
        7.7
      • message

        @Deprecated
        @ProwideDeprecated(phase3=SRU2023)
        public java.lang.String message​(java.lang.String rootElement)
        Deprecated.
      • header

        public java.lang.String header()
        Get this message AppHdr as an XML string.

        The XML will not include the XML declaration, will bind the namespace to all elements without prefix and will use the default escape handler and content adapters.

        For more serialization options use header(MxWriteParams)

        Returns:
        the serialized header or null if header is not set or errors occur during serialization
        Since:
        7.8
      • header

        @Deprecated
        @ProwideDeprecated(phase3=SRU2023)
        public java.lang.String header​(java.lang.String prefix,
                                       boolean includeXMLDeclaration)
        Deprecated.
      • header

        @Deprecated
        @ProwideDeprecated(phase3=SRU2023)
        public java.lang.String header​(java.lang.String prefix,
                                       boolean includeXMLDeclaration,
                                       EscapeHandler escapeHandler)
        Deprecated.
      • document

        public java.lang.String document()
        Get this message Document as an XML string.

        The XML will not include the XML declaration, will bind the namespace to all elements using "Doc" as default prefix and will use the default escape handler. For more serialization options use document(MxWriteParams)

        Returns:
        document serialized into XML string or null if errors occur during serialization
        Since:
        7.8
      • document

        @Deprecated
        @ProwideDeprecated(phase3=SRU2023)
        public java.lang.String document​(java.lang.String prefix,
                                         boolean includeXMLDeclaration)
        Deprecated.
      • document

        @Deprecated
        @ProwideDeprecated(phase2=SRU2023)
        public java.lang.String document​(java.lang.String prefix,
                                         boolean includeXMLDeclaration,
                                         EscapeHandler escapeHandler)
        Deprecated.
      • xmlSource

        public javax.xml.transform.Source xmlSource()
        Convenience method to get this message XML as javax.xml.transform.Source.
        Returns:
        null if message() returns null or StreamSource in other case
        Since:
        7.7
        See Also:
        message()
      • message

        public java.lang.String message()
        Get this message as an XML string.

        If the header is present, then 'AppHdr' and 'Document' elements will be wrapped under a DEFAULT_ROOT_ELEMENT. Both header and document are generated with the corresponding namespaces and by default the prefix 'h' is used for the header and the prefix 'Doc' for the document.
        For more serialization options see message(MxWriteConfiguration)
        To serialize only the header or the document (without header) see header() and document()

        Specified by:
        message in class com.prowidesoftware.swift.model.AbstractMessage
        Returns:
        the XML content or null if errors occur during serialization
        Since:
        7.7
      • write

        @Deprecated
        @ProwideDeprecated(phase2=SRU2023)
        public void write​(java.io.File file)
                   throws java.io.IOException
        Deprecated.
        use message(MxWriteConfiguration) and handle write from String to file with plain Java API
        Throws:
        java.io.IOException
      • write

        @Deprecated
        @ProwideDeprecated(phase2=SRU2023)
        public void write​(java.io.OutputStream stream)
                   throws java.io.IOException
        Deprecated.
        use message(MxWriteConfiguration) and handle write from String to stream with plain Java API
        Throws:
        java.io.IOException
      • getBusinessHeader

        @Deprecated
        @ProwideDeprecated(phase4=SRU2023)
        public BusinessHeader getBusinessHeader()
        Deprecated.
        use getAppHdr() instead
        Returns:
        the business header or null if not set
        Since:
        7.7
      • setBusinessHeader

        @ProwideDeprecated(phase4=SRU2023)
        @Deprecated
        public void setBusinessHeader​(BusinessHeader businessHeader)
        Deprecated.
        use setAppHdr(AppHdr) instead
        Parameters:
        businessHeader - the header to set
        Since:
        7.8
      • getAppHdr

        public AppHdr getAppHdr()
        Returns:
        the business header or null if not set
        Since:
        9.0.1
      • setAppHdr

        public void setAppHdr​(AppHdr appHdr)
        Parameters:
        appHdr - the header to set
        Since:
        9.0.1
      • getMxId

        public MxId getMxId()
        Returns the MX message identification.
        Composed by the business process, functionality, variant and version.
        Returns:
        the constructed message id
        Since:
        7.7
      • getBusinessProcess

        public abstract java.lang.String getBusinessProcess()
        get the Alphabetic code in four positions (fixed length) identifying the Business Process
        Returns:
        the business process of the implementing class
        Since:
        7.7
      • getFunctionality

        public abstract int getFunctionality()
        Get the code identifying the Message Functionality
        Returns:
        the set functionality or null if not set
        Since:
        7.7
      • getVariant

        public abstract int getVariant()
        Get the Message variant
        Returns:
        the set variant or null if not set
        Since:
        7.7
      • getVersion

        public abstract int getVersion()
        Get the message version
        Returns:
        the set vesion or null if not set
        Since:
        7.7
      • element

        public org.w3c.dom.Element element()
      • element

        public org.w3c.dom.Element element​(jakarta.xml.bind.JAXBContext inputContext)
      • toJson

        public java.lang.String toJson()
        Get a JSON representation of this MX message.
        Specified by:
        toJson in interface com.prowidesoftware.JsonSerializable
        Since:
        7.10.3
      • targetNamespace

        public java.lang.String targetNamespace()
        Returns:
        same as getNamespace()
        Since:
        9.1.2