Difference between revisions of "XMLConfig"

From GreenVulcano Wiki
Jump to: navigation, search
 
(9 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
Class FQN: '''it.greenvulcano.configuration.XMLConfig'''
 
Class FQN: '''it.greenvulcano.configuration.XMLConfig'''
  
==Following the XMLConfig public static methods==
+
==XMLConfig public static methods==
 
<syntaxhighlight lang="java5">
 
<syntaxhighlight lang="java5">
 
/**
 
/**
    * Set the entity resolver used to resolve entities into the configuration
+
* Reads a value. If the XPath selects many nodes the values are appended
    * files.
+
* together.
    *  
+
*  
    * @param entityResolver
+
* @param file
    *        EntityResolver to use in order to resolve entity. If
+
*        file to read
    *        <code>null</code> is specified then the default XML mechanism is
+
* @param xpath
    *        used.
+
*        parameter to read specified as absolute path to the root of the
    *  
+
*        file.
    * @see #setDefaultEntityResolver()
+
*  
    */
+
* @return the searched value or null if the XPath select no
    public static synchronized void setEntityResolver(EntityResolver entityResolver)
+
*         node.
    {
+
*
         if (isFiringEvents) {
+
* @throws XMLConfigException
            fireConfigurationEvents();
+
*         if some error occurs.
        }
+
*
        XMLConfig.entityResolver = entityResolver;
+
*/
    }
+
public static String get(String file, String xpath) throws XMLConfigException
  
    /**
+
/**
    * Use the default entity resolver to resolve entities into the
+
* Reads a value. If the XPath selects many nodes the values are appended
    * configuration files. The default entity resolver does not resolve
+
* together.
    * anything.
+
*  
    *  
+
* @param node
    * @see #setEntityResolver(org.xml.sax.EntityResolver)
+
*        base for XPath
    */
+
* @param xpath
    public static synchronized void setDefaultEntityResolver()
+
*        parameter to read specified as relative path to the node.
 +
*  
 +
* @return the searched value or null if the XPath selects no node.
 +
*
 +
* @throws XMLConfigException
 +
*        if some error occurs.
 +
*
 +
*/
 +
public static String get(Node node, String xpath) throws XMLConfigException
  
    /**
+
/**
    * Return the entity resolver for the configuration.
+
* Reads a value. If the XPath selects many nodes the values are appended
    *  
+
* together.
    * @return the entity resolver for the configuration
+
*  
    */
+
* @param file
    public static synchronized EntityResolver getEntityResolver()
+
*        file to read
    {
+
* @param xpath
        return entityResolver;
+
*        parameter to read specified as absolute path to the root of the
    }
+
*        file.
 +
* @param defaultValue
 +
*        default value
 +
*
 +
* @return the searched value or the specified default value if the XPath
 +
*        selects no node or an error occurs.
 +
*
 +
*/
 +
public static String get(String file, String xpath, String defaultValue)
  
    /**
+
/**
    * Load a configuration file and, if necessary, notifies registered
+
* Reads a value. If the XPath selects many nodes the values are appended
    * listeners. This method can be used in order to preload the configuration
+
* together.
    * file.
+
*  
    *  
+
* @param node
    * @param file
+
*        base node for XPath
    *        the file to read
+
* @param xpath
    * @return the complete URL used to load the file.
+
*        parameter to read specified as relative path to node.
    * @exception XMLConfigException
+
* @param defaultValue
    *           if error occurs
+
*        default value
    */
+
*
    public static synchronized URL load(String file) throws XMLConfigException
+
* @return the searched value or the specified default value if the XPath
    {
+
*        select no node or an error occurs.
        return load(file, null, false, true);
+
*
    }
+
*/
 +
public static String get(Node node, String xpath, String defaultValue)
  
    /**
+
/**
    * Load a configuration file and, if necessary, notifies registered
+
* Reads a single encrypted value.
    * listeners. This method can be used in order to preload the configuration
+
*  
    * file.
+
* @param file
    *
+
*        file to read
    * @param file
+
* @param xpath
    *        the file to read
+
*        parameter to read specified as absolute path to the root of the
    * @param classLoader
+
*        file.
    *        the class loader to use to retrieve the file to read
+
* @param keyId
    * @param force
+
*        the key id to be used for decryption, if null or empty is used
    *        force the reload of file if already present in cache
+
*        DEFAULT_KEY_ID
    * @param canBeReloaded
+
* @param canBeClear
    *        flag that indicates if this file can be changed and can be
+
*        if true the data can be unencrypted
    *       reloaded
+
*  
    * @return the complete URL used to load the file.
+
* @return the searched value or null if the XPath select no node.
    * @exception XMLConfigException
+
* @throws XMLConfigException
    *           if error occurs
+
*         if some error occurs.
    */
+
*
    public static synchronized URL load(String file, ClassLoader classLoader, boolean force, boolean canBeReloaded)
+
*/
            throws XMLConfigException
+
public static String getDecrypted(String file, String xpath, String keyId, boolean canBeClear)
    {
+
        throws XMLConfigException
        // Load a configuration file and caches it.
 
        // If the file is already loaded, noting happens.
 
        //
 
        getDocument(file, classLoader, force, canBeReloaded);
 
  
        // Return the complete used URL
+
/**
         //
+
* Reads a single encrypted value.
         return urls.get(file);
+
*
    }
+
* @param node
 +
*        base for XPath
 +
* @param xpath
 +
*        parameter to read specified as relative path to the node.
 +
* @param keyId
 +
*        the key id to be used for decryption, if null or empty is used
 +
*        DEFAULT_KEY_ID
 +
* @param canBeClear
 +
*        if true the data can be unencrypted
 +
*
 +
* @return the searched value or null if the XPath selects no node.
 +
*
 +
* @throws XMLConfigException
 +
*         if some error occurs.
 +
*/
 +
public static String getDecrypted(Node node, String xpath, String keyId, boolean canBeClear)
 +
        throws XMLConfigException
 +
   
 +
/**
 +
* Reads a single encrypted value.
 +
*
 +
* @param file
 +
*        file to read
 +
* @param xpath
 +
*        parameter to read specified as absolute path to the root of the
 +
*        file.
 +
* @param keyId
 +
*        the key id to be used for decryption, if null or empty is used
 +
*        DEFAULT_KEY_ID
 +
* @param canBeClear
 +
*        if true the data can be unencrypted
 +
* @param defaultValue
 +
*        default value
 +
*
 +
* @return the searched value or the specified default value if the XPath
 +
*         select no node or an error occurs.
 +
*
 +
*/
 +
public static String getDecrypted(String file, String xpath, String keyId, boolean canBeClear, String defaultValue)
  
    /**
+
/**
    * Discard all cached configuration files, notifies all registered
+
* Reads a single encrypted value.
    * listeners, reload discarded files and notifies all registered listeners.
+
*
    *  
+
* @param node
    * @exception XMLConfigException
+
*        base node for XPath
    *           if error occurs
+
* @param xpath
    */
+
*        parameter to read specified as relative path to node.
    public static synchronized void reloadAll() throws XMLConfigException
+
* @param keyId
    {
+
*        the key id to be used for decryption, if null or empty is used
        baseProps = null;
+
*        DEFAULT_KEY_ID
 +
* @param canBeClear
 +
*       if true the data can be unencrypted
 +
* @param defaultValue
 +
*        default value
 +
*
 +
* @return the searched value or the specified default value if the XPath
 +
*        select no node or an error occurs.
 +
*
 +
*/
 +
public static String getDecrypted(Node node, String xpath, String keyId, boolean canBeClear, String defaultValue)
  
         xpathAPI.reset();
+
/**
 +
* Reads a single encrypted value.
 +
*
 +
* @param file
 +
*        file to read
 +
* @param xpath
 +
*        parameter to read specified as absolute path to the root of the
 +
*        file.
 +
*
 +
*        Sets the key id as DEFAULT_KEY_ID and canBeClear at true
 +
*
 +
* @return the searched value or null if the XPath select no node.
 +
* @throws XMLConfigException
 +
*         if some error occurs.
 +
*
 +
*/
 +
public static String getDecrypted(String file, String xpath) throws XMLConfigException
  
        if (isFiringEvents) {
+
/**
            fireConfigurationEvents();
+
* Reads a single encrypted value.
        }
+
*
        // Obtains loaded configuration file names
+
* @param node
        //
+
*        base for XPath
        Set<String> keys = reloadableDocuments.keySet();
+
* @param xpath
        String[] arr = new String[keys.size()];
+
*        parameter to read specified as relative path to the node.
         keys.toArray(arr);
+
*
 +
*        Sets the key id as DEFAULT_KEY_ID and canBeClear at true
 +
*
 +
* @return the searched value or null if the XPath select no node.
 +
*
 +
* @throws XMLConfigException
 +
*         if some error occurs.
 +
*
 +
*/
 +
public static String getDecrypted(Node node, String xpath) throws XMLConfigException
  
        // Discard all and notify listeners
+
/**
         //
+
* Reads a single encrypted value.
        discardAll();
+
*
 +
* @param file
 +
*        file to read
 +
* @param xpath
 +
*        parameter to read specified as absolute path to the root of the
 +
*        file.
 +
* @param defaultValue
 +
*        default value
 +
*
 +
*        Sets the key id as DEFAULT_KEY_ID and canBeClear at true
 +
*
 +
* @return the searched value or the specified default value if the XPath
 +
*         select no node or an error occurs.
 +
*
 +
*/
 +
public static String getDecrypted(String file, String xpath, String defaultValue)
  
        // Reload files
+
/**
        //
+
* Reads a single encrypted value.
        for (int i = 0; i < arr.length; ++i) {
+
*
            load(arr[i]);
+
* @param node
         }
+
*        base node for XPath
    }
+
* @param xpath
 +
*        parameter to read specified as relative path to node.
 +
* @param defaultValue
 +
*        default value
 +
*
 +
*        Sets the key id as DEFAULT_KEY_ID and canBeClear at true
 +
*
 +
* @return the searched value or the specified default value if the XPath
 +
*         select no node or an error occurs.
 +
*
 +
*/
 +
public static String getDecrypted(Node node, String xpath, String defaultValue)
  
    /**
+
/**
    * If loaded discard the given file and notifies all registered listeners,
+
* Decrypt a string encrypted by default XMLConfig key.
    * then reload the given file (only if it was previously loaded) and
+
*  
    * notifies all registered listeners.
+
* @param value
    *  
+
*        the value to decrypt
    * @param file
+
*
    *        the file to reload
+
* @return the decrypted value or value if not encrypted
    * @exception XMLConfigException
+
* @throws XMLConfigException
    *           if error occurs
+
*         if some error occurs.
    */
+
*
    public static synchronized void reload(String file) throws XMLConfigException
+
*/
    {
+
public static String getDecrypted(String value) throws XMLConfigException
        baseProps = null;
 
  
         xpathAPI.reset();
+
/**
 +
* Encrypt a string using default XMLConfig key.
 +
*
 +
* @param value
 +
*        the value to encrypt
 +
*
 +
* @return the encrypted value
 +
* @throws XMLConfigException
 +
*         if some error occurs.
 +
*
 +
*/
 +
public static String getEncrypted(String value) throws XMLConfigException
  
        if (isFiringEvents) {
+
/**
            fireConfigurationEvents();
+
* Return an integer parameter.
        }
+
* This method uses get() to obtain the value, then convert it
        boolean mustReload = reloadableDocuments.containsKey(file);
+
* to an integer.
         if (mustReload) {
+
*
            discard(file);
+
* @param file
            load(file);
+
* @param xpath
        }
+
* @return the searched integer value from the configuration.
    }
+
*
 +
* @throws XMLConfigException
 +
*         if any error occurs
 +
*/
 +
public static int getInteger(String file, String xpath) throws XMLConfigException
  
    /**
+
/**
    * Discard all cached files and notifies all listeners.
+
* Return an integer parameter.
    */
+
* This method uses get() to obtain the value, then convert it
    public static synchronized void discardAll()
+
* to an integer.
    {
+
*
        baseProps = null;
+
* @param node
 +
*        base node for XPath
 +
* @param xpath
 +
*        parameter to read specified as relative path to node.
 +
*
 +
* @return the searched integer value from the configuration.
 +
*
 +
* @throws XMLConfigException
 +
*        if an error occurs
 +
*/
 +
public static int getInteger(Node node, String xpath) throws XMLConfigException
  
         xpathAPI.reset();
+
/**
 +
* Return an integer parameter.
 +
* This method uses get() to obtain the value, then convert it
 +
* to an integer.
 +
*
 +
* @param file
 +
*        the configuration file
 +
* @param xpath
 +
*        the XPath to search
 +
* @param defaultValue
 +
*        value to return if XPath not match
 +
* @return the parameter value. If the parameter does not exists or an error
 +
*         occurs then the specified default value will be returned.
 +
*
 +
*/
 +
public static int getInteger(final String file, final String xpath, final int defaultValue)
  
        if (isFiringEvents) {
+
/**
            fireConfigurationEvents();
+
* Return an integer parameter.
        }
+
* This method uses get() to obtain the value, then convert it
        Set<String> keys = reloadableDocuments.keySet();
+
* to an integer.
         String[] arr = new String[keys.size()];
+
*
        keys.toArray(arr);
+
* @param node
        Map<String, URL> oldUrls = urls;
+
*        base node for XPath
        reloadableDocuments = new HashMap<String, Document>();
+
* @param xpath
        splitDocuments = new HashMap<String, Document>();
+
*        parameter to read specified as relative path to node.
        urls = new HashMap<String, URL>();
+
* @param defaultValue
 +
*        default value
 +
*
 +
* @return the searched value or the specified default value if the XPath
 +
*         select no node or an error occurs.
 +
*
 +
*/
 +
public static int getInteger(Node node, String xpath, int defaultValue)
  
        for (int i = 0; i < arr.length; ++i) {
+
/**
            ConfigurationEvent event = new ConfigurationEvent(ConfigurationEvent.EVT_FILE_REMOVED, arr[i],
+
* Returns a long parameter.
                    oldUrls.get(arr[i]));
+
* This method uses get() to obtain the value, then converts it
            prepareConfigurationEvent(event, false);
+
* to a long.
 +
*
 +
* @param file
 +
* @param xpath
 +
* @return the searched long value from the configuration.
 +
*
 +
* @throws XMLConfigException
 +
*        if an error occurs
 +
*/
 +
public static long getLong(String file, String xpath) throws XMLConfigException
  
            List<String> splits = mainToSplitFile.get(arr[i]);
+
/**
            if (splits != null) {
+
* Returns a long parameter.
                for (String split : splits) {
+
* This method uses get() to obtain the value, then convert it
                    ConfigurationEvent eventS = new ConfigurationEvent(ConfigurationEvent.EVT_FILE_REMOVED, split,
+
* to a long.
                            oldUrls.get(arr[i]));
+
*
                    prepareConfigurationEvent(eventS, false);
+
* @param node
                }
+
*        base node for XPath
            }
+
* @param xpath
         }
+
*        parameter to read specified as relative path to node.
    }
+
*
 +
* @return the searched long value from the configuration.
 +
*
 +
* @throws XMLConfigException
 +
*         if an error occurs
 +
*/
 +
public static long getLong(Node node, String xpath) throws XMLConfigException
  
    /**
+
/**
    * Discard the given file. If the file was previously loaded then the
+
* Returns a long parameter.
    * listeners will be notified, otherwise no action will be taken.
+
* This method uses get() to obtain the value, then convert it
    *  
+
* to a long.
    * @param file
+
*  
    *       the file to discard
+
* @param file
    */
+
* @param xpath
    public static synchronized void discard(String file)
+
* @param defaultValue
    {
+
*
        baseProps = null;
+
* @return the parameter value. If the parameter does not exists or an error
 +
*        occurs then the specified default value will be returned.
 +
*
 +
*/
 +
public static long getLong(String file, String xpath, long defaultValue)
  
         xpathAPI.reset();
+
/**
 +
* Returns a long parameter.
 +
* This method uses get() to obtain the value, then convert it
 +
* to a long.
 +
*
 +
* @param node
 +
*        base node for XPath
 +
* @param xpath
 +
*        parameter to read specified as relative path to node.
 +
* @param defaultValue
 +
*
 +
* @return the searched value or the specified default value if the XPath
 +
*         select no node or an error occurs.
 +
*
 +
*/
 +
public static long getLong(Node node, String xpath, long defaultValue)
  
        if (isFiringEvents) {
+
/**
            fireConfigurationEvents();
+
* Returns a double parameter.
        }
+
* This method uses get() to obtain the value, then convert it
        if (reloadableDocuments.containsKey(file)) {
+
* to a double.
            URL url = urls.get(file);
+
*
            reloadableDocuments.remove(file);
+
* @param file
            urls.remove(file);
+
* @param xpath
            documents.remove(file);
+
* @return the searched double value from the configuration.
            ConfigurationEvent event = new ConfigurationEvent(ConfigurationEvent.EVT_FILE_REMOVED, file, url);
+
*
            prepareConfigurationEvent(event, true);
+
* @throws XMLConfigException
 +
*        if an error occurs
 +
*/
 +
public static double getDouble(String file, String xpath) throws XMLConfigException
  
            List<String> splits = mainToSplitFile.get(file);
+
/**
            if (splits != null) {
+
* Returns a double parameter.  
                for (String split : splits) {
+
* This method uses get() to obtain the value, then convert it
                    splitDocuments.remove(split);
+
* to a double.
                    ConfigurationEvent eventS = new ConfigurationEvent(ConfigurationEvent.EVT_FILE_REMOVED, split, url);
+
*
                    prepareConfigurationEvent(eventS, false);
+
* @param node
                }
+
*        base node for XPath
            }
+
* @param xpath
        }
+
*        parameter to read specified as relative path to node.
    }
+
*
 +
* @return the searched double value from the configuration.
 +
*
 +
* @throws XMLConfigException
 +
*        if an error occurs
 +
*/
 +
public static double getDouble(Node node, String xpath) throws XMLConfigException
  
    /**
+
/**
    * Returns an array of <tt>String</tt> s containing the names of the files
+
* Return a double parameter.
    * currently loaded into <tt>XMLConfig</tt> private cache.
+
* This method uses get() to obtain the value, then convert it
    *  
+
* to a double.
    * @return an array of <tt>String</tt> s containing the names of the files
+
*  
    *        currently loaded into <tt>XMLConfig</tt> private cache.
+
* @param file
    */
+
* @param xpath
    public static synchronized String[] getLoadedFiles()
+
* @param defaultValue
    {
+
*
        Set<String> keys = reloadableDocuments.keySet();
+
* @return the parameter value. If the parameter does not exists or an error
        String[] arr = new String[keys.size()];
+
*        occurs then the specified default value will be returned.
        keys.toArray(arr);
+
*
        return arr;
+
*/
    }
+
public static double getDouble(String file, String xpath, double defaultValue)
  
    /**
+
/**
    * Return the value for a node.
+
* Returns a double parameter.
    *  
+
* This method uses get() to obtain the value, then convert it
    * @param node
+
* to a double.
    *        input Node.
+
*  
    *  
+
* @param node
    * @return the node value. The value for an Element is the concatenation of
+
*        base node for XPath
    *        children values. For other nodes the value is
+
* @param xpath
    *         <code>node.getNodeValue()</code>.
+
*        parameter to read specified as relative path to node.
    */
+
* @param defaultValue
    public static String getNodeValue(Node node)
+
*        default value
    {
+
*  
        if (isFiringEvents) {
+
* @return the searched value or the specified default value if the XPath
            fireConfigurationEvents();
+
*        select no node or an error occurs.
        }
+
*  
        if (node instanceof Element) {
+
*/
            StringBuilder buf = new StringBuilder();
+
public static double getDouble(Node node, String xpath, double defaultValue)
            Node child = node.getFirstChild();
 
            while (child != null) {
 
                String val = getNodeValue(child);
 
                if (val != null) {
 
                    buf.append(val);
 
                }
 
                child = child.getNextSibling();
 
            }
 
            return buf.toString();
 
        }
 
        return node.getNodeValue();
 
    }
 
  
    /**
+
/**
    * Return the value of a NodeList as concatenation of values of all nodes
+
* Returns a float parameter.
    * contained in the list.
+
* This method uses get() to obtain the value, then convert it
    *  
+
* to a float.
    * @param node
+
*  
    *       the node list
+
* @param file
    * @return the nodes value
+
* @param xpath
    */
+
* @return the searched float value from the configuration.
    public static String getNodeValue(NodeList node)
+
*  
    {
+
* @throws XMLConfigException
         StringBuilder buf = new StringBuilder();
+
*         if an error occurs
        NodeList list = node;
+
*/
        int n = list.getLength();
+
public static float getFloat(String file, String xpath) throws XMLConfigException
        for (int i = 0; i < n; ++i) {
 
            String val = getNodeValue(list.item(i));
 
            if (val != null) {
 
                buf.append(val);
 
            }
 
        }
 
        return buf.toString();
 
    }
 
  
    /**
+
/**
    * Reads a value. If the XPath selects many nodes the values are appended
+
* Return a float parameter.
    * together.
+
* This method uses get() to obtain the value, then converts it
    *  
+
* to a float.
    * @param file
+
*  
    *        file to read
+
* @param node
    * @param xpath
+
*        base node for XPath
    *        parameter to read specified as absolute path to the root of the
+
* @param xpath
    *        file.
+
*        parameter to read specified as relative path to node.
    *  
+
*  
    * @return the searched value or <code>null</code> if the XPath select no
+
* @return the searched float value from the configuration.
    *        node.
+
*  
    *  
+
* @throws XMLConfigException
    * @throws XMLConfigException
+
*        if an error occurs
    *        if some error occurs.
+
*/
    *
+
public static float getFloat(Node node, String xpath) throws XMLConfigException
    * @see #getNodeValue(org.w3c.dom.NodeList)
 
    * @see #getNodeList(java.lang.String, java.lang.String)
 
    */
 
    public static String get(String file, String xpath) throws XMLConfigException
 
    {
 
        NodeList list = getNodeList(file, xpath);
 
        if (list.getLength() == 0) {
 
            return null;
 
        }
 
        return getNodeValue(list);
 
    }
 
  
    /**
+
/**
    * Reads a value. If the XPath selects many nodes the values are appended
+
* Return a float parameter.
    * together.
+
* This method uses get() to obtain the value, then converts it
    *  
+
* to a float.
    * @param node
+
*  
    *        base for XPath
+
* @param file
    * @param xpath
+
* @param xpath
    *       parameter to read specified as relative path to the node.
+
* @param defaultValue
    *  
+
*  
    * @return the searched value or <code>null</code> if the XPath select no
+
* @return the parameter value. If the parameter does not exists or an error
    *        node.
+
*        occurs then the specified default value will be returned.
    *
+
*  
    * @throws XMLConfigException
+
*/
    *        if some error occurs.
+
public static float getFloat(String file, String xpath, float defaultValue)
    *  
 
    * @see #getNodeValue(org.w3c.dom.NodeList)
 
    * @see #getNodeList(org.w3c.dom.Node, java.lang.String)
 
    */
 
    public static String get(Node node, String xpath) throws XMLConfigException
 
    {
 
        NodeList list = getNodeList(node, xpath);
 
        if (list.getLength() == 0) {
 
            return null;
 
        }
 
        return getNodeValue(list);
 
    }
 
  
    /**
+
/**
    * Reads a value. If the XPath selects many nodes the values are appended
+
* Returns a float parameter.
    * together.
+
* This method uses get() to obtain the value, then converts it
    *  
+
* to a float.
    * @param file
+
*  
    *        file to read
+
* @param node
    * @param xpath
+
*        base node for XPath
    *        parameter to read specified as absolute path to the root of the
+
* @param xpath
    *        file.
+
*        parameter to read specified as relative path to node.
    * @param defaultValue
+
* @param defaultValue
    *        default value
+
*        default value
    *  
+
*  
    * @return the searched value or the specified default value if the XPath
+
* @return the searched value or the specified default value if the XPath
    *        select no node or an error occurs.
+
*        select no node or an error occurs.
    *  
+
*  
    * @see #get(java.lang.String, java.lang.String)
+
*/
    */
+
public static float getFloat(Node node, String xpath, float defaultValue)
    public static String get(String file, String xpath, String defaultValue)
 
    {
 
        try {
 
            String val = get(file, xpath);
 
            if (val == null) {
 
                return defaultValue;
 
            }
 
            return val;
 
        }
 
        catch (Exception exc) {
 
            return defaultValue;
 
        }
 
    }
 
  
    /**
+
/**
    * Reads a value. If the XPath selects many nodes the values are appended
+
* Returns a boolean parameter.
    * together.
+
*
    *  
+
* The value returned is true if and only if the parameter red is
    * @param node
+
* equal, ignoring case, to "true" or "yes" or "on". Otherwise, it returns
    *        base node for XPath
+
* false.
    * @param xpath
+
*  
    *        parameter to read specified as relative path to node.
+
* @param file
    * @param defaultValue
+
* @param xpath
    *        default value
+
* @return the boolean value of the parameter.
    *
+
* @throws XMLConfigException
    * @return the searched value or the specified default value if the XPath
+
*/
    *        select no node or an error occurs.
+
public static boolean getBoolean(String file, String xpath) throws XMLConfigException
    *
 
    * @see #get(org.w3c.dom.Node, java.lang.String)
 
    */
 
    public static String get(Node node, String xpath, String defaultValue)
 
    {
 
        try {
 
            String val = get(node, xpath);
 
            if (val == null) {
 
                return defaultValue;
 
            }
 
            return val;
 
        }
 
        catch (Exception exc) {
 
            return defaultValue;
 
        }
 
    }
 
  
    /**
+
/**
    * Reads a single encrypted value.
+
* Returns a boolean parameter.
    *  
+
*
    * @param file
+
* The value returned is true if and only if the parameter red is
    *        file to read
+
* equal, ignoring case, to "true" or "yes" or "on". Otherwise, it returns
    * @param xpath
+
* false.
    *        parameter to read specified as absolute path to the root of the
+
*  
    *        file.
+
* @param node
    * @param keyId
+
*        base node for XPath
    *        the key id to be used for decryption, if null or empty is used
+
* @param xpath
    *       DEFAULT_KEY_ID
+
*        parameter to read specified as relative path to node.
    * @param canBeClear
+
*  
    *        if true the data can be unencrypted
+
* @return the searched boolean value from the configuration.
    *
+
*  
    * @return the searched value or <code>null</code> if the XPath select no
+
* @throws XMLConfigException
    *         node.
+
*/
    * @throws XMLConfigException
+
public static boolean getBoolean(Node node, String xpath) throws XMLConfigException
    *        if some error occurs.
 
    *
 
    * @see #getNodeValue(org.w3c.dom.NodeList)
 
    * @see #getNodeList(java.lang.String, java.lang.String)
 
    */
 
    public static String getDecrypted(String file, String xpath, String keyId, boolean canBeClear)
 
            throws XMLConfigException
 
    {
 
        NodeList list = getNodeList(file, xpath);
 
        if (list.getLength() != 1) {
 
            return null;
 
        }
 
        String value = getNodeValue(list);
 
        if ("".equals(keyId)) {
 
            keyId = DEFAULT_KEY_ID;
 
        }
 
        try {
 
            value = CryptoHelper.decrypt(keyId, value, canBeClear);
 
        }
 
        catch (CryptoUtilsException exc) {
 
            throw new XMLConfigException("Error occurred decrypting value (XPath " + xpath + " - keyId " + keyId
 
                    + ") : " + exc.getMessage(), exc);
 
        }
 
        catch (CryptoHelperException exc) {
 
            if (canBeClear) {
 
                return value;
 
            }
 
            throw new XMLConfigException("Error occurred decrypting value (XPath " + xpath + " - keyId " + keyId
 
                    + ") : " + exc.getMessage(), exc);
 
        }
 
        return value;
 
    }
 
  
    /**
+
/**
    * Reads a single encrypted value.
+
* Returns a boolean parameter.
    *  
+
*  
    * @param node
+
* The value returned is true if and only if the parameter red is
    *       base for XPath
+
* equal, ignoring case, to "true" or "yes" or "on". Otherwise, it returns
    * @param xpath
+
* false.
    *       parameter to read specified as relative path to the node.
+
*  
    * @param keyId
+
* @param file
    *       the key id to be used for decryption, if null or empty is used
+
* @param xpath
    *        DEFAULT_KEY_ID
+
* @param defaultValue
    * @param canBeClear
+
* @return the boolean value of the parameter. If the parameter does not
    *        if true the data can be unencrypted
+
*        exists or an error occurs then the specified default value will
    *
+
*         be returned.
    * @return the searched value or <code>null</code> if the XPath select no
+
*/
    *        node.
+
public static boolean getBoolean(String file, String xpath, boolean defaultValue)
    *
 
    * @throws XMLConfigException
 
    *        if some error occurs.
 
    *  
 
    * @see #getNodeValue(org.w3c.dom.NodeList)
 
    * @see #getNodeList(org.w3c.dom.Node, java.lang.String)
 
    */
 
    public static String getDecrypted(Node node, String xpath, String keyId, boolean canBeClear)
 
            throws XMLConfigException
 
    {
 
        NodeList list = getNodeList(node, xpath);
 
        if (list.getLength() != 1) {
 
            return null;
 
        }
 
        String value = getNodeValue(list);
 
        if ("".equals(keyId)) {
 
            keyId = DEFAULT_KEY_ID;
 
        }
 
        try {
 
            value = CryptoHelper.decrypt(keyId, value, canBeClear);
 
        }
 
        catch (CryptoUtilsException exc) {
 
            throw new XMLConfigException("Error occurred decrypting value (XPath " + xpath + " - keyId " + keyId
 
                    + ") : " + exc.getMessage(), exc);
 
        }
 
        catch (CryptoHelperException exc) {
 
            if (canBeClear) {
 
                return value;
 
            }
 
            throw new XMLConfigException("Error occurred decrypting value (XPath " + xpath + " - keyId " + keyId
 
                    + ") : " + exc.getMessage(), exc);
 
        }
 
        return value;
 
    }
 
  
    /**
+
/**
    * Reads a single encrypted value.
+
* Returns a boolean parameter.
    *  
+
*
    * @param file
+
* The value returned is true if and only if the parameter red is
    *        file to read
+
* equal, ignoring case, to "true" or "yes" or "on". Otherwise, it returns
    * @param xpath
+
* false.
    *        parameter to read specified as absolute path to the root of the
+
*  
    *        file.
+
* @param node
    * @param keyId
+
*        base node for XPath
    *        the key id to be used for decryption, if null or empty is used
+
* @param xpath
    *        DEFAULT_KEY_ID
+
*        parameter to read specified as relative path to node.
    * @param canBeClear
+
* @param defaultValue
    *        if true the data can be unencrypted
+
*        default value
    * @param defaultValue
+
*  
    *        default value
+
* @return the searched value or the specified default value if the XPath
    *  
+
*        select no node or an error occurs.
    * @return the searched value or the specified default value if the XPath
+
*/
    *        select no node or an error occurs.
+
public static boolean getBoolean(Node node, String xpath, boolean defaultValue)
    *
 
    * @see #getDecrypted(java.lang.String, java.lang.String)
 
    */
 
    public static String getDecrypted(String file, String xpath, String keyId, boolean canBeClear, String defaultValue)
 
    {
 
        try {
 
            String val = getDecrypted(file, xpath, keyId, canBeClear);
 
            if (val == null) {
 
                return defaultValue;
 
            }
 
            return val;
 
        }
 
        catch (Exception exc) {
 
            return defaultValue;
 
        }
 
    }
 
  
    /**
+
/**
    * Reads a single encrypted value.
+
* Checks if the given parameter exists. <br>
    *  
+
* It checks that get() method does not return null.
    * @param node
+
*  
    *       base node for XPath
+
* @param file
    * @param xpath
+
* @param xpath
    *        parameter to read specified as relative path to node.
+
* @return if the given parameter exists.
    * @param keyId
+
*  
    *        the key id to be used for decryption, if null or empty is used
+
* @throws XMLConfigException
    *        DEFAULT_KEY_ID
+
*        if some error occurs.
    * @param canBeClear
+
*/
    *        if true the data can be unencrypted
+
public static boolean exists(String file, String xpath) throws XMLConfigException
    * @param defaultValue
 
    *        default value
 
    *  
 
    * @return the searched value or the specified default value if the XPath
 
    *        select no node or an error occurs.
 
    *
 
    * @see #getDecrypted(org.w3c.dom.Node, java.lang.String)
 
    */
 
    public static String getDecrypted(Node node, String xpath, String keyId, boolean canBeClear, String defaultValue)
 
    {
 
        try {
 
            String val = getDecrypted(node, xpath, keyId, canBeClear);
 
            if (val == null) {
 
                return defaultValue;
 
            }
 
            return val;
 
        }
 
        catch (Exception exc) {
 
            return defaultValue;
 
        }
 
    }
 
  
    /**
+
/**
    * Reads a single encrypted value.
+
* Checks if the given parameter exists.
    *  
+
* It checks that get() method does not return null.
    * @param file
+
*  
    *        file to read
+
* @param node
    * @param xpath
+
* @param xpath
    *        parameter to read specified as absolute path to the root of the
+
* @return if the given parameter exists
    *        file.
+
*  
    *
+
* @throws XMLConfigException
    *        Sets the key id as DEFAULT_KEY_ID and canBeClear at true
+
*        if some error occurs.
    *
+
*/
    * @return the searched value or <code>null</code> if the XPath select no
+
public static boolean exists(Node node, String xpath) throws XMLConfigException
    *         node.
 
    * @throws XMLConfigException
 
    *        if some error occurs.
 
    *
 
    * @see #getDecrypted(java.lang.String, java.lang.String, java.lang.String,
 
    *      boolean)
 
    */
 
    public static String getDecrypted(String file, String xpath) throws XMLConfigException
 
    {
 
        return getDecrypted(file, xpath, DEFAULT_KEY_ID, true);
 
    }
 
  
    /**
+
/**
    * Reads a single encrypted value.
+
* Obtains a list of nodes that match the given XPath.
    *  
+
*  
    * @param node
+
* @param file
    *        base for XPath
+
*        file to read
    * @param xpath
+
* @param xpath
    *        parameter to read specified as relative path to the node.
+
*        parameter to read specified as absolute path to the root of the
    *
+
*        file.
    *        Sets the key id as DEFAULT_KEY_ID and canBeClear at true
+
* @return a list of nodes that match the given XPath.
    *
+
*  
    * @return the searched value or <code>null</code> if the XPath select no
+
* @throws XMLConfigException
    *        node.
+
*        if some error occurs.
    *  
+
*/
    * @throws XMLConfigException
+
public static NodeList getNodeList(String file, String xpath) throws XMLConfigException
    *        if some error occurs.
 
    *
 
    * @see #getDecrypted(org.w3c.dom.Node, java.lang.String, java.lang.String,
 
    *      boolean)
 
    */
 
    public static String getDecrypted(Node node, String xpath) throws XMLConfigException
 
    {
 
        return getDecrypted(node, xpath, DEFAULT_KEY_ID, true);
 
    }
 
  
    /**
+
/**
    * Reads a single encrypted value.
+
* Obtains a list of nodes that match the given XPath.
    *  
+
*  
    * @param file
+
* @param node
    *        file to read
+
*        base node for XPath
    * @param xpath
+
* @param xpath
    *        parameter to read specified as absolute path to the root of the
+
*        parameter to read specified as relative path to the node
    *        file.
+
* @return a list of nodes that match the given XPath.
    * @param defaultValue
+
*  
    *        default value
+
* @throws XMLConfigException
    *
+
*        if some error occurs.
    *        Sets the key id as DEFAULT_KEY_ID and canBeClear at true
+
*/
    *  
+
public static NodeList getNodeList(Node node, String xpath) throws XMLConfigException
    * @return the searched value or the specified default value if the XPath
 
    *        select no node or an error occurs.
 
    *
 
    * @see #getDecrypted(java.lang.String, java.lang.String, java.lang.String,
 
    *      boolean, java.lang.String)
 
    */
 
    public static String getDecrypted(String file, String xpath, String defaultValue)
 
    {
 
        return getDecrypted(file, xpath, DEFAULT_KEY_ID, true, defaultValue);
 
    }
 
  
    /**
+
/**
    * Reads a single encrypted value.
+
* Obtains a list of nodes that match the given XPath as a Collection.
    *  
+
*  
    * @param node
+
* @param file
    *        base node for XPath
+
*        file to read
    * @param xpath
+
* @param xpath
    *        parameter to read specified as relative path to node.
+
*        parameter to read specified as absolute path to the root of the
    * @param defaultValue
+
*        file.
    *        default value
+
* @return a list of nodes that match the given XPath as a
    *
+
*        Collection.
    *        Sets the key id as DEFAULT_KEY_ID and canBeClear at true
+
*  
    *
+
* @throws XMLConfigException
    * @return the searched value or the specified default value if the XPath
+
*         if some error occurs.
    *        select no node or an error occurs.
+
*/
    *  
+
public static Collection<Node> getNodeListCollection(String file, String xpath) throws XMLConfigException
    * @see #getDecrypted(org.w3c.dom.Node, java.lang.String, java.lang.String,
 
    *     boolean, java.lang.String)
 
    */
 
    public static String getDecrypted(Node node, String xpath, String defaultValue)
 
    {
 
        return getDecrypted(node, xpath, DEFAULT_KEY_ID, true, defaultValue);
 
    }
 
  
    /**
+
/**
    * Decrypt a string encrypted by default XMLConfig key.
+
* Obtains a list of nodes that match the given XPath as a Collection.
    *  
+
*  
    * @param value
+
* @param node
    *        the value to decrypt
+
*        base node for XPath
    *  
+
* @param xpath
    * @return the decrypted value or value if not encrypted
+
*       parameter to read specified as relative path to the node
    * @throws XMLConfigException
+
* @return a list of nodes that match the given XPath as a
    *        if some error occurs.
+
*        Collection.
    *
+
*
    */
+
* @throws XMLConfigException
    public static String getDecrypted(String value) throws XMLConfigException
+
*        if some error occurs.
    {
+
*/
        String out = value;
+
public static Collection<Node> getNodeListCollection(Node node, String xpath) throws XMLConfigException
        try {
 
            out = CryptoHelper.decrypt(DEFAULT_KEY_ID, value, true);
 
        }
 
        catch (Exception exc) {
 
            throw new XMLConfigException("Error occurred decrypting value [" + value + "]", exc);
 
        }
 
        return out;
 
    }
 
  
    /**
+
/**
    * Encrypt a string using default XMLConfig key.
+
* Obtains a single node that matches the given XPath.
    *  
+
*  
    * @param value
+
* @param file
    *        the value to encrypt
+
*        file to read
    *  
+
* @param xpath
    * @return the encrypted value
+
*        parameter to read specified as absolute path to the root of the
    * @throws XMLConfigException
+
*        file.
    *        if some error occurs.
+
* @return a single node that matches the given XPath.
    *
+
*
    */
+
* @throws XMLConfigException
    public static String getEncrypted(String value) throws XMLConfigException
+
*        if some error occurs.
    {
+
*/
        String out = value;
+
public static Node getNode(String file, String xpath) throws XMLConfigException
        try {
 
            out = CryptoHelper.encrypt(DEFAULT_KEY_ID, value, true);
 
        }
 
        catch (Exception exc) {
 
            throw new XMLConfigException("Error occurred encrypting value [" + value + "]", exc);
 
        }
 
        return out;
 
    }
 
  
    /**
+
/**
    * Return an integer parameter. <br>
+
* Obtains a single node that matches the given XPath.
    * This method uses <code>get()</code> to obtain the value, then convert it
+
*  
    * to an integer.
+
* @param node
    *  
+
*        base node for XPath
    * @param file
+
* @param xpath
    * @param xpath
+
*       parameter to read specified as relative path to the node
    * @return the searched integer value from the configuration.
+
* @return a single node that matches the given XPath.
    *
+
*  
    * @see #get(java.lang.String, java.lang.String)
+
* @throws XMLConfigException
    *  
+
*        if some error occurs.
    * @throws XMLConfigException
+
*/
    *        if any error occurs
+
public static Node getNode(Node node, String xpath) throws XMLConfigException
    */
+
</syntaxhighlight>
    public static int getInteger(String file, String xpath) throws XMLConfigException
 
    {
 
        try {
 
            String v = get(file, xpath);
 
            return Integer.parseInt(v);
 
        }
 
        catch (XMLConfigException exc) {
 
            throw exc;
 
        }
 
        catch (Exception exc) {
 
            throw new XMLConfigException("" + exc, exc);
 
        }
 
  
    }
 
  
    /**
+
==XMLConfig configuration events management methods==
    * Return an integer parameter. <br>
+
<syntaxhighlight lang="java5">
    * This method uses <code>get()</code> to obtain the value, then convert it
+
/**
    * to an integer.
+
* Add a ConfigurationListener.
    *  
+
*  
    * @param node
+
* @param listener
    *       base node for XPath
+
*/
    * @param xpath
+
public static void addConfigurationListener(ConfigurationListener listener)
    *        parameter to read specified as relative path to node.
 
    *
 
    * @return the searched integer value from the configuration.
 
    *
 
    * @throws XMLConfigException
 
    *        if an error occurs
 
    */
 
    public static int getInteger(Node node, String xpath) throws XMLConfigException
 
    {
 
        try {
 
            String v = get(node, xpath);
 
            return Integer.parseInt(v);
 
        }
 
        catch (XMLConfigException exc) {
 
            throw exc;
 
        }
 
        catch (Exception exc) {
 
            throw new XMLConfigException("" + exc, exc);
 
        }
 
    }
 
  
    /**
+
/**
    * Return an integer parameter. <br>
+
* Adds a ConfigurationListener listening for events related to a single
    * This method uses <code>get()</code> to obtain the value, then convert it
+
* particular file.
    * to an integer.
+
*  
    *  
+
* @param listener
    * @param file
+
*        a ConfigurationListener object
    *        the configuration file
+
* @param filename
    * @param xpath
+
*        a String containing the name of a file whose changes must
    *        the XPath to search
+
*        be notified to the given listener
    * @param defaultValue
+
*/
    *        value to return if XPath not match
+
public static void addConfigurationListener(ConfigurationListener listener, String filename)
    * @return the parameter value. If the parameter does not exists or an error
 
    *        occurs then the specified default value will be returned.
 
    *
 
    * @see #get(java.lang.String, java.lang.String)
 
    */
 
    public static int getInteger(final String file, final String xpath, final int defaultValue)
 
    {
 
        try {
 
            return getInteger(file, xpath);
 
        }
 
        catch (Exception exc) {
 
            // do nothing
 
        }
 
        return defaultValue;
 
    }
 
  
    /**
+
/**
    * Return an integer parameter. <br>
+
* Add a ConfigurationListener listening for events related to a particular
    * This method uses <code>get()</code> to obtain the value, then convert it
+
* set of files.
    * to an integer.
+
*  
    *  
+
* @param listener
    * @param node
+
*        a ConfigurationListener object
    *        base node for XPath
+
* @param fileList
    * @param xpath
+
*        a List of String s containing the name of files
    *        parameter to read specified as relative path to node.
+
*        whose changes must be notified to the given listener
    * @param defaultValue
+
*/
    *        default value
+
public static void addConfigurationListener(ConfigurationListener listener, List<String> fileList)
    *
+
      
    * @return the searched value or the specified default value if the XPath
+
/**
    *        select no node or an error occurs.
+
* Removes a ConfigurationListener
    *
+
*
    * @see #get(org.w3c.dom.Node, java.lang.String)
+
* @param listener
    */
+
*/
    public static int getInteger(Node node, String xpath, int defaultValue)
+
public static void removeConfigurationListener(ConfigurationListener listener)
     {
 
        try {
 
            return getInteger(node, xpath);
 
        }
 
        catch (Exception exc) {
 
            // do nothing
 
        }
 
        return defaultValue;
 
    }
 
  
    /**
+
/**
    * Return a long parameter. <br>
+
* Removes a ConfigurationListener listening for changes on a single file
    * This method uses <code>get()</code> to obtain the value, then convert it
+
*  
    * to a long.
+
* @param listener
    *  
+
*       a ConfigurationListener object
    * @param file
+
* @param filename
    * @param xpath
+
*       a String containing the name of a file whose changes must
    * @return the searched long value from the configuration.
+
*       be notified to the given listener
    *  
+
*/
    * @see #get(java.lang.String, java.lang.String)
+
public static void removeConfigurationListener(ConfigurationListener listener, String filename)
    *  
 
    * @throws XMLConfigException
 
    *        if an error occurs
 
    */
 
    public static long getLong(String file, String xpath) throws XMLConfigException
 
    {
 
        try {
 
            String v = get(file, xpath);
 
            return Long.parseLong(v);
 
        }
 
        catch (XMLConfigException exc) {
 
            throw exc;
 
        }
 
        catch (Exception exc) {
 
            throw new XMLConfigException("" + exc, exc);
 
        }
 
    }
 
  
    /**
+
/**
    * Return a long parameter. <br>
+
* Remove a ConfigurationListener listening for changes on a subset of files
    * This method uses <code>get()</code> to obtain the value, then convert it
+
*  
    * to a long.
+
* @param listener
    *  
+
*        a ConfigurationListener object
    * @param node
+
* @param fileList
    *        base node for XPath
+
*        a List of String s containing the name of files
    * @param xpath
+
*       whose changes must be notified to the given listener
    *        parameter to read specified as relative path to node.
+
*/
    *  
+
public static void removeConfigurationListener(ConfigurationListener listener, List<String> fileList)
    * @return the searched long value from the configuration.
+
</syntaxhighlight>
    *
 
    * @throws XMLConfigException
 
    *        if an error occurs
 
    */
 
    public static long getLong(Node node, String xpath) throws XMLConfigException
 
    {
 
        try {
 
            String v = get(node, xpath);
 
            return Long.parseLong(v);
 
        }
 
        catch (XMLConfigException exc) {
 
            throw exc;
 
        }
 
        catch (Exception exc) {
 
            throw new XMLConfigException("" + exc, exc);
 
        }
 
    }
 
  
    /**
 
    * Return a long parameter. <br>
 
    * This method uses <code>get()</code> to obtain the value, then convert it
 
    * to a long.
 
    *
 
    * @param file
 
    * @param xpath
 
    * @param defaultValue
 
    *
 
    * @return the parameter value. If the parameter does not exists or an error
 
    *        occurs then the specified default value will be returned.
 
    *
 
    * @see #get(java.lang.String, java.lang.String)
 
    */
 
    public static long getLong(String file, String xpath, long defaultValue)
 
    {
 
        try {
 
            return getLong(file, xpath);
 
        }
 
        catch (Exception exc) {
 
            // do nothing
 
        }
 
        return defaultValue;
 
    }
 
  
    /**
+
==XMLConfig file management methods==
    * Return a long parameter. <br>
+
<syntaxhighlight lang="java5">
    * This method uses <code>get()</code> to obtain the value, then convert it
+
/**
    * to a long.
+
* Loads a configuration file and, if necessary, notifies registered
    *
+
* listeners. This method can be used in order to preload the configuration
    * @param node
+
* file.
    *        base node for XPath
+
*  
    * @param xpath
+
* @param file
    *        parameter to read specified as relative path to node.
+
*        the file to read
    * @param defaultValue
+
* @return the complete URL used to load the file.
    *
+
* @exception XMLConfigException
    * @return the searched value or the specified default value if the XPath
+
*            if error occurs
    *        select no node or an error occurs.
+
*/
    *
+
public static synchronized URL load(String file) throws XMLConfigException
    * @see #get(org.w3c.dom.Node, java.lang.String)
 
    */
 
    public static long getLong(Node node, String xpath, long defaultValue)
 
    {
 
        try {
 
            return getLong(node, xpath);
 
        }
 
        catch (Exception exc) {
 
            // do nothing
 
        }
 
        return defaultValue;
 
    }
 
 
 
    /**
 
    * Return a double parameter. <br>
 
    * This method uses <code>get()</code> to obtain the value, then convert it
 
    * to a double.
 
    *
 
    * @param file
 
    * @param xpath
 
    * @return the searched double value from the configuration.
 
    *
 
    * @see #get(java.lang.String, java.lang.String)
 
    *
 
    * @throws XMLConfigException
 
    *        if an error occurs
 
    */
 
    public static double getDouble(String file, String xpath) throws XMLConfigException
 
    {
 
        try {
 
            String v = get(file, xpath);
 
            return Double.parseDouble(v);
 
        }
 
        catch (XMLConfigException exc) {
 
            throw exc;
 
        }
 
        catch (Exception exc) {
 
            throw new XMLConfigException("" + exc, exc);
 
        }
 
    }
 
 
 
    /**
 
    * Return a double parameter. <br>
 
    * This method uses <code>get()</code> to obtain the value, then convert it
 
    * to a double.
 
    *
 
    * @param node
 
    *        base node for XPath
 
    * @param xpath
 
    *        parameter to read specified as relative path to node.
 
    *
 
    * @return the searched double value from the configuration.
 
    *
 
    * @throws XMLConfigException
 
    *        if an error occurs
 
    */
 
    public static double getDouble(Node node, String xpath) throws XMLConfigException
 
    {
 
        try {
 
            String v = get(node, xpath);
 
            return Double.parseDouble(v);
 
        }
 
        catch (XMLConfigException exc) {
 
            throw exc;
 
        }
 
        catch (Exception exc) {
 
            throw new XMLConfigException("" + exc, exc);
 
        }
 
    }
 
 
 
    /**
 
    * Return a double parameter. <br>
 
    * This method uses <code>get()</code> to obtain the value, then convert it
 
    * to a double.
 
    *
 
    * @param file
 
    * @param xpath
 
    * @param defaultValue
 
    *
 
    * @return the parameter value. If the parameter does not exists or an error
 
    *        occurs then the specified default value will be returned.
 
    *
 
    * @see #get(java.lang.String, java.lang.String)
 
    */
 
    public static double getDouble(String file, String xpath, double defaultValue)
 
    {
 
        try {
 
            return getDouble(file, xpath);
 
        }
 
        catch (Exception exc) {
 
            // do nothing
 
        }
 
        return defaultValue;
 
    }
 
 
 
    /**
 
    * Return a double parameter. <br>
 
    * This method uses <code>get()</code> to obtain the value, then convert it
 
    * to a double.
 
    *
 
    * @param node
 
    *        base node for XPath
 
    * @param xpath
 
    *        parameter to read specified as relative path to node.
 
    * @param defaultValue
 
    *        default value
 
    *
 
    * @return the searched value or the specified default value if the XPath
 
    *        select no node or an error occurs.
 
    *
 
    * @see #get(org.w3c.dom.Node, java.lang.String)
 
    */
 
    public static double getDouble(Node node, String xpath, double defaultValue)
 
    {
 
        try {
 
            return getDouble(node, xpath);
 
        }
 
        catch (Exception exc) {
 
            // do nothing
 
        }
 
        return defaultValue;
 
    }
 
 
 
    /**
 
    * Return a float parameter. <br>
 
    * This method uses <code>get()</code> to obtain the value, then convert it
 
    * to a float.
 
    *
 
    * @param file
 
    * @param xpath
 
    * @return the searched float value from the configuration.
 
    *
 
    * @see #get(java.lang.String, java.lang.String)
 
    *
 
    * @throws XMLConfigException
 
    *        if an error occurs
 
    */
 
    public static float getFloat(String file, String xpath) throws XMLConfigException
 
    {
 
        try {
 
            String v = get(file, xpath);
 
            return Float.parseFloat(v);
 
        }
 
        catch (XMLConfigException exc) {
 
            throw exc;
 
        }
 
        catch (Exception exc) {
 
            throw new XMLConfigException("" + exc, exc);
 
        }
 
    }
 
 
 
    /**
 
    * Return a float parameter. <br>
 
    * This method uses <code>get()</code> to obtain the value, then convert it
 
    * to a float.
 
    *
 
    * @param node
 
    *        base node for XPath
 
    * @param xpath
 
    *        parameter to read specified as relative path to node.
 
    *
 
    * @return the searched float value from the configuration.
 
    *
 
    * @throws XMLConfigException
 
    *        if an error occurs
 
    */
 
    public static float getFloat(Node node, String xpath) throws XMLConfigException
 
    {
 
        try {
 
            String v = get(node, xpath);
 
            return Float.parseFloat(v);
 
        }
 
        catch (XMLConfigException exc) {
 
            throw exc;
 
        }
 
        catch (Exception exc) {
 
            throw new XMLConfigException("" + exc, exc);
 
        }
 
    }
 
 
 
    /**
 
    * Return a float parameter. <br>
 
    * This method uses <code>get()</code> to obtain the value, then convert it
 
    * to a float.
 
    *
 
    * @param file
 
    * @param xpath
 
    * @param defaultValue
 
    *
 
    * @return the parameter value. If the parameter does not exists or an error
 
    *        occurs then the specified default value will be returned.
 
    *
 
    * @see #get(java.lang.String, java.lang.String)
 
    */
 
    public static float getFloat(String file, String xpath, float defaultValue)
 
    {
 
        try {
 
            return getFloat(file, xpath);
 
        }
 
        catch (Exception exc) {
 
            // do nothing
 
        }
 
        return defaultValue;
 
    }
 
 
 
    /**
 
    * Return a float parameter. <br>
 
    * This method uses <code>get()</code> to obtain the value, then convert it
 
    * to a float.
 
    *
 
    * @param node
 
    *        base node for XPath
 
    * @param xpath
 
    *        parameter to read specified as relative path to node.
 
    * @param defaultValue
 
    *        default value
 
    *
 
    * @return the searched value or the specified default value if the XPath
 
    *        select no node or an error occurs.
 
    *
 
    * @see #get(org.w3c.dom.Node, java.lang.String)
 
    */
 
    public static float getFloat(Node node, String xpath, float defaultValue)
 
    {
 
        try {
 
            return getFloat(node, xpath);
 
        }
 
        catch (Exception exc) {
 
            // do nothing
 
        }
 
        return defaultValue;
 
    }
 
 
 
    /**
 
    * Returns a boolean parameter.
 
    * <p>
 
    * The value returned is <b>true</b> if and only if the parameter red is
 
    * equal, ignoring case, to "true" or "yes" or "on". Otherwise, it returns
 
    * <b>false</b>.
 
    * <p>
 
    *
 
    * @param file
 
    * @param xpath
 
    * @return the boolean value of the parameter.
 
    * @throws XMLConfigException
 
    */
 
    public static boolean getBoolean(String file, String xpath) throws XMLConfigException
 
    {
 
        try {
 
            String s = get(file, xpath);
 
            return (s.equalsIgnoreCase("true") || s.equalsIgnoreCase("yes") || s.equalsIgnoreCase("on"));
 
        }
 
        catch (XMLConfigException exc) {
 
            throw exc;
 
        }
 
        catch (Exception exc) {
 
            throw new XMLConfigException("" + exc, exc);
 
        }
 
    }
 
 
 
    /**
 
    * Returns a boolean parameter.
 
    * <p>
 
    * The value returned is <b>true</b> if and only if the parameter red is
 
    * equal, ignoring case, to "true" or "yes" or "on". Otherwise, it returns
 
    * <b>false</b>.
 
    * <p>
 
    *
 
    * @param node
 
    *        base node for XPath
 
    * @param xpath
 
    *        parameter to read specified as relative path to node.
 
    *
 
    * @return the searched boolean value from the configuration.
 
    *
 
    * @throws XMLConfigException
 
    */
 
    public static boolean getBoolean(Node node, String xpath) throws XMLConfigException
 
    {
 
        try {
 
            String s = get(node, xpath);
 
            return (s.equalsIgnoreCase("true") || s.equalsIgnoreCase("yes") || s.equalsIgnoreCase("on"));
 
        }
 
        catch (XMLConfigException exc) {
 
            throw exc;
 
        }
 
        catch (Exception exc) {
 
            throw new XMLConfigException("" + exc, exc);
 
        }
 
    }
 
 
 
    /**
 
    * Returns a boolean parameter.
 
    * <p>
 
    * The value returned is <b>true</b> if and only if the parameter red is
 
    * equal, ignoring case, to "true" or "yes" or "on". Otherwise, it returns
 
    * <b>false</b>.
 
    * <p>
 
    *
 
    * @param file
 
    * @param xpath
 
    * @param defaultValue
 
    * @return the boolean value of the parameter. If the parameter does not
 
    *        exists or an error occurs then the specified default value will
 
    *        be returned.
 
    */
 
    public static boolean getBoolean(String file, String xpath, boolean defaultValue)
 
    {
 
        try {
 
            return getBoolean(file, xpath);
 
        }
 
        catch (Exception exc) {
 
            // Do nothing
 
        }
 
        return defaultValue;
 
    }
 
 
 
    /**
 
    * Returns a boolean parameter.
 
    * <p>
 
    * The value returned is <b>true</b> if and only if the parameter red is
 
    * equal, ignoring case, to "true" or "yes" or "on". Otherwise, it returns
 
    * <b>false</b>.
 
    * <p>
 
    *
 
    * @param node
 
    *        base node for XPath
 
    * @param xpath
 
    *        parameter to read specified as relative path to node.
 
    * @param defaultValue
 
    *        default value
 
    *
 
    * @return the searched value or the specified default value if the XPath
 
    *        select no node or an error occurs.
 
    */
 
    public static boolean getBoolean(Node node, String xpath, boolean defaultValue)
 
    {
 
        try {
 
            return getBoolean(node, xpath);
 
        }
 
        catch (Exception exc) {
 
            // Do nothing
 
        }
 
        return defaultValue;
 
    }
 
 
 
    /**
 
    * Checks if the given parameter exists. <br>
 
    * It checks that <code>get()</code> method does not return
 
    * <code>null</code>.
 
    *
 
    * @param file
 
    * @param xpath
 
    * @return if the given parameter exists.
 
    *
 
    * @see #get(java.lang.String, java.lang.String)
 
    *
 
    * @throws XMLConfigException
 
    *        if some error occurs.
 
    */
 
    public static boolean exists(String file, String xpath) throws XMLConfigException
 
    {
 
        return get(file, xpath) != null;
 
    }
 
 
 
    /**
 
    * Checks if the given parameter exists. <br>
 
    * It checks that <code>get()</code> method does not return
 
    * <code>null</code>.
 
    *
 
    * @param node
 
    * @param xpath
 
    * @return if the given parameter exists
 
    *
 
    * @see #get(org.w3c.dom.Node, java.lang.String)
 
    *
 
    * @throws XMLConfigException
 
    *        if some error occurs.
 
    */
 
    public static boolean exists(Node node, String xpath) throws XMLConfigException
 
    {
 
        return get(node, xpath) != null;
 
    }
 
 
 
    /**
 
    * Obtains a list of nodes that match the given XPath.
 
    *
 
    * @param file
 
    *        file to read
 
    * @param xpath
 
    *        parameter to read specified as absolute path to the root of the
 
    *        file.
 
    * @return a list of nodes that match the given XPath.
 
    *
 
    * @throws XMLConfigException
 
    *        if some error occurs.
 
    */
 
    public static NodeList getNodeList(String file, String xpath) throws XMLConfigException
 
    {
 
 
 
        synchronized (XMLConfig.class) {
 
            xpathAPI.reset();
 
        }
 
 
 
        Document doc = getDocument(file);
 
        try {
 
            synchronized (doc) {
 
                return (NodeList) xpathAPI.selectNodeList(doc, new XPath(xpath));
 
            }
 
        }
 
        catch (Throwable thr) {
 
            thr.printStackTrace();
 
 
 
            throw new XMLConfigException("XML XMLConfig error (File:" + file + ", Node:-, XPath:" + xpath + ")", thr);
 
        }
 
    }
 
 
 
    /**
 
    * Obtains a list of nodes that match the given XPath.
 
    *
 
    * @param node
 
    *        base node for XPath
 
    * @param xpath
 
    *        parameter to read specified as relative path to the node
 
    * @return a list of nodes that match the given XPath.
 
    *
 
    * @throws XMLConfigException
 
    *        if some error occurs.
 
    */
 
    public static NodeList getNodeList(Node node, String xpath) throws XMLConfigException
 
    {
 
        synchronized (XMLConfig.class) {
 
            xpathAPI.reset();
 
        }
 
 
 
        if (isFiringEvents) {
 
            fireConfigurationEvents();
 
        }
 
        if (node == null) {
 
            throw new XMLConfigException("Context node cannot be null");
 
        }
 
 
 
        try {
 
            synchronized (getOwnerDocument(node)) {
 
                return (NodeList) xpathAPI.selectNodeList(node, new XPath(xpath));
 
            }
 
        }
 
        catch (Throwable thr) {
 
            thr.printStackTrace();
 
 
 
            throw new XMLConfigException("XML XMLConfig error (File:-, Node:" + node.getNodeName() + ", XPath:" + xpath
 
                    + ")", thr);
 
        }
 
    }
 
 
 
    /**
 
    * Obtains a list of nodes that match the given XPath as a
 
    * <code>Collection</code>.
 
    *
 
    * @param file
 
    *        file to read
 
    * @param xpath
 
    *        parameter to read specified as absolute path to the root of the
 
    *        file.
 
    * @return a list of nodes that match the given XPath as a
 
    *        <code>Collection</code>.
 
    *
 
    * @throws XMLConfigException
 
    *        if some error occurs.
 
    */
 
    public static Collection<Node> getNodeListCollection(String file, String xpath) throws XMLConfigException
 
    {
 
        NodeList nl = getNodeList(file, xpath);
 
        Collection<Node> returnList = new ArrayList<Node>();
 
        if (nl != null) {
 
            for (int i = 0; i < nl.getLength(); i++) {
 
                returnList.add(nl.item(i));
 
            }
 
        }
 
        return returnList;
 
    }
 
 
 
    /**
 
    * Obtains a list of nodes that match the given XPath as a
 
    * <code>Collection</code>.
 
    *
 
    * @param node
 
    *        base node for XPath
 
    * @param xpath
 
    *        parameter to read specified as relative path to the node
 
    * @return a list of nodes that match the given XPath as a
 
    *        <code>Collection</code>.
 
    *
 
    * @throws XMLConfigException
 
    *        if some error occurs.
 
    */
 
    public static Collection<Node> getNodeListCollection(Node node, String xpath) throws XMLConfigException
 
    {
 
        NodeList nl = getNodeList(node, xpath);
 
        Collection<Node> returnList = new ArrayList<Node>();
 
        if (nl != null) {
 
            for (int i = 0; i < nl.getLength(); i++) {
 
                returnList.add(nl.item(i));
 
            }
 
        }
 
        return returnList;
 
    }
 
 
 
    /**
 
    * Obtains a single node that matches the given XPath.
 
    *
 
    * @param file
 
    *        file to read
 
    * @param xpath
 
    *        parameter to read specified as absolute path to the root of the
 
    *        file.
 
    * @return a single node that matches the given XPath.
 
    *
 
    * @throws XMLConfigException
 
    *        if some error occurs.
 
    */
 
    public static Node getNode(String file, String xpath) throws XMLConfigException
 
    {
 
        Document doc = getDocument(file);
 
        try {
 
            synchronized (doc) {
 
                return (Node) xpathAPI.selectSingleNode(doc, new XPath(xpath));
 
            }
 
        }
 
        catch (Throwable thr) {
 
            thr.printStackTrace();
 
 
 
            throw new XMLConfigException("XML XMLConfig error (File:" + file + ", Node:-, XPath:" + xpath + ")", thr);
 
        }
 
    }
 
 
 
    /**
 
    * Obtains a single node that matches the given XPath.
 
    *
 
    * @param node
 
    *        base node for XPath
 
    * @param xpath
 
    *        parameter to read specified as relative path to the node
 
    * @return a single node that matches the given XPath.
 
    *
 
    * @throws XMLConfigException
 
    *        if some error occurs.
 
    */
 
    public static Node getNode(Node node, String xpath) throws XMLConfigException
 
    {
 
        if (isFiringEvents) {
 
            fireConfigurationEvents();
 
        }
 
        if (node == null) {
 
            throw new XMLConfigException("Context node cannot be null");
 
        }
 
 
 
        try {
 
            synchronized (getOwnerDocument(node)) {
 
                return (Node) xpathAPI.selectSingleNode(node, new XPath(xpath));
 
            }
 
        }
 
        catch (Throwable thr) {
 
            thr.printStackTrace();
 
 
 
            throw new XMLConfigException("XML XMLConfig error (File:-, Node:" + node.getNodeName() + ", XPath:" + xpath
 
                    + ")", thr);
 
        }
 
    }
 
 
 
    /**
 
    * Add a ConfigurationListener.
 
    *
 
    * @param listener
 
    */
 
    public static void addConfigurationListener(ConfigurationListener listener)
 
    {
 
        if (isFiringEvents) {
 
            fireConfigurationEvents();
 
        }
 
        try {
 
            EventHandler.addEventListener(listener, ConfigurationListener.class, new ConfigurationEventSelector(),
 
                    EVENT_SOURCE);
 
        }
 
        catch (NoSuchMethodException exc) {
 
            exc.printStackTrace();
 
        }
 
    }
 
 
 
    /**
 
    * Add a ConfigurationListener listening for events related to a single
 
    * particular file.
 
    *
 
    * @param listener
 
    *        a <tt>ConfigurationListener</tt> object
 
    * @param filename
 
    *        a <tt>String</tt> containing the name of a file whose changes must
 
    *        be notified to the given listener
 
    */
 
    public static void addConfigurationListener(ConfigurationListener listener, String filename)
 
    {
 
        if (isFiringEvents) {
 
            fireConfigurationEvents();
 
        }
 
        try {
 
            EventHandler.addEventListener(listener, ConfigurationListener.class, new ConfigurationEventSelector(
 
                    filename), EVENT_SOURCE);
 
        }
 
        catch (NoSuchMethodException exc) {
 
            exc.printStackTrace();
 
        }
 
    }
 
 
 
    /**
 
    * Add a ConfigurationListener listening for events related to a particular
 
    * set of files.
 
    *
 
    * @param listener
 
    *        a <tt>ConfigurationListener</tt> object
 
    * @param fileList
 
    *        a <tt>List</tt> of <tt>String</tt> s containing the name of files
 
    *        whose changes must be notified to the given listener
 
    */
 
    public static void addConfigurationListener(ConfigurationListener listener, List<String> fileList)
 
    {
 
        if (isFiringEvents) {
 
            fireConfigurationEvents();
 
        }
 
        try {
 
            EventHandler.addEventListener(listener, ConfigurationListener.class, new ConfigurationEventSelector(
 
                    fileList), EVENT_SOURCE);
 
        }
 
        catch (NoSuchMethodException exc) {
 
            exc.printStackTrace();
 
        }
 
    }
 
 
 
    /**
 
    * Remove a ConfigurationListener
 
    *
 
    * @param listener
 
    */
 
    public static void removeConfigurationListener(ConfigurationListener listener)
 
    {
 
        if (isFiringEvents) {
 
            fireConfigurationEvents();
 
        }
 
        EventHandler.removeEventListener(listener, ConfigurationListener.class, EVENT_SOURCE);
 
    }
 
 
 
    /**
 
    * Remove a ConfigurationListener listening for changes on a single file
 
    *
 
    * @param listener
 
    *        a <tt>ConfigurationListener</tt> object
 
    * @param filename
 
    *        a <tt>String</tt> containing the name of a file whose changes must
 
    *        be notified to the given listener
 
    */
 
    public static void removeConfigurationListener(ConfigurationListener listener, String filename)
 
    {
 
        if (isFiringEvents) {
 
            fireConfigurationEvents();
 
        }
 
        EventHandler.removeEventListener(listener, ConfigurationListener.class,
 
                new ConfigurationEventSelector(filename), EVENT_SOURCE);
 
    }
 
 
 
    /**
 
    * Remove a ConfigurationListener listening for changes on a subset of files
 
    *
 
    * @param listener
 
    *        a <tt>ConfigurationListener</tt> object
 
    * @param fileList
 
    *        a <tt>List</tt> of <tt>String</tt> s containing the name of files
 
    *        whose changes must be notified to the given listener
 
    */
 
    public static void removeConfigurationListener(ConfigurationListener listener, List<String> fileList)
 
    {
 
        if (isFiringEvents) {
 
            fireConfigurationEvents();
 
        }
 
        EventHandler.removeEventListener(listener, ConfigurationListener.class,
 
                new ConfigurationEventSelector(fileList), EVENT_SOURCE);
 
    }
 
 
 
    /**
 
    * Fires a ConfigurationEvent to all registered ConfigurationListener.
 
    *
 
    * @param event
 
    *        event to fire
 
    * @param immediate
 
    *        if true the event is fired immediately
 
    */
 
    protected static synchronized void prepareConfigurationEvent(ConfigurationEvent event, boolean immediate)
 
    {
 
        isFiringEvents = true;
 
 
 
        configurationEvents.add(event);
 
 
 
        if (immediate) {
 
            fireConfigurationEvents();
 
        }
 
    }
 
 
 
    /**
 
    * Fires the ConfigurationEvents to all registered ConfigurationListener.
 
    *
 
    */
 
    protected static synchronized void fireConfigurationEvents()
 
    {
 
        if (!isFiringEvents) {
 
            return;
 
        }
 
 
 
        while (!configurationEvents.isEmpty()) {
 
            try {
 
                EventHandler.fireEventSync("configurationChanged", configurationEvents.remove(0));
 
            }
 
            catch (Exception exc) {
 
                exc.printStackTrace();
 
            }
 
        }
 
        isFiringEvents = false;
 
    }
 
 
 
    /**
 
    * Return the URL to be used in order to load the given file.
 
    *
 
    * @param file
 
    *        the file to read
 
    * @return the URL to be used in order to load the given file.
 
    * @exception XMLConfigException
 
    *            if the file could not be found.
 
    */
 
    public static synchronized URL getURL(String file) throws XMLConfigException
 
    {
 
        return getURL(file, null, false, true);
 
    }
 
 
 
    /**
 
    * Return the URL to be used in order to load the given file.
 
    *  
 
    * @param file
 
    *        the file to read
 
    * @param classLoader
 
    *        the class loader to use to retrieve the file to read
 
    * @param force
 
    *        force the reload of file if already present in cache
 
    * @param canBeReloaded
 
    *        flag that indicates if this file can be changed and can be
 
    *        reloaded
 
    * @return the URL to be used in order to load the given file.
 
    * @exception XMLConfigException
 
    *            if the file could not be found.
 
    */
 
    public static synchronized URL getURL(String file, ClassLoader classLoader, boolean force, boolean canBeReloaded)
 
            throws XMLConfigException
 
    {
 
        if (isFiringEvents) {
 
            fireConfigurationEvents();
 
        }
 
        // It is already in cache?
 
        //
 
        URL url = urls.get(file);
 
        if ((url != null) && !force) {
 
            return url;
 
        }
 
 
 
        try {
 
            if ((XMLConfig.baseConfigPath != null) && !("".equals(XMLConfig.baseConfigPath))) {
 
                File f = new File(baseConfigPath + File.separatorChar + file);
 
                if (f.exists()) {
 
                    url = new URL("file", null, f.getAbsolutePath());
 
                }
 
            }
 
        }
 
        catch (MalformedURLException e) {
 
            // do nothing
 
        }
 
 
 
        if (url == null) {
 
            if (classLoader == null) {
 
                classLoader = XMLConfig.class.getClassLoader();
 
            }
 
            // Tries to obtain the URL from the class loader.
 
            // If not found, then throws an exception.
 
            //
 
            url = classLoader.getResource(file);
 
            if (url == null) {
 
                System.err.println("XMLConfig: file not found: " + file);
 
                throw new XMLConfigException("XML configuration error (File:" + file + ", Node:-, XPath:-)");
 
            }
 
        }
 
 
 
        // Caches the URL.
 
        urls.put(file, url);
 
 
 
        return url;
 
    }
 
 
 
    /**
 
    * Reads a configuration file and caches it.
 
    * <p>
 
    * The file is searched into the Java class path as another Java resource.
 
    * See Java class loader documentation to understand this mechanism.
 
    *
 
    * @param file
 
    *        the file to read
 
    * @return the read configuration as {@link org.w3c.dom.Document Document}.
 
    *
 
    * @throws XMLConfigException
 
    *        if some error occurs.
 
    */
 
    public static synchronized Document getDocument(String file) throws XMLConfigException
 
    {
 
        return getDocument(file, null, false, true);
 
    }
 
 
 
    /**
 
    * Reads a configuration file and caches it.
 
    * <p>
 
    * The file is searched into the Java class path as another Java resource.
 
    * See Java class loader documentation to understand this mechanism.
 
    *
 
    * @param file
 
    *        the file to read
 
    * @param classLoader
 
    *        the class loader to use to retrieve the file to read
 
    * @param force
 
    *        force the reload of file if already present in cache
 
    * @param canBeReloaded
 
    *        flag that indicates if this file can be changed and can be
 
    *        reloaded
 
    * @return the read configuration as {@link org.w3c.dom.Document Document}.
 
    *
 
    * @throws XMLConfigException
 
    *        if some error occurs.
 
    */
 
    public static synchronized Document getDocument(String file, ClassLoader classLoader, boolean force,
 
            boolean canBeReloaded) throws XMLConfigException
 
    {
 
        String mainFile = file;
 
 
 
        if (isFiringEvents) {
 
            fireConfigurationEvents();
 
        }
 
        if (file == null) {
 
            System.err.println("Invalid argument: no file specified");
 
 
 
            throw new IllegalArgumentException("No file specified");
 
        }
 
 
 
        if (splitConfig == null) {
 
            try {
 
                readSplitConfig();
 
            }
 
            catch (Exception exc) {
 
                System.out.println("Error reading: XMLConfigSplit.properties - " + exc);
 
                splitConfig = new HashMap<String, SplitConfig>();
 
                mainToSplitFile = new HashMap<String, List<String>>();
 
            }
 
        }
 
 
 
        Document document = documents.get(file);
 
        if ((document != null) && !force) {
 
            return document;
 
        }
 
 
 
        if (isSplitFile(file)) {
 
            document = splitDocuments.get(file);
 
            if ((document != null) && !force) {
 
                return document;
 
            }
 
 
 
            SplitConfig sCfg = splitConfig.get(file);
 
            mainFile = sCfg.getFileSrc();
 
        }
 
 
 
        URL currentUrl = getURL(mainFile, classLoader, force, canBeReloaded);
 
        System.out.println("Retrieved Document URL: " + currentUrl);
 
 
 
        try {
 
            document = readDocument(currentUrl, mainFile);
 
 
 
            documents.put(mainFile, document);
 
            urls.put(mainFile, currentUrl);
 
            if (canBeReloaded) {
 
                reloadableDocuments.put(mainFile, document);
 
 
 
                ConfigurationEvent event = new ConfigurationEvent(ConfigurationEvent.EVT_FILE_LOADED, mainFile,
 
                        urls.get(mainFile));
 
                prepareConfigurationEvent(event, true);
 
            }
 
 
 
            if (isSplitFile(file)) {
 
                document = initSplitFile(file, mainFile, document);
 
            }
 
            return document;
 
        }
 
        catch (Throwable thr) {
 
            thr.printStackTrace();
 
 
 
            throw new XMLConfigException("XML XMLConfig error (File:" + file + ", Node:-, XPath:-)", thr);
 
        }
 
    }
 
  
 
/**
 
/**
* Checks if configuration is composed by multiple files.
+
* Loads a configuration file and, if necessary, notifies registered
 +
* listeners. This method can be used in order to preload the configuration
 +
* file.
 +
*
 +
* @param file
 +
*        the file to read
 +
* @param classLoader
 +
*        the class loader to use to retrieve the file to read
 +
* @param force
 +
*        force the reload of file if already present in cache
 +
* @param canBeReloaded
 +
*        flag that indicates if this file can be changed and can be
 +
*        reloaded
 +
* @return the complete URL used to load the file.
 +
* @exception XMLConfigException
 +
*            if error occurs
 +
*/
 +
public static synchronized URL load(String file, ClassLoader classLoader, boolean force, boolean canBeReloaded)
 +
        throws XMLConfigException
 +
/**
 +
* Discards all cached configuration files, notifies all registered
 +
* listeners, reload discarded files and notifies all registered listeners.
 
*  
 
*  
* @param document
+
* @exception XMLConfigException
* @return if configuration is composed by multiple files.
+
*           if error occurs
 
*/
 
*/
public static boolean isCompositeXMLConfig(Document document)
+
public static synchronized void reloadAll() throws XMLConfigException
  
 
/**
 
/**
* @param baseUrl
+
* If loaded discards the given file and notifies all registered listeners,
* @param document
+
* then reloads the given file (only if it was previously loaded) and
* @return the read configuration as {@link org.w3c.dom.Document Document}
+
* notifies all registered listeners.
* @throws XMLConfigException
+
*
 +
* @param file
 +
*       the file to reload
 +
* @exception XMLConfigException
 +
*            if error occurs
 
*/
 
*/
public static synchronized Document readCompositeXMLConfig(URL baseUrl, Document document)
+
public static synchronized void reload(String file) throws XMLConfigException
            throws XMLConfigException
 
  
 
/**
 
/**
* @param masterURL
+
* Discards all cached files and notifies all listeners.
* @param xml
 
* @return the input with replaced properties
 
 
*/
 
*/
public static synchronized byte[] replaceXMLProperties(URL masterURL, byte[] xml)
+
public static synchronized void discardAll()
  
 
/**
 
/**
* @param baseConfigPath
+
* Discards the given file. If the file was previously loaded then the
 +
* listeners will be notified, otherwise no action will be taken.
 +
*
 +
* @param file
 +
*        the file to discard
 
*/
 
*/
public static void setBaseConfigPath(String baseConfigPath)
+
public static synchronized void discard(String file)
  
 
/**
 
/**
* @return the base configuration path
+
* Returns an array of String s containing the names of the files
 +
* currently loaded into XMLConfig private cache.
 +
*
 +
* @return an array of String s containing the names of the files
 +
*        currently loaded into XMLConfig private cache.
 
*/
 
*/
public static String getBaseConfigPath()
+
public static synchronized String[] getLoadedFiles()
 +
</syntaxhighlight>
  
private static Document readDocument(URL url, String file) throws Exception
 
  
private static Document readCompositeXMLConfig(URL baseUrl, DocumentBuilder db, Element config) throws Exception
+
==XMLConfig utility methods==
 +
<syntaxhighlight lang="java5">
 +
/**
 +
* Sets the entity resolver used to resolve entities into the configuration
 +
* files.
 +
*
 +
* @param entityResolver
 +
*        EntityResolver to use in order to resolve entity. If
 +
*        null is specified then the default XML mechanism is
 +
*        used.
 +
*/
 +
public static synchronized void setEntityResolver(EntityResolver entityResolver)
  
private static void mergeXML(Document global, Document current, Element currentElement) throws Exception
+
/**
 
+
* Uses the default entity resolver to resolve entities into the
private static void mergeFragment(Document global, Document current, Element fragmentElement) throws Exception
+
* configuration files. The default entity resolver does not resolve
 
+
* anything.
private static Document readXML(URL baseUrl, DocumentBuilder db, Element documentElement) throws Exception
+
*
 
+
* @see #setEntityResolver(org.xml.sax.EntityResolver)
private static Document readXML(URL baseUrl, DocumentBuilder db, String relativeLocation) throws Exception
+
*/
 
+
public static synchronized void setDefaultEntityResolver()
private static synchronized Document readXML(URL url, String file, DocumentBuilder db) throws Exception
 
 
 
@SuppressWarnings("unchecked")
 
private static void readSplitConfig() throws Exception
 
 
 
private static boolean isSplitFile(String file)
 
  
 
/**
 
/**
* @param file
+
* Returns the entity resolver for the configuration.
* @param document
+
*  
* @param sCfg
+
* @return the entity resolver for the configuration
* @return
 
* @throws XMLConfigException
 
 
*/
 
*/
private static Document initSplitFile(String file, String mainFile, Document document) throws XMLConfigException
+
public static synchronized EntityResolver getEntityResolver()
 
 
private static Document getOwnerDocument(Node node)
 
 
</syntaxhighlight>
 
</syntaxhighlight>

Latest revision as of 17:35, 21 December 2012

Class FQN: it.greenvulcano.configuration.XMLConfig

XMLConfig public static methods

/**
* Reads a value. If the XPath selects many nodes the values are appended
* together.
* 
* @param file
*        file to read
* @param xpath
*        parameter to read specified as absolute path to the root of the
*        file.
* 
* @return the searched value or null if the XPath select no
*         node.
* 
* @throws XMLConfigException
*         if some error occurs.
* 
*/
public static String get(String file, String xpath) throws XMLConfigException

/**
* Reads a value. If the XPath selects many nodes the values are appended
* together.
* 
* @param node
*        base for XPath
* @param xpath
*        parameter to read specified as relative path to the node.
* 
* @return the searched value or null if the XPath selects no node.
* 
* @throws XMLConfigException
*         if some error occurs.
* 
*/
public static String get(Node node, String xpath) throws XMLConfigException

/**
* Reads a value. If the XPath selects many nodes the values are appended
* together.
* 
* @param file
*        file to read
* @param xpath
*        parameter to read specified as absolute path to the root of the
*        file.
* @param defaultValue
*        default value
* 
* @return the searched value or the specified default value if the XPath
*         selects no node or an error occurs.
* 
*/
public static String get(String file, String xpath, String defaultValue)

/**
* Reads a value. If the XPath selects many nodes the values are appended
* together.
* 
* @param node
*        base node for XPath
* @param xpath
*        parameter to read specified as relative path to node.
* @param defaultValue
*        default value
* 
* @return the searched value or the specified default value if the XPath
*         select no node or an error occurs.
* 
*/
public static String get(Node node, String xpath, String defaultValue)

/**
* Reads a single encrypted value.
* 
* @param file
*        file to read
* @param xpath
*        parameter to read specified as absolute path to the root of the
*        file.
* @param keyId
*        the key id to be used for decryption, if null or empty is used
*        DEFAULT_KEY_ID
* @param canBeClear
*        if true the data can be unencrypted
* 
* @return the searched value or null if the XPath select no node.
* @throws XMLConfigException
*         if some error occurs.
* 
*/
public static String getDecrypted(String file, String xpath, String keyId, boolean canBeClear)
         throws XMLConfigException

/**
* Reads a single encrypted value.
* 
* @param node
*        base for XPath
* @param xpath
*        parameter to read specified as relative path to the node.
* @param keyId
*        the key id to be used for decryption, if null or empty is used
*        DEFAULT_KEY_ID
* @param canBeClear
*        if true the data can be unencrypted
* 
* @return the searched value or null if the XPath selects no node.
* 
* @throws XMLConfigException
*         if some error occurs.
*/
public static String getDecrypted(Node node, String xpath, String keyId, boolean canBeClear)
        throws XMLConfigException
    
/**
* Reads a single encrypted value.
* 
* @param file
*        file to read
* @param xpath
*        parameter to read specified as absolute path to the root of the
*        file.
* @param keyId
*        the key id to be used for decryption, if null or empty is used
*        DEFAULT_KEY_ID
* @param canBeClear
*        if true the data can be unencrypted
* @param defaultValue
*        default value
* 
* @return the searched value or the specified default value if the XPath
*         select no node or an error occurs.
* 
*/
public static String getDecrypted(String file, String xpath, String keyId, boolean canBeClear, String defaultValue)

/**
* Reads a single encrypted value.
* 
* @param node
*        base node for XPath
* @param xpath
*        parameter to read specified as relative path to node.
* @param keyId
*        the key id to be used for decryption, if null or empty is used
*        DEFAULT_KEY_ID
* @param canBeClear
*        if true the data can be unencrypted
* @param defaultValue
*        default value
* 
* @return the searched value or the specified default value if the XPath
*         select no node or an error occurs.
* 
*/
public static String getDecrypted(Node node, String xpath, String keyId, boolean canBeClear, String defaultValue)

/**
* Reads a single encrypted value.
* 
* @param file
*        file to read
* @param xpath
*        parameter to read specified as absolute path to the root of the
*        file.
* 
*        Sets the key id as DEFAULT_KEY_ID and canBeClear at true
* 
* @return the searched value or null if the XPath select no node.
* @throws XMLConfigException
*         if some error occurs.
* 
*/
public static String getDecrypted(String file, String xpath) throws XMLConfigException

/**
* Reads a single encrypted value.
* 
* @param node
*        base for XPath
* @param xpath
*        parameter to read specified as relative path to the node.
* 
*        Sets the key id as DEFAULT_KEY_ID and canBeClear at true
* 
* @return the searched value or null if the XPath select no node.
* 
* @throws XMLConfigException
*         if some error occurs.
* 
*/
public static String getDecrypted(Node node, String xpath) throws XMLConfigException

/**
* Reads a single encrypted value.
* 
* @param file
*        file to read
* @param xpath
*        parameter to read specified as absolute path to the root of the
*        file.
* @param defaultValue
*        default value
* 
*        Sets the key id as DEFAULT_KEY_ID and canBeClear at true
* 
* @return the searched value or the specified default value if the XPath
*         select no node or an error occurs.
* 
*/
public static String getDecrypted(String file, String xpath, String defaultValue)

/**
* Reads a single encrypted value.
* 
* @param node
*        base node for XPath
* @param xpath
*        parameter to read specified as relative path to node.
* @param defaultValue
*        default value
* 
*        Sets the key id as DEFAULT_KEY_ID and canBeClear at true
* 
* @return the searched value or the specified default value if the XPath
*         select no node or an error occurs.
* 
*/
public static String getDecrypted(Node node, String xpath, String defaultValue)

/**
* Decrypt a string encrypted by default XMLConfig key.
* 
* @param value
*        the value to decrypt
* 
* @return the decrypted value or value if not encrypted
* @throws XMLConfigException
*         if some error occurs.
* 
*/
 public static String getDecrypted(String value) throws XMLConfigException

/**
* Encrypt a string using default XMLConfig key.
* 
* @param value
*        the value to encrypt
* 
* @return the encrypted value
* @throws XMLConfigException
*         if some error occurs.
* 
*/
public static String getEncrypted(String value) throws XMLConfigException

/**
* Return an integer parameter. 
* This method uses get() to obtain the value, then convert it
* to an integer.
* 
* @param file
* @param xpath
* @return the searched integer value from the configuration.
* 
* @throws XMLConfigException
*         if any error occurs
*/
public static int getInteger(String file, String xpath) throws XMLConfigException

/**
* Return an integer parameter.
* This method uses get() to obtain the value, then convert it
* to an integer.
* 
* @param node
*        base node for XPath
* @param xpath
*        parameter to read specified as relative path to node.
* 
* @return the searched integer value from the configuration.
* 
* @throws XMLConfigException
*         if an error occurs
*/
public static int getInteger(Node node, String xpath) throws XMLConfigException

/**
* Return an integer parameter.
* This method uses get() to obtain the value, then convert it
* to an integer.
* 
* @param file
*        the configuration file
* @param xpath
*        the XPath to search
* @param defaultValue
*        value to return if XPath not match
* @return the parameter value. If the parameter does not exists or an error
*         occurs then the specified default value will be returned.
* 
*/
public static int getInteger(final String file, final String xpath, final int defaultValue)

/**
* Return an integer parameter. 
* This method uses get() to obtain the value, then convert it
* to an integer.
* 
* @param node
*        base node for XPath
* @param xpath
*        parameter to read specified as relative path to node.
* @param defaultValue
*        default value
* 
* @return the searched value or the specified default value if the XPath
*         select no node or an error occurs.
* 
*/
public static int getInteger(Node node, String xpath, int defaultValue)

/**
* Returns a long parameter.
* This method uses get() to obtain the value, then converts it
* to a long.
* 
* @param file
* @param xpath
* @return the searched long value from the configuration.
* 
* @throws XMLConfigException
*         if an error occurs
*/
public static long getLong(String file, String xpath) throws XMLConfigException

/**
* Returns a long parameter.
* This method uses get() to obtain the value, then convert it
* to a long.
* 
* @param node
*        base node for XPath
* @param xpath
*        parameter to read specified as relative path to node.
* 
* @return the searched long value from the configuration.
* 
* @throws XMLConfigException
*         if an error occurs
*/
public static long getLong(Node node, String xpath) throws XMLConfigException

/**
* Returns a long parameter.
* This method uses get() to obtain the value, then convert it
* to a long.
* 
* @param file
* @param xpath
* @param defaultValue
* 
* @return the parameter value. If the parameter does not exists or an error
*         occurs then the specified default value will be returned.
* 
*/
public static long getLong(String file, String xpath, long defaultValue)

/**
* Returns a long parameter.
* This method uses get() to obtain the value, then convert it
* to a long.
* 
* @param node
*        base node for XPath
* @param xpath
*        parameter to read specified as relative path to node.
* @param defaultValue
* 
* @return the searched value or the specified default value if the XPath
*         select no node or an error occurs.
* 
*/
public static long getLong(Node node, String xpath, long defaultValue)

/**
* Returns a double parameter.
* This method uses get() to obtain the value, then convert it
* to a double.
* 
* @param file
* @param xpath
* @return the searched double value from the configuration.
* 
* @throws XMLConfigException
*         if an error occurs
*/
public static double getDouble(String file, String xpath) throws XMLConfigException

/**
* Returns a double parameter. 
* This method uses get() to obtain the value, then convert it
* to a double.
* 
* @param node
*        base node for XPath
* @param xpath
*        parameter to read specified as relative path to node.
* 
* @return the searched double value from the configuration.
* 
* @throws XMLConfigException
*         if an error occurs
*/
public static double getDouble(Node node, String xpath) throws XMLConfigException

/**
* Return a double parameter.
* This method uses get() to obtain the value, then convert it
* to a double.
* 
* @param file
* @param xpath
* @param defaultValue
* 
* @return the parameter value. If the parameter does not exists or an error
*         occurs then the specified default value will be returned.
* 
*/
public static double getDouble(String file, String xpath, double defaultValue)

/**
* Returns a double parameter.
* This method uses get() to obtain the value, then convert it
* to a double.
* 
* @param node
*        base node for XPath
* @param xpath
*        parameter to read specified as relative path to node.
* @param defaultValue
*        default value
* 
* @return the searched value or the specified default value if the XPath
*         select no node or an error occurs.
* 
*/
public static double getDouble(Node node, String xpath, double defaultValue)

/**
* Returns a float parameter.
* This method uses get() to obtain the value, then convert it
* to a float.
* 
* @param file
* @param xpath
* @return the searched float value from the configuration.
* 
* @throws XMLConfigException
*         if an error occurs
*/
public static float getFloat(String file, String xpath) throws XMLConfigException

/**
* Return a float parameter.
* This method uses get() to obtain the value, then converts it
* to a float.
* 
* @param node
*        base node for XPath
* @param xpath
*        parameter to read specified as relative path to node.
* 
* @return the searched float value from the configuration.
* 
* @throws XMLConfigException
*         if an error occurs
*/
public static float getFloat(Node node, String xpath) throws XMLConfigException

/**
* Return a float parameter.
* This method uses get() to obtain the value, then converts it
* to a float.
* 
* @param file
* @param xpath
* @param defaultValue
* 
* @return the parameter value. If the parameter does not exists or an error
*         occurs then the specified default value will be returned.
* 
*/
public static float getFloat(String file, String xpath, float defaultValue)

/**
* Returns a float parameter.
* This method uses get() to obtain the value, then converts it
* to a float.
* 
* @param node
*        base node for XPath
* @param xpath
*        parameter to read specified as relative path to node.
* @param defaultValue
*        default value
* 
* @return the searched value or the specified default value if the XPath
*         select no node or an error occurs.
* 
*/
public static float getFloat(Node node, String xpath, float defaultValue)

/**
* Returns a boolean parameter.
* 
* The value returned is true if and only if the parameter red is
* equal, ignoring case, to "true" or "yes" or "on". Otherwise, it returns
* false.
* 
* @param file
* @param xpath
* @return the boolean value of the parameter.
* @throws XMLConfigException
*/
public static boolean getBoolean(String file, String xpath) throws XMLConfigException

/**
* Returns a boolean parameter.
* 
* The value returned is true if and only if the parameter red is
* equal, ignoring case, to "true" or "yes" or "on". Otherwise, it returns
* false.
* 
* @param node
*        base node for XPath
* @param xpath
*        parameter to read specified as relative path to node.
* 
* @return the searched boolean value from the configuration.
* 
* @throws XMLConfigException
*/
public static boolean getBoolean(Node node, String xpath) throws XMLConfigException

/**
* Returns a boolean parameter.
* 
* The value returned is true if and only if the parameter red is
* equal, ignoring case, to "true" or "yes" or "on". Otherwise, it returns
* false.
* 
* @param file
* @param xpath
* @param defaultValue
* @return the boolean value of the parameter. If the parameter does not
*         exists or an error occurs then the specified default value will
*         be returned.
*/
public static boolean getBoolean(String file, String xpath, boolean defaultValue)

/**
* Returns a boolean parameter.
* 
* The value returned is true if and only if the parameter red is
* equal, ignoring case, to "true" or "yes" or "on". Otherwise, it returns
* false.
* 
* @param node
*        base node for XPath
* @param xpath
*        parameter to read specified as relative path to node.
* @param defaultValue
*        default value
* 
* @return the searched value or the specified default value if the XPath
*         select no node or an error occurs.
*/
public static boolean getBoolean(Node node, String xpath, boolean defaultValue)

/**
* Checks if the given parameter exists. <br>
* It checks that get() method does not return null.
* 
* @param file
* @param xpath
* @return if the given parameter exists.
* 
* @throws XMLConfigException
*         if some error occurs.
*/
public static boolean exists(String file, String xpath) throws XMLConfigException

/**
* Checks if the given parameter exists.
* It checks that get() method does not return null.
* 
* @param node
* @param xpath
* @return if the given parameter exists
* 
* @throws XMLConfigException
*         if some error occurs.
*/
public static boolean exists(Node node, String xpath) throws XMLConfigException

/**
* Obtains a list of nodes that match the given XPath.
* 
* @param file
*        file to read
* @param xpath
*        parameter to read specified as absolute path to the root of the
*        file.
* @return a list of nodes that match the given XPath.
* 
* @throws XMLConfigException
*         if some error occurs.
*/
public static NodeList getNodeList(String file, String xpath) throws XMLConfigException

/**
* Obtains a list of nodes that match the given XPath.
* 
* @param node
*        base node for XPath
* @param xpath
*        parameter to read specified as relative path to the node
* @return a list of nodes that match the given XPath.
* 
* @throws XMLConfigException
*         if some error occurs.
*/
public static NodeList getNodeList(Node node, String xpath) throws XMLConfigException

/**
* Obtains a list of nodes that match the given XPath as a Collection.
* 
* @param file
*        file to read
* @param xpath
*        parameter to read specified as absolute path to the root of the
*        file.
* @return a list of nodes that match the given XPath as a
*         Collection.
* 
* @throws XMLConfigException
*         if some error occurs.
*/
public static Collection<Node> getNodeListCollection(String file, String xpath) throws XMLConfigException

/**
* Obtains a list of nodes that match the given XPath as a Collection.
* 
* @param node
*        base node for XPath
* @param xpath
*        parameter to read specified as relative path to the node
* @return a list of nodes that match the given XPath as a
*         Collection.
* 
* @throws XMLConfigException
*         if some error occurs.
*/
public static Collection<Node> getNodeListCollection(Node node, String xpath) throws XMLConfigException

/**
* Obtains a single node that matches the given XPath.
* 
* @param file
*        file to read
* @param xpath
*        parameter to read specified as absolute path to the root of the
*        file.
* @return a single node that matches the given XPath.
* 
* @throws XMLConfigException
*         if some error occurs.
*/
public static Node getNode(String file, String xpath) throws XMLConfigException

/**
* Obtains a single node that matches the given XPath.
* 
* @param node
*        base node for XPath
* @param xpath
*        parameter to read specified as relative path to the node
* @return a single node that matches the given XPath.
* 
* @throws XMLConfigException
*         if some error occurs.
*/
public static Node getNode(Node node, String xpath) throws XMLConfigException


XMLConfig configuration events management methods

/**
* Add a ConfigurationListener.
* 
* @param listener
*/
public static void addConfigurationListener(ConfigurationListener listener)

/**
* Adds a ConfigurationListener listening for events related to a single
* particular file.
* 
* @param listener
*        a ConfigurationListener object
* @param filename
*        a String containing the name of a file whose changes must
*        be notified to the given listener
*/
public static void addConfigurationListener(ConfigurationListener listener, String filename)

/**
* Add a ConfigurationListener listening for events related to a particular
* set of files.
* 
* @param listener
*        a ConfigurationListener object
* @param fileList
*        a List of String s containing the name of files
*        whose changes must be notified to the given listener
*/
public static void addConfigurationListener(ConfigurationListener listener, List<String> fileList)
    
/**
* Removes a ConfigurationListener
* 
* @param listener
*/
public static void removeConfigurationListener(ConfigurationListener listener)

/**
* Removes a ConfigurationListener listening for changes on a single file
* 
* @param listener
*        a ConfigurationListener object
* @param filename
*        a String containing the name of a file whose changes must
*        be notified to the given listener
*/
public static void removeConfigurationListener(ConfigurationListener listener, String filename)

/**
* Remove a ConfigurationListener listening for changes on a subset of files
* 
* @param listener
*        a ConfigurationListener object
* @param fileList
*        a List of String s containing the name of files
*        whose changes must be notified to the given listener
*/
public static void removeConfigurationListener(ConfigurationListener listener, List<String> fileList)


XMLConfig file management methods

/**
* Loads a configuration file and, if necessary, notifies registered
* listeners. This method can be used in order to preload the configuration
* file.
* 
* @param file
*        the file to read
* @return the complete URL used to load the file.
* @exception XMLConfigException
*            if error occurs
*/
public static synchronized URL load(String file) throws XMLConfigException

/**
* Loads a configuration file and, if necessary, notifies registered
* listeners. This method can be used in order to preload the configuration
* file.
* 
* @param file
*        the file to read
* @param classLoader
*        the class loader to use to retrieve the file to read
* @param force
*        force the reload of file if already present in cache
* @param canBeReloaded
*        flag that indicates if this file can be changed and can be
*        reloaded
* @return the complete URL used to load the file.
* @exception XMLConfigException
*            if error occurs
*/
public static synchronized URL load(String file, ClassLoader classLoader, boolean force, boolean canBeReloaded)
         throws XMLConfigException
/**
* Discards all cached configuration files, notifies all registered
* listeners, reload discarded files and notifies all registered listeners.
* 
* @exception XMLConfigException
*            if error occurs
*/
public static synchronized void reloadAll() throws XMLConfigException

/**
* If loaded discards the given file and notifies all registered listeners,
* then reloads the given file (only if it was previously loaded) and
* notifies all registered listeners.
* 
* @param file
*        the file to reload
* @exception XMLConfigException
*            if error occurs
*/
public static synchronized void reload(String file) throws XMLConfigException

/**
* Discards all cached files and notifies all listeners.
*/
public static synchronized void discardAll()

/**
* Discards the given file. If the file was previously loaded then the
* listeners will be notified, otherwise no action will be taken.
* 
* @param file
*        the file to discard
*/
public static synchronized void discard(String file)

/**
* Returns an array of String s containing the names of the files
* currently loaded into XMLConfig private cache.
* 
* @return an array of String s containing the names of the files
*         currently loaded into XMLConfig private cache.
*/
public static synchronized String[] getLoadedFiles()


XMLConfig utility methods

/**
* Sets the entity resolver used to resolve entities into the configuration
* files.
* 
* @param entityResolver
*        EntityResolver to use in order to resolve entity. If
*        null is specified then the default XML mechanism is
*        used.
*/
public static synchronized void setEntityResolver(EntityResolver entityResolver)

/**
* Uses the default entity resolver to resolve entities into the
* configuration files. The default entity resolver does not resolve
* anything.
* 
* @see #setEntityResolver(org.xml.sax.EntityResolver)
*/
public static synchronized void setDefaultEntityResolver()

/**
* Returns the entity resolver for the configuration.
* 
* @return the entity resolver for the configuration
*/
public static synchronized EntityResolver getEntityResolver()