Class MxReadImpl
- java.lang.Object
-
- com.prowidesoftware.swift.model.mx.MxReadImpl
-
- All Implemented Interfaces:
MxRead
public class MxReadImpl extends java.lang.Object implements MxRead
Default implementation of theMxRead
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 Summary
Constructors Constructor Description MxReadImpl()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static AbstractMX
parse(java.lang.Class<? extends AbstractMX> targetClass, java.lang.String xml, java.lang.Class<?>[] classes)
Static parse implementation ofMxRead.read(Class, String, Class[])
static AbstractMX
parse(java.lang.Class<? extends AbstractMX> targetClass, java.lang.String xml, java.lang.Class<?>[] classes, MxReadParams params)
static AbstractMX
parse(java.lang.String xml, MxId id)
Static parse implementation ofMxRead.read(String, MxId)
static AbstractMX
parse(java.lang.String xml, MxId id, MxReadParams params)
AbstractMX
read(java.lang.Class<? extends AbstractMX> targetClass, java.lang.String xml, java.lang.Class<?>[] classes)
Readxml
into a message objectAbstractMX
read(java.lang.String xml, MxId id)
Parses the XML string content into a specific instance of Mx.
-
-
-
Method Detail
-
parse
public static AbstractMX parse(java.lang.Class<? extends AbstractMX> targetClass, java.lang.String xml, java.lang.Class<?>[] classes)
Static parse implementation ofMxRead.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 ofMxRead.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 blankjava.lang.NullPointerException
- if the XML parameter is null- Since:
- 9.0
-
parse
public static AbstractMX parse(java.lang.String xml, MxId id, MxReadParams params)
- Since:
- 9.2.6
-
read
public AbstractMX read(java.lang.Class<? extends AbstractMX> targetClass, java.lang.String xml, java.lang.Class<?>[] classes)
Description copied from interface:MxRead
Readxml
into a message object
-
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 interfaceMxRead
- Parameters:
xml
- a string containing an MX message in XML formatid
- 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
-
-