Package com.solab.iso8583.parse
Class ConfigParser
- java.lang.Object
-
- com.solab.iso8583.parse.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 Summary
Constructors Constructor Description ConfigParser()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T extends IsoMessage>
voidconfigureFromClasspathConfig(MessageFactory<T> mfact, java.lang.String path)
Configures a MessageFactory using the configuration file at the path specified (will be searched within the classpath using the MessageFactory's ClassLoader).static <T extends IsoMessage>
voidconfigureFromDefault(MessageFactory<T> mfact)
Configures a MessageFactory using the default configuration file j8583.xml.static <T extends IsoMessage>
voidconfigureFromReader(MessageFactory<T> mfact, java.io.Reader reader)
Configures a MessageFactory using the XML data obtained from the specified Reader.static <T extends IsoMessage>
voidconfigureFromUrl(MessageFactory<T> mfact, java.net.URL url)
This method attempts to open a stream from the XML configuration in the specified URL and configure the message factory from that config.static MessageFactory<IsoMessage>
createDefault()
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.static MessageFactory<IsoMessage>
createDefault(java.lang.ClassLoader loader)
Creates a message factory configured from the default file, which is j8583.xml located in the root of the classpath, using the specified ClassLoader.static MessageFactory<IsoMessage>
createFromClasspathConfig(java.lang.ClassLoader loader, java.lang.String path)
Creates a message factory from the specified path inside the classpath, using MessageFactory's ClassLoader.static MessageFactory<IsoMessage>
createFromClasspathConfig(java.lang.String path)
Creates a message factory from the specified path inside the classpath, using the specified ClassLoader.static MessageFactory<IsoMessage>
createFromReader(java.io.Reader reader)
Creates a messageFactory from the XML contained in the specified Reader.static MessageFactory<IsoMessage>
createFromUrl(java.net.URL url)
Creates a message factory from the file located at the specified URL.protected static <T extends IsoMessage>
FieldParseInfogetParser(org.w3c.dom.Element f, MessageFactory<T> mfact)
protected static <M extends IsoMessage>
IsoValue<?>getTemplateField(org.w3c.dom.Element f, MessageFactory<M> mfact, boolean toplevel)
Creates an IsoValue from the XML definition in a message template.protected static <T extends IsoMessage>
voidparse(MessageFactory<T> mfact, org.xml.sax.InputSource source)
Reads the XML from the stream and configures the message factory with its values.protected static <T extends IsoMessage>
voidparseGuides(org.w3c.dom.NodeList nodes, MessageFactory<T> mfact)
protected static <T extends IsoMessage>
voidparseHeaders(org.w3c.dom.NodeList nodes, MessageFactory<T> mfact)
protected static <T extends IsoMessage>
voidparseTemplates(org.w3c.dom.NodeList nodes, MessageFactory<T> mfact)
-
-
-
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 IsoMessage> IsoValue<?> 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.
-
getParser
protected static <T extends IsoMessage> FieldParseInfo getParser(org.w3c.dom.Element f, MessageFactory<T> mfact)
-
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
-
-