com.jstatcom.engine
Class ConfigHolder
- java.lang.Object
-
- com.jstatcom.engine.ConfigHolder
-
public final class ConfigHolder extends java.lang.ObjectThis class is used byEngineinstances to get all information that is necessary to run a specific engine. The types of configuration settings are defined in theConfigKeysimplementation for the underlying engine type. Instances of this class store information according to the respective configuration keys.For every engine type there exists only one instance of this class. Instances for engine types are created or referenced by the static factory method
valueOf.All information is stored permanently in an XML file defined in the respective engine type.
- See Also:
EngineTypes,ConfigKeys
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static classConfigHolder.KeyValPairInner class for storing key value pairs of this collection as XML elements.
-
Field Summary
Fields Modifier and Type Field and Description static XmlFormat<ConfigHolder>ConfigHolder_XMLXML format field for (de)serialization.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidadjustConfig()Creates a dialog to change the configuration settings for the respective engine.java.lang.StringgetConfig(ConfigKeys key)Get a configuration value for a key.java.util.Set<ConfigKeys>getConfigKeys()Gets aSetof all availableConfigKeys.EngineTypesgetEngineType()Returns the engine type associated withthis.voidsetConfig(ConfigKeys configKey, java.lang.String value)Set a key value pair to be stored by the config holder.static ConfigHoldervalueOf(EngineTypes engineType)Static initializer to return an instance ofConfigHolder.
-
-
-
Field Detail
-
ConfigHolder_XML
public static final XmlFormat<ConfigHolder> ConfigHolder_XML
XML format field for (de)serialization.
-
-
Method Detail
-
adjustConfig
public void adjustConfig()
Creates a dialog to change the configuration settings for the respective engine. It updates the XML configuration file if the changes were successful.
-
getConfig
public java.lang.String getConfig(ConfigKeys key)
Get a configuration value for a key.- Parameters:
key- that defines type of setting- Returns:
- a string containing the setting associated with
keyornullif the key is not contained - Throws:
java.lang.IllegalArgumentException-if (key == null)
-
getConfigKeys
public java.util.Set<ConfigKeys> getConfigKeys()
Gets aSetof all availableConfigKeys.- Returns:
- a set of all keys
-
getEngineType
public final EngineTypes getEngineType()
Returns the engine type associated withthis.- Returns:
- the engine type
-
setConfig
public void setConfig(ConfigKeys configKey, java.lang.String value)
Set a key value pair to be stored by the config holder.- Parameters:
configKey- the keyvalue- the value- Throws:
java.lang.IllegalArgumentException-if (configKey == null)or ifconfigKeyis not valid for the underlying engine type
-
valueOf
public static ConfigHolder valueOf(EngineTypes engineType)
Static initializer to return an instance ofConfigHolder. It parses the XML config file if it exists and tries to get all necessary configuration information. If the config file does not exist or if something is wrong with the settings, an input dialog is shown. The configuration file is updated if something has changed.- Parameters:
engineType- to define a specific engine- Returns:
- the initialized instance
- Throws:
java.lang.IllegalArgumentException-if (engineType == null)java.lang.IllegalStateException- if the user input dialog is cancelled but the settings are still invalid
-
-
DMelt 3.0 © DataMelt by jWork.ORG