com.xmlmill.config
Class Configurator

java.lang.Object
  |
  +--com.xmlmill.config.Configurator

public final class Configurator
extends java.lang.Object

The Configurator is responsible for reading the configuration properties from an (external) XML configuration file and making these available to the application.

You need to call the Configurator only once during the lifetime of your JVM session, as all PDXTransform sessions will ask the requested configuration attributes from this class.

The content of the configuration cannot be changed during the lifetime of the Configurator (in order to change the content of the configuration the config.xml file needs to be reread.

Since:
1.41
Version:
1.41
Author:
Stefan Geelen, support@xmlmill.com

Field Summary
static int JAXP_11
          A possible JAXP version
static int JAXP_12
          A possible JAXP version
static int JAXP_13
          A possible JAXP version
 
Method Summary
static void configure()
          Loads the configuration values from the default config.xml file.
static void configure(java.io.File f)
          Loads configuration from specified configuration file.
static void configure(java.io.File f, int i)
          Loads configuration from specified configuration file.
static void configure(int i)
          Loads the configuration values from the default config.xml file.
static void configure(java.lang.String s)
          Loads configuration from specified configuration file.
static void configure(java.lang.String s, int i)
          Loads configuration from specified configuration file.
static void configure(java.net.URL url)
          Loads configuration from specified configuration file.
static void configure(java.net.URL url, int i)
          Loads configuration from specified configuration file.
static boolean containsKey(java.lang.String key)
          Returns true if this Configurator contains a mapping for the specified key.
static java.lang.Object get(java.lang.String key)
          Returns specified value with the specified key in the configuration map.
static org.apache.commons.logging.Log getLogger()
          Returns the logger to use.
static boolean isConfigured()
          Returns if the configuration has been done.
static void reset()
          Resets (empties)the configuration map.
static void setErrorHandler(JAXPErrorHandler handler)
          Defines the behavior of the errorhandler when processing the configuration file.
static void setLogger(org.apache.commons.logging.Log l)
          Define the loggin instance to use.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JAXP_11

public static final int JAXP_11
A possible JAXP version

JAXP_12

public static final int JAXP_12
A possible JAXP version

JAXP_13

public static final int JAXP_13
A possible JAXP version
Method Detail

configure

public static final void configure()
                            throws javax.xml.parsers.ParserConfigurationException,
                                   org.xml.sax.SAXException,
                                   XMLMillFatalError,
                                   java.io.IOException
Loads the configuration values from the default config.xml file.

The default config.xml file is located in the xmlmill.jar package at following location: com/xmlmill/conf/config.xml.

Throws:
javax.xml.parsers.ParserConfigurationException - when a parser cannot be configurated.
org.xml.sax.SAXException - when a SAXException occurs.
XMLMillException - when a XMLMill exception occurs.
java.io.IOException - when a IOException exception occurs.
Since:
1.50

configure

public static final void configure(int i)
                            throws javax.xml.parsers.ParserConfigurationException,
                                   org.xml.sax.SAXException,
                                   XMLMillFatalError,
                                   java.io.IOException,
                                   XMLMillNotRecognizedException
Loads the configuration values from the default config.xml file.

The default config.xml file is located in the xmlmill.jar package at following location: com/xmlmill/conf/config.xml.

The JAXPVersion can be added to define a version different from the version defined in the configuration file.

Parameters:
i - int representing the JAXP version implemented.
Throws:
javax.xml.parsers.ParserConfigurationException - when a parser cannot be configurated.
org.xml.sax.SAXException - when a SAXException occurs.
XMLMillException - when a XMLMill exception occurs.
java.io.IOException - when a IOException exception occurs.
XMLMillNotRecognizedException - when the JAXP version is unknown.
Since:
2.20
See Also:
JAXP_11, JAXP_12, JAXP_13

configure

public static final void configure(java.lang.String s)
                            throws javax.xml.parsers.ParserConfigurationException,
                                   org.xml.sax.SAXException,
                                   XMLMillException,
                                   java.io.IOException
Loads configuration from specified configuration file.

Parameters:
s - String representing the configuration file (URL) The URL should be fully resolved. For example: http://www. xmlmill.com/test/config.xml or file:/c:/xmlmill/test/config.xml.
Throws:
javax.xml.parsers.ParserConfigurationException - when a parser cannot be configurated.
org.xml.sax.SAXException - when a SAXException occurs.
XMLMillException - when a XMLMill exception occurs.
java.io.IOException - when a IOException exception occurs.
Since:
1.50

configure

public static final void configure(java.lang.String s,
                                   int i)
                            throws javax.xml.parsers.ParserConfigurationException,
                                   org.xml.sax.SAXException,
                                   XMLMillException,
                                   java.io.IOException,
                                   XMLMillNotRecognizedException
Loads configuration from specified configuration file.

The JAXPVersion can be added to define a version different from the version defined in the configuration file.

Parameters:
s - String representing the configuration file (URL) The URL should be fully resolved. For example: http://www. xmlmill.com/test/config.xml or file:/c:/xmlmill/test/config.xml.
i - int representing the JAXP version implemented.
Throws:
XMLMillNotRecognizedException - when the JAXP version is unknown.
javax.xml.parsers.ParserConfigurationException - when a parser cannot be configurated.
org.xml.sax.SAXException - when a SAXException occurs.
XMLMillException - when a XMLMill exception occurs.
java.io.IOException - when a IOException exception occurs.
Since:
2.20
See Also:
JAXP_11, JAXP_12, JAXP_13

configure

public static final void configure(java.net.URL url)
                            throws javax.xml.parsers.ParserConfigurationException,
                                   org.xml.sax.SAXException,
                                   XMLMillException,
                                   java.io.IOException
Loads configuration from specified configuration file.

Parameters:
url - URL representing the configuration file The URL should be fully resolved. For example: http://www. xmlmill.com/test/config.xml or file:/c:/xmlmill/test/config.xml.
Throws:
javax.xml.parsers.ParserConfigurationException - when a parser cannot be configurated.
org.xml.sax.SAXException - when a SAXException occurs.
XMLMillException - when a XMLMill exception occurs.
java.io.IOException - when a IOException exception occurs.
Since:
1.50

configure

public static final void configure(java.net.URL url,
                                   int i)
                            throws javax.xml.parsers.ParserConfigurationException,
                                   org.xml.sax.SAXException,
                                   XMLMillException,
                                   java.io.IOException,
                                   XMLMillNotRecognizedException
Loads configuration from specified configuration file.

The JAXPVersion can be added to define a version different from the version defined in the configuration file.

Parameters:
url - URL representing the configuration file The URL should be fully resolved. For example: http://www. xmlmill.com/test/config.xml or file:/c:/xmlmill/test/config.xml.
i - int representing the JAXP version implemented.
Throws:
XMLMillNotRecognizedException - when the JAXP version is unknown.
javax.xml.parsers.ParserConfigurationException - when a parser cannot be configurated.
org.xml.sax.SAXException - when a SAXException occurs.
XMLMillException - when a XMLMill exception occurs.
java.io.IOException - when a IOException exception occurs.
Since:
1.50
See Also:
JAXP_11, JAXP_12, JAXP_13

configure

public static void configure(java.io.File f)
                      throws javax.xml.parsers.ParserConfigurationException,
                             org.xml.sax.SAXException,
                             XMLMillException,
                             java.io.IOException
Loads configuration from specified configuration file.

Parameters:
f - File representing the configuration file
Throws:
javax.xml.parsers.ParserConfigurationException - when a parser cannot be configurated.
org.xml.sax.SAXException - when a SAXException occurs.
XMLMillException - when a XMLMill exception occurs.
java.io.IOException - when a IOException exception occurs.
Since:
1.50

configure

public static void configure(java.io.File f,
                             int i)
                      throws javax.xml.parsers.ParserConfigurationException,
                             org.xml.sax.SAXException,
                             XMLMillException,
                             java.io.IOException,
                             XMLMillNotRecognizedException
Loads configuration from specified configuration file.

The JAXPVersion can be added to define a version different from the version defined in the configuration file.

Parameters:
f - File representing the configuration file
i - int representing the JAXP version implemented.
Throws:
XMLMillNotRecognizedException - when the JAXP version is unknown.
javax.xml.parsers.ParserConfigurationException - when a parser cannot be configurated.
org.xml.sax.SAXException - when a SAXException occurs.
XMLMillException - when a XMLMill exception occurs.
java.io.IOException - when a IOException exception occurs.
Since:
1.50
See Also:
JAXP_11, JAXP_12, JAXP_13

setErrorHandler

public static final void setErrorHandler(JAXPErrorHandler handler)
Defines the behavior of the errorhandler when processing the configuration file.

*** For internal use only ***

Defines whether or not to log and stop processing when a error or warning happens processing the configuration file.

Note:
This method will become protected in the next version of XMLMill. Do not use.

Parameters:
handler - the errors handler.
Since:
1.50
See Also:
JAXPErrorHandler

get

public static final java.lang.Object get(java.lang.String key)
Returns specified value with the specified key in the configuration map.

If the size of the configuration map is empty, the default configuration map (located at: com/xmlmill/conf/config.xml) will first be read.

Parameters:
key - with which the specified value is to be associated.
Returns:
Object representing the value (null if the key is not defined).
Since:
1.50

containsKey

public static final boolean containsKey(java.lang.String key)
Returns true if this Configurator contains a mapping for the specified key. Returns the specified value with the specified key in the configuration map.

Parameters:
key - whose presence in this Configurator is to be tested.
Returns:
true if this Configurator contains a mapping for the specified key.
Since:
1.50

isConfigured

public static final boolean isConfigured()
Returns if the configuration has been done.

Returns:
boolean true if the configuration is done, false otherwise.
Since:
1.50

reset

public static final void reset()
Resets (empties)the configuration map.

Note: It is important to know that the internal font-cache is NOT resetted.

Since:
1.50

setLogger

public static final void setLogger(org.apache.commons.logging.Log l)
Define the loggin instance to use.

Since:
3.00

getLogger

public static final org.apache.commons.logging.Log getLogger()
Returns the logger to use.

Since:
3.00