org.nukesoft.bot2.botutil
Class XmlConfManager

java.lang.Object
  |
  +--org.nukesoft.bot2.botutil.XmlConfManager

public class XmlConfManager
extends Object

The ConfManager simplifies access to an XML based configuration file. It manages file management and data location. It also provides the ability to globalize an instance itself, thus making it staticaly accessable. This class acts as a wrapper for the TXML library. (http://sourceforge.net/projects/txml/)

Author:
Ryan Michela

Constructor Summary
XmlConfManager(File confFile)
          Creates a confuguration manager and loads a file.
XmlConfManager(File confFile, boolean globalize)
          Creates a confuguration manager and loads a file.
XmlConfManager(String confPath)
          Creates a confuguration manager and loads a file.
XmlConfManager(String confPath, boolean globalize)
          Creates a confuguration manager and loads a file.
 
Method Summary
 String[] getAllConfStrings(String confPath)
          Loads multiple string from the configuration file.
 XmlConfManager[] getConfSet(String partialConfPath)
          Returns an array of XmlConfManager objects that represent configuration subtrees with requested root nodes located in a designated location in the configuration file.
static XmlConfManager getGlobalConf()
          Gets the global configuration manager.
 String getOneConfString(String confPath)
          Loads a single string from the configuration file.
 void globalize()
          Promotes this XmlConfManager to global conf manager status.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlConfManager

public XmlConfManager(String confPath)
               throws IOException
Creates a confuguration manager and loads a file.

Parameters:
confPath - The path to the confuguration file to load.
Throws:
IOException - conf file not loaded.

XmlConfManager

public XmlConfManager(String confPath,
                      boolean globalize)
               throws IOException
Creates a confuguration manager and loads a file. Optionaly assigns the global config.

Parameters:
confPath - The path to the confuguration file to load.
globalize - Set to TRUE if you want this configuration file to be the global config.
Throws:
IOException - conf file not loaded.

XmlConfManager

public XmlConfManager(File confFile)
               throws IOException
Creates a confuguration manager and loads a file.

Parameters:
confFile - The confuguration file to load.
Throws:
IOException - conf file not loaded.

XmlConfManager

public XmlConfManager(File confFile,
                      boolean globalize)
               throws IOException
Creates a confuguration manager and loads a file. Optionaly assigns the global config.

Parameters:
confFile - The confuguration file to load.
globalize - Set to TRUE if you want this configuration file to be the global config.
Throws:
IOException - conf file not loaded.
Method Detail

getOneConfString

public String getOneConfString(String confPath)
                        throws IOException
Loads a single string from the configuration file. If the provided confPath returns multiple matches, only the first value is returned.

Parameters:
confPath - The path in the configuration hiearchy to load. Format: /RootNode/Node/Node/Element
Returns:
The value of the target node. NULL if ther are no matches.
Throws:
IOException - conf file not loaded.

getAllConfStrings

public String[] getAllConfStrings(String confPath)
                           throws IOException
Loads multiple string from the configuration file. If the provided confPath returns multiple matches, all values are returned.

Parameters:
confPath - The path in the configuration hiearchy to load. Format: /RootNode/Node/Node/Element
Returns:
The value of the target node. NULL if ther are no matches.
Throws:
IOException - conf file not loaded.

getConfSet

public XmlConfManager[] getConfSet(String partialConfPath)
                            throws IOException
Returns an array of XmlConfManager objects that represent configuration subtrees with requested root nodes located in a designated location in the configuration file. This behaves similar to getAllConfStrings, but returns data structures rather than values.

Parameters:
partialConfPath - The path in the configuration hiearchy to the top of the node set you wish to retreive. This includes the name of the target nodes.
Returns:
An array of XmlConfManagers representing the selected subtrees.
Throws:
IOException - conf file not loaded.

globalize

public void globalize()
Promotes this XmlConfManager to global conf manager status.


getGlobalConf

public static XmlConfManager getGlobalConf()
Gets the global configuration manager.

Returns:
The global ConfManager.