edu.cs.ai.kreator.control.config
Class ConfigurationFacility

java.lang.Object
  extended by edu.cs.ai.kreator.control.config.ConfigurationFacility

public abstract class ConfigurationFacility
extends java.lang.Object

This abstract class manages the org.apache.commons.configuration.XMLConfiguration configuration object which holds the KReator configuration read from the "kreater_config.xml" file.
Calling ConfigurationFacility.initialize() initializes the ConfigurationFacility. If it has already been initialized can be checked with ConfigurationFacility.isInitialized().

To access a configuration option (all configuration options can be addressed by the references in "Configuration"), use the "getProperty(...)" methods.

To store or replace a property, the setProperty(key, value) method must be used. To add another value to an existing (multi-valued) property, then addProperty(key, value) method must be used.

Author:
Marc Finthammer, Matthias Thimm

Field Summary
static org.apache.log4j.Logger LOG
           
 
Constructor Summary
ConfigurationFacility()
           
 
Method Summary
static java.util.TreeSet<java.lang.String> getAllOptionStrings()
          Returns a sorted set of strings containing all configuration options (i.e. keys).
static java.io.File getConfigFile()
          Returns the configuration file.
static java.lang.Boolean getProperty(BooleanConfigurationOption option)
          Fetches the value for the given option from the config.
static java.lang.Object getProperty(ConfigurationOption option)
          Fetches the value for the given option from the config.
static Pair<java.lang.Double,java.lang.Boolean> getProperty(DoubleBoolConfigOption option)
          Fetches the value for the given option from the config.
static java.lang.Double getProperty(DoubleConfigurationOption option)
          Fetches the value for the given option from the config.
static Triple<java.awt.Color,java.lang.Boolean,java.lang.Boolean> getProperty(FontStyleConfigurationOption option)
          Fetches the value for the given option from the config.
static Pair<java.lang.Integer,java.lang.Boolean> getProperty(IntBoolConfigOption option)
          Fetches the value for the given option from the config.
static java.lang.Integer getProperty(IntegerConfigurationOption option)
          Fetches the value for the given option from the config.
static java.util.List<java.lang.String> getProperty(PathListConfigurationOption option)
          Fetches the value for the given option from the config.
static Pair<java.lang.String,java.lang.Boolean> getProperty(StringBooleanConfigurationOption option)
          Fetches the value for the given option from the config.
static java.lang.String getProperty(StringConfigurationOption option)
          Fetches the value for the given option from the config.
static java.util.List<java.lang.String> getProperty(StringListConfigurationOption option)
          Fetches the value for the given option from the config.
static java.lang.String getProperty(StringSelectionConfigurationOption option)
          Fetches the value for the given option from the config.
static java.lang.String getStringRepresentation()
          Returns a string representation of the whole configuration.
static java.lang.String getStringRepresentation(java.lang.String leftMargin, boolean omitUnimportantProperties)
          Returns a string representation of the configuration.
static org.apache.commons.configuration.XMLConfiguration initialize(java.lang.String configName)
          Initializes the ConfigurationFacility, i.e. the configuration file is loaded and the appropriate configuration is build.
static boolean isInitialized()
          Returns true if the ConfigurationFacility has already been initialized.
static void setProperty(ConfigurationOption option, java.lang.Object value)
          This method sets the given property with the given value and saves the configuration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

public static final org.apache.log4j.Logger LOG
Constructor Detail

ConfigurationFacility

public ConfigurationFacility()
Method Detail

initialize

public static org.apache.commons.configuration.XMLConfiguration initialize(java.lang.String configName)
Initializes the ConfigurationFacility, i.e. the configuration file is loaded and the appropriate configuration is build. If no configuration file exists, a new default configuration file is created.

Returns:
the configuration object

isInitialized

public static boolean isInitialized()
Returns true if the ConfigurationFacility has already been initialized.

Returns:
true if initialized; false otherwise

getConfigFile

public static java.io.File getConfigFile()
Returns the configuration file.

Returns:
configuration file

getProperty

public static java.lang.Object getProperty(ConfigurationOption option)
Fetches the value for the given option from the config. This is the most general variant of the "getProperty" methods and can be used when the class of the configruation property is unknown.

Parameters:
option - a configuration option.
Returns:
the value of the option.

getProperty

public static java.lang.String getProperty(StringConfigurationOption option)
Fetches the value for the given option from the config.

Parameters:
option - a configuration option.
Returns:
the value of the option.

getProperty

public static java.lang.Boolean getProperty(BooleanConfigurationOption option)
Fetches the value for the given option from the config.

Parameters:
option - a configuration option.
Returns:
the value of the option.

getProperty

public static java.lang.Integer getProperty(IntegerConfigurationOption option)
Fetches the value for the given option from the config.

Parameters:
option - a configuration option.
Returns:
the value of the option.

getProperty

public static java.lang.Double getProperty(DoubleConfigurationOption option)
Fetches the value for the given option from the config.

Parameters:
option - a configuration option.
Returns:
the value of the option.

getProperty

public static java.lang.String getProperty(StringSelectionConfigurationOption option)
Fetches the value for the given option from the config.

Parameters:
option - a configuration option.
Returns:
the value of the option.

getProperty

public static java.util.List<java.lang.String> getProperty(StringListConfigurationOption option)
Fetches the value for the given option from the config.

Parameters:
option - a configuration option.
Returns:
the value of the option.

getProperty

public static java.util.List<java.lang.String> getProperty(PathListConfigurationOption option)
Fetches the value for the given option from the config.

Parameters:
option - a configuration option.
Returns:
the value of the option.

getProperty

public static Pair<java.lang.String,java.lang.Boolean> getProperty(StringBooleanConfigurationOption option)
Fetches the value for the given option from the config.

Parameters:
option - a configuration option.
Returns:
the value of the option.

getProperty

public static Pair<java.lang.Integer,java.lang.Boolean> getProperty(IntBoolConfigOption option)
Fetches the value for the given option from the config.

Parameters:
option - a configuration option.
Returns:
the value of the option.

getProperty

public static Pair<java.lang.Double,java.lang.Boolean> getProperty(DoubleBoolConfigOption option)
Fetches the value for the given option from the config.

Parameters:
option - a configuration option.
Returns:
the value of the option.

getProperty

public static Triple<java.awt.Color,java.lang.Boolean,java.lang.Boolean> getProperty(FontStyleConfigurationOption option)
Fetches the value for the given option from the config.

Parameters:
option - a configuration option.
Returns:
the value of the option.

setProperty

public static void setProperty(ConfigurationOption option,
                               java.lang.Object value)
                        throws java.lang.IllegalArgumentException
This method sets the given property with the given value and saves the configuration.

Parameters:
option - a configuration option.
value - a value for the option
Throws:
java.lang.IllegalArgumentException - if the value does not match the option or the option is of unknown type.

getStringRepresentation

public static java.lang.String getStringRepresentation(java.lang.String leftMargin,
                                                       boolean omitUnimportantProperties)
Returns a string representation of the configuration.

Parameters:
leftMargin - left margin for pretty print.
omitUnimportantProperties - leaves out unimportant properties (e.g. editor.highlighting)
Returns:
a string representation of the configuration.

getStringRepresentation

public static java.lang.String getStringRepresentation()
Returns a string representation of the whole configuration.

Returns:
a string representation of the configuration.

getAllOptionStrings

public static java.util.TreeSet<java.lang.String> getAllOptionStrings()
Returns a sorted set of strings containing all configuration options (i.e. keys).

Returns:
sorted set of configuration options.