org.xvsm.configuration
Class ConfigurationManager

Package class diagram package ConfigurationManager
java.lang.Object
  extended by org.xvsm.configuration.ConfigurationManager

public final class ConfigurationManager
extends java.lang.Object

Author:
Christian Schreiber, Michael Proestler The ConfigurationManager class handles the whole configuration of the space. It has some defaultSettings that will be written to harddisk if there is no configuration file already.

Method Summary
 boolean getBooleanSetting(java.lang.String key)
          Get the setting for the specified key as a boolean.
static ConfigurationManager getInstance()
          Factory method.
 int getIntegerSetting(java.lang.String key)
          Get the setting for the specified key as an int.
 long getLongSetting(java.lang.String key)
          Get the setting for the specified key as a long.
 java.lang.String getStringSetting(java.lang.String key)
          Get the setting for the specified key as a String.
static void init(java.lang.String configurationFile)
          Initializes the ConfigurationManager to use a specific configuration File.
static void removeInstance()
          Destroys the ConfigurationManager instance.
protected  void setDefaults()
          Put default values into the defaultSettings.
 boolean setStringSetting(java.lang.String key, java.lang.String value)
          This function stores an key - value pair in the configuration file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static ConfigurationManager getInstance()
Factory method. If you want to use a specific configuration File use init(String) to initialize the ConfigurationManager before you call this method otherwise a default configuration file will be created and used.

Returns:
a ConfigurationManager instance.

removeInstance

public static void removeInstance()
Destroys the ConfigurationManager instance.


init

public static void init(java.lang.String configurationFile)
                 throws java.io.IOException
Initializes the ConfigurationManager to use a specific configuration File.
If the ConfigurationManager is not initializes with this method a default conifguration File will be created and used.

Parameters:
configurationFile - the configuration File which shall be used.
Throws:
java.io.IOException - when errors occure when writing the settings to the harddisk.

setDefaults

protected void setDefaults()
Put default values into the defaultSettings.


setStringSetting

public boolean setStringSetting(java.lang.String key,
                                java.lang.String value)
This function stores an key - value pair in the configuration file.

Parameters:
key - The key to the new setting.
value - The value to the new setting.
Returns:
True if the setting has been successfully stored, else false.

getStringSetting

public java.lang.String getStringSetting(java.lang.String key)
Get the setting for the specified key as a String.

Parameters:
key - the key to that setting.
Returns:
the value of that setting.

getIntegerSetting

public int getIntegerSetting(java.lang.String key)
Get the setting for the specified key as an int.

Parameters:
key - the key to that setting.
Returns:
the value of that setting.

getLongSetting

public long getLongSetting(java.lang.String key)
Get the setting for the specified key as a long.

Parameters:
key - the key to that setting.
Returns:
the value of that setting.

getBooleanSetting

public boolean getBooleanSetting(java.lang.String key)
Get the setting for the specified key as a boolean.

Parameters:
key - the key to that setting.
Returns:
the value of that setting.


Copyright © 2009. All Rights Reserved.