Class ConfigParser


  • public class ConfigParser
    extends java.lang.Object
    This class is used to parse a XML configuration file and configure a MessageFactory with the values from it.
    • Constructor Detail

      • ConfigParser

        public ConfigParser()
    • Method Detail

      • createDefault

        public static MessageFactory<IsoMessage> createDefault​(java.lang.ClassLoader loader)
                                                        throws java.io.IOException
        Creates a message factory configured from the default file, which is j8583.xml located in the root of the classpath, using the specified ClassLoader.
        Throws:
        java.io.IOException
      • createDefault

        public static MessageFactory<IsoMessage> createDefault()
                                                        throws java.io.IOException
        Creates a message factory configured from the default file, which is j8583.xml located in the root of the classpath, using the MessageFactory's ClassLoader.
        Throws:
        java.io.IOException
      • createFromClasspathConfig

        public static MessageFactory<IsoMessage> createFromClasspathConfig​(java.lang.String path)
                                                                    throws java.io.IOException
        Creates a message factory from the specified path inside the classpath, using the specified ClassLoader.
        Throws:
        java.io.IOException
      • createFromClasspathConfig

        public static MessageFactory<IsoMessage> createFromClasspathConfig​(java.lang.ClassLoader loader,
                                                                           java.lang.String path)
                                                                    throws java.io.IOException
        Creates a message factory from the specified path inside the classpath, using MessageFactory's ClassLoader.
        Throws:
        java.io.IOException
      • createFromUrl

        public static MessageFactory<IsoMessage> createFromUrl​(java.net.URL url)
                                                        throws java.io.IOException
        Creates a message factory from the file located at the specified URL.
        Throws:
        java.io.IOException
      • createFromReader

        public static MessageFactory<IsoMessage> createFromReader​(java.io.Reader reader)
                                                           throws java.io.IOException
        Creates a messageFactory from the XML contained in the specified Reader.
        Throws:
        java.io.IOException
      • parseHeaders

        protected static <T extends IsoMessage> void parseHeaders​(org.w3c.dom.NodeList nodes,
                                                                  MessageFactory<T> mfact)
                                                           throws java.io.IOException
        Throws:
        java.io.IOException
      • parseTemplates

        protected static <T extends IsoMessage> void parseTemplates​(org.w3c.dom.NodeList nodes,
                                                                    MessageFactory<T> mfact)
                                                             throws java.io.IOException
        Throws:
        java.io.IOException
      • getTemplateField

        protected static <M extends IsoMessageIsoValue<?> getTemplateField​(org.w3c.dom.Element f,
                                                                             MessageFactory<M> mfact,
                                                                             boolean toplevel)
        Creates an IsoValue from the XML definition in a message template. If it's for a toplevel field and the message factory has a codec for this field, that codec is assigned to that field. For nested fields, a CompositeField is created and populated.
      • parseGuides

        protected static <T extends IsoMessage> void parseGuides​(org.w3c.dom.NodeList nodes,
                                                                 MessageFactory<T> mfact)
                                                          throws java.io.IOException
        Throws:
        java.io.IOException
      • parse

        protected static <T extends IsoMessage> void parse​(MessageFactory<T> mfact,
                                                           org.xml.sax.InputSource source)
                                                    throws java.io.IOException
        Reads the XML from the stream and configures the message factory with its values.
        Parameters:
        mfact - The message factory to be configured with the values read from the XML.
        source - The InputSource containing the XML configuration.
        Throws:
        java.io.IOException
      • configureFromDefault

        public static <T extends IsoMessage> void configureFromDefault​(MessageFactory<T> mfact)
                                                                throws java.io.IOException
        Configures a MessageFactory using the default configuration file j8583.xml. This is useful if you have a MessageFactory created using Spring for example.
        Throws:
        java.io.IOException
      • configureFromUrl

        public static <T extends IsoMessage> void configureFromUrl​(MessageFactory<T> mfact,
                                                                   java.net.URL url)
                                                            throws java.io.IOException
        This method attempts to open a stream from the XML configuration in the specified URL and configure the message factory from that config.
        Throws:
        java.io.IOException
      • configureFromClasspathConfig

        public static <T extends IsoMessage> void configureFromClasspathConfig​(MessageFactory<T> mfact,
                                                                               java.lang.String path)
                                                                        throws java.io.IOException
        Configures a MessageFactory using the configuration file at the path specified (will be searched within the classpath using the MessageFactory's ClassLoader). This is useful for configuring Spring-bound instances of MessageFactory for example.
        Throws:
        java.io.IOException
      • configureFromReader

        public static <T extends IsoMessage> void configureFromReader​(MessageFactory<T> mfact,
                                                                      java.io.Reader reader)
                                                               throws java.io.IOException
        Configures a MessageFactory using the XML data obtained from the specified Reader.
        Throws:
        java.io.IOException