de.aitools.ie.stemming.examples
Class ConfigurationManager

java.lang.Object
  extended by de.aitools.ie.stemming.examples.ConfigurationManager

public class ConfigurationManager
extends java.lang.Object

Provides access to a configuration file located in the users home directory. The intend is to support machine-dependent settings such as pathnames for different aitools modules. Usually the configuration file is located in
$HOME/.aitools/module/config
The configuration file is considered as properties file as created by the java.util.Properties class.

Author:
christof.braeutigam@uni-weimar.de

Constructor Summary
ConfigurationManager()
           
 
Method Summary
 java.lang.String getConfigFileName()
          Returns the absolute pathname to the configuration file.
 java.util.Properties getProperties()
          Loads and returns the properties provided by this configuration manager.
 boolean init(java.lang.String moduleName, java.lang.String configFileName)
          Initializes the configuration manager and checks if the configuration file specified by the given parameters exists.
 boolean init(java.lang.String moduleName, java.lang.String configFileName, java.util.Properties p)
          Initializes the configuration manager and creates a configuration file with the contents given by p.
static void main(java.lang.String[] args)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConfigurationManager

public ConfigurationManager()
Method Detail

getConfigFileName

public java.lang.String getConfigFileName()
Returns the absolute pathname to the configuration file. Note that the configuration manager has to be initialized first.

Returns:
absolute path to configuration file

init

public boolean init(java.lang.String moduleName,
                    java.lang.String configFileName)
             throws java.io.IOException
Initializes the configuration manager and checks if the configuration file specified by the given parameters exists. The configuration file is expected at
$HOME/.aitools/moduleName/configFileName
If no such file exists at this location or one or more of the parent directories don't exist, all necessary directories and an empty file are created.
Note: calling this method doesn't change an existing config file.

Parameters:
moduleName - name for the parent directory of the configuration file
configFileName - filename for the configuration file
Returns:
true if the configuration file exists or is successfully created, false otherwise
Throws:
java.io.IOException

init

public boolean init(java.lang.String moduleName,
                    java.lang.String configFileName,
                    java.util.Properties p)
             throws java.io.IOException
Initializes the configuration manager and creates a configuration file with the contents given by p. Note that an existing config file will be overwritten! The config file is created at
$HOME/.aitools/moduleName/configFileName
If one or more of the parent directories don't exist, all necessary directories are created.

Parameters:
moduleName - name for the parent directory of the configuration file
configFileName - filename for the configuration file
p - properties to store in the newly created configuration file
Returns:
true if the config file is successfully created, false otherwise
Throws:
java.io.IOException

getProperties

public java.util.Properties getProperties()
                                   throws java.io.IOException
Loads and returns the properties provided by this configuration manager. Note that the configuration manager has to bw initialized first.

Returns:
properties provided by this configuration manager
Throws:
java.io.IOException

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException
Parameters:
args -
Throws:
java.io.IOException