Class MxReadImpl

  • All Implemented Interfaces:
    MxRead

    public class MxReadImpl
    extends java.lang.Object
    implements MxRead
    Default implementation of the MxRead interface to parse XML strings into Mx message objects.

    The implementation is not a straight forward jaxb unmarsahlling. Some remarks:

    • The parser uses a SAX reader, to extract only the AppHdr and Document portions of the source XML, ignoring any container wrapper elements.
    • The parser is not namespace aware for general ISO 20022 elements, because the dictionary model classes in the library are not bounded to any specific namespace. This is due to the fact that the library is generated as a flat shared collection of elements, where the same element implementation is potentially used by many specific ISO 20022 messages. This is a special feature of the model, that is not a direct jaxb generation from hundreds of ISO schemas with each type in its own package, but a custom jaxb process to produce a shareable dictionary for the elements with minimal custom bindings. Notice however xsys messages do use namespace for the shared schemas such as Sw, SwInt, etc...
    • For the header, multiple variants are supported. The parser detects the specific header to parse using the namespace at the AppHdr element. By default it tries to parse the content as head.001.001.01.

    This is the default implementation used for the direct parse calls in MX messages.

    Since:
    9.0
    • Constructor Detail

      • MxReadImpl

        public MxReadImpl()
    • Method Detail

      • parse

        public static AbstractMX parse​(java.lang.Class<? extends AbstractMX> targetClass,
                                       java.lang.String xml,
                                       java.lang.Class<?>[] classes)
        Static parse implementation of MxRead.read(Class, String, Class[])
        Parameters:
        xml - the XML to parse, should contain the Document, and optional AppHdr and any type of wrapper elements
        Since:
        8.0.4
      • parse

        public static AbstractMX parse​(java.lang.Class<? extends AbstractMX> targetClass,
                                       java.lang.String xml,
                                       java.lang.Class<?>[] classes,
                                       MxReadParams params)
        Since:
        9.2.6
      • parse

        public static AbstractMX parse​(java.lang.String xml,
                                       MxId id)
        Static parse implementation of MxRead.read(String, MxId)
        Returns:
        parsed message or null if XML is malformed or unrecognized as MX message
        Throws:
        java.lang.IllegalArgumentException - if the XML parameter is blank
        java.lang.NullPointerException - if the XML parameter is null
        Since:
        9.0
      • read

        public AbstractMX read​(java.lang.Class<? extends AbstractMX> targetClass,
                               java.lang.String xml,
                               java.lang.Class<?>[] classes)
        Description copied from interface: MxRead
        Read xml into a message object
        Specified by:
        read in interface MxRead
        Parameters:
        targetClass - class of the message to be read
        xml - the string with the message
        classes - classes for the context
        Returns:
        parsed message or null if string content could not be parsed into an Mx
      • read

        public AbstractMX read​(java.lang.String xml,
                               MxId id)
        Parses the XML string content into a specific instance of Mx.

        If the string is empty, does not contain any MX message, 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 Mx subclass.

        If header is present, it is also parsed into the message object.

        Specified by:
        read in interface MxRead
        Parameters:
        xml - a string containing an MX message in XML format
        id - optional parameter to indicate the specific MX type to create; autodetected from namespace if null.
        Returns:
        parser message or null if string content could not be parsed into an Mx
        Since:
        7.8.4