Class Config
- Direct Known Subclasses:
MessageVortexConfig
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()*copy()*voidcreateBooleanConfigValue(String id, String description, boolean dval) *voidcreateNumericConfigValue(String id, String description, int dval) *voidcreateSectionConfigValue(String id, String description, String dval) *booleancreateSectionListConfigValue(String id, String description, String dval) *booleancreateStringConfigValue(String id, String description, String dval) *booleangetBooleanValue(String section, String id) *static ConfigGets the default value of the named configuration item.getDescription(String id) Get the descriptive text of the named configuration item.getMap()intgetNumericValue(String section, String id) *String[]getSectionListValue(String section, String id) *getSectionValue(String section, String id) *getStringValue(String section, String id) *booleanisDefaultValue(String section, String id) Checks if a specific key is returning default values only.void*boolean*booleansetBooleanValue(String section, String id, boolean value, int lineNumber) *intsetNumericValue(String section, String id, int value, int lineNumber) *setSectionListValue(String section, String id, String value, int lineNumber) *setSectionValue(String section, String id, String value, int lineNumber) *setStringValue(String section, String id, String value, int lineNumber) *store()*void*
-
Constructor Details
-
Config
*Creates an config object following the spec given in the resource file.
- Parameters:
ressourceFile- filename of the resource file- Throws:
IOException- if an error happens while reading the file
-
-
Method Details
-
getResouceFilename
-
getDefault
- Throws:
IOException
-
copy
*Returns a deep copy of this config store.
- Returns:
- the copy
-
clear
public void clear()*Reverts config store to all default values.
-
createBooleanConfigValue
*Creates a new boolean config value in the store.
- Parameters:
id- the name (id) of the new valuedescription- the description for the valuedval- the default value
-
setBooleanValue
*Sets a boolean value in the application config.
- Parameters:
section- the section of the config to be affected (null for default section)id- key which should be setvalue- Value to be set in keylineNumber- the line number of the respective file (for error messages)- Returns:
- old value before setting to new value
- Throws:
NullPointerException- if key does not exist in configDataClassCastException- if key is not of type boolean
-
getBooleanValue
*Gets a boolean value from the application config.
- Parameters:
section- the section of the config to be affected (null for default section)id- key which should be set- Returns:
- current value of the specified key
- Throws:
NullPointerException- if key does not exist in configDataClassCastException- if key is not of type boolean
-
createNumericConfigValue
*Creates a new numeric config value in the store.
- Parameters:
id- the name (id) of the new valuedescription- the description for the valuedval- the default value
-
createSectionConfigValue
*Creates a new section config value in the store.
- Parameters:
id- the name (id) of the new valuedescription- the description for the valuedval- the default value
-
setNumericValue
*Sets a numeric value in the application config.
- Parameters:
section- section from which the value should be taken. null defaults to default sectionid- key which should be setvalue- Value to be set in keylineNumber- the line number of the respective file (for error messages)- Returns:
- old value before setting to new value
- Throws:
NullPointerException- if key does not exist in configDataClassCastException- if key is not of type boolean
-
getNumericValue
*Gets a numeric value from the application config.
- Parameters:
section- section from which the value should be taken. null defaults to default sectionid- key which should be set- Returns:
- current value of the specified key
- Throws:
NullPointerException- if key does not exist in configDataClassCastException- if key is not of type boolean
-
createSectionListConfigValue
*Creates a section_list config item.
Creates a config item with a case insensitive identifier. The content of the item may not be null.
- Parameters:
id- Name of config item (case insensitive)description- Description of value to be writtendval- Default content if not set- Returns:
- True if item did not exist and was successfully created
-
setSectionListValue
*Set a section_list value to a config parameter.
- Parameters:
section- section from which the value should be taken. null defaults to default sectionid- key which should be setvalue- Value to be set in keylineNumber- the line number of the respective file (for error messages)- Returns:
- the previously set value
- Throws:
NullPointerException- when id is unknown or value is nullClassCastException- when id is not a String setting
-
getSectionListValue
*Sets the value of a section_list type.
- Parameters:
section- section from which the value should be taken. 'Null' defaults to default sectionid- the id of the value to be retrieved- Returns:
- a list of sections
- Throws:
NullPointerException- when id is unknownClassCastException- when id is not a String setting
-
setSectionValue
*Set a section value to a config parameter.
- Parameters:
section- section from which the value should be taken. Use "null" to get the default sectionid- key which should be setvalue- Value to be set in keylineNumber- the line number of the respective file (for error messages)- Returns:
- the previously set value
- Throws:
NullPointerException- when id is unknown or value is nullClassCastException- when id is not a String setting
-
getSectionValue
*Gets the value of a section type.
- Parameters:
section- section from which the value should be taken. 'Null' defaults to default sectionid- the id of the value to be retrieved- Returns:
- a section name
- Throws:
NullPointerException- when id is unknownClassCastException- when id is not a String setting
-
createStringConfigValue
*Creates a String config item.
Creates a config item with a case insensitive identifier. The content of the item may not be null.
- Parameters:
id- Name of config item (case insensitive)description- Description of value to be writtendval- Default content if not set- Returns:
- True if item did not exist and was successfully created
-
removeConfigValue
*Removes a config value declaration from the config container.
- Parameters:
id- the id of the value to be removed- Returns:
- true if the id did exist
-
setStringValue
*Set a String value to a config parameter.
- Parameters:
section- section from which the value should be taken. 'null' defaults to default sectionid- Name of config item (case insensitive)value- Value to be set in keylineNumber- the line number of the respective file (for error messages)- Returns:
- the previously set value
- Throws:
NullPointerException- when id is unknown or value is nullClassCastException- when id is not a String setting
-
getStringValue
*Sets the value of a string type.
- Parameters:
section- section from which the value should be taken. 'null' defaults to default sectionid- the id of the value to be retrieved- Returns:
- the previously set value
- Throws:
NullPointerException- when id is unknownClassCastException- when id is not a String setting
-
isDefaultValue
Checks if a specific key is returning default values only.
- Parameters:
section- the section to be querriedid- the id of the key to be queried- Returns:
- true if there is a specific value set.
-
getMap
-
load
*Loads a config file and validates input.
Loads and parses a file according to the resources configuration
- Parameters:
filename- name of the property file to be read- Throws:
IOException- if the file is not parsed properly
-
store
*Writes config to a string.
Writes a commented file according to the configuration
- Returns:
- The configuration as string
- Throws:
IOException- if error writing file
-
store
*Writes a config file.
Writes a commented file according to the configuration
- Parameters:
filename- name of the property file to be written- Throws:
IOException- if error writing to file
-
getDescription
Get the descriptive text of the named configuration item.- Parameters:
id- identification of the configuration item- Returns:
- the configuration item description
-
getDefaultValue
Gets the default value of the named configuration item.- Parameters:
id- identification of the configuration item- Returns:
- the configuration items' default value
-