Package kieker.common.configuration
Class Configuration
- All Implemented Interfaces:
Serializable,Cloneable,Map<Object,Object>
- Direct Known Subclasses:
ReadOnlyConfiguration
This class represents a configuration object within the Kieker project. Technically it is a property list with some additional methods and possibilities.
Some of the methods are marked as deprecated. This is not because they will be removed, but rather because they should not be used anymore (at least not directly
- they are still used in a valid way within this class). Normally we would remove them, but they are inherited from the class
Properties and can neither
be removed nor get a lower visibility modificator.- Since:
- 1.5
- Author:
- Jan Waller
- See Also:
-
Field Summary
Fields inherited from class java.util.Properties
defaults -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new (empty) configuration.Configuration(Properties defaults) Creates a new instance of this class using the given parameters. -
Method Summary
Modifier and TypeMethodDescriptionstatic final StringconvertToPath(String pathname) Based upon Guava 14.0.1 (Chris Nokleberg, Colin Decker).final Configurationflatten()Flattens the Properties hierarchies and returns a new Configuration object.final Configurationflatten(Configuration defaultConfiguration) Flattens the Properties hierarchies and returns a new Configuration object.final voidFlattens the Properties hierarchies with this Configuration.final ObjectDeprecated.This method will not be removed (as this is for technical reasons not possible), but should only be used within this class.final booleangetBooleanProperty(String key) Reads the given property from the configuration and interprets it as a boolean.final booleangetBooleanProperty(String key, boolean defaultValue) Reads the given property from the configuration and interprets it as a boolean.final doublegetDoubleProperty(String key) Reads the given property from the configuration and interprets it as a double.final doublegetDoubleProperty(String key, double defaultValue) Reads the given property from the configuration and interprets it as a double.final <T extends Enum<T>>
TgetEnumProperty(String key, Class<T> enumType, T defaultValue) Reads the given property from the configuration and interprets it as a double.final intgetIntProperty(String key) Reads the given property from the configuration and interprets it as an integer.final intgetIntProperty(String key, int defaultValue) Reads the given property from the configuration and interprets it as an integer.final longgetLongProperty(String key) Reads the given property from the configuration and interprets it as a long.final longgetLongProperty(String key, long defaultValue) Reads the given property from the configuration and interprets it as a long.final StringgetPathProperty(String key) Reads the given property from the configuration and interprets it as a path.final ConfigurationgetPropertiesStartingWith(String prefix) Flattens the Properties hierarchies and returns a Configuration object containing only keys starting with the prefix.final StringgetProperty(String key) Deprecated.This method will not be removed (as this is for technical reasons not possible), but should only be used within this class.final StringgetProperty(String key, String defaultValue) Deprecated.This method will not be removed (as this is for technical reasons not possible), but should only be used within this class.final String[]Interprets the property (defined by the given key) as an array of values and transforms it into a real array.final String[]getStringArrayProperty(String key, String split) Interprets the property (defined by the given key) as an array of values and transforms it into a real array.final StringgetStringProperty(String key) Reads the given property from the configuration and interprets it as a string.final StringgetStringProperty(String key, String defaultValue) Reads the given property from the configuration and interprets it as a string.final ObjectDeprecated.This method will not be removed (as this is for technical reasons not possible), but should only be used within this class.voidsetDefaultConfiguration(Configuration defaultConfiguration) You should know what you do if you use this method! Currently it is used for a (dirty) hack to add default configurations to Writers or AnalysisPlugins.voidsetProperty(String key, boolean value) Convenience method to set boolean-valued properties.voidsetProperty(String key, double value) Convenience method to set double-valued properties.voidsetProperty(String key, int value) Convenience method to set int-valued properties.voidsetProperty(String key, long value) Convenience method to set long-valued properties.voidsetStringArrayProperty(String key, String[] value) Sets a property to the given string array.static final StringtoProperty(Object[] values) Converts the Object[] to a String split by '|'.Methods inherited from class java.util.Properties
clear, clone, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, getOrDefault, hashCode, isEmpty, keys, keySet, list, list, load, load, loadFromXML, merge, propertyNames, putAll, putIfAbsent, rehash, remove, remove, replace, replace, replaceAll, save, setProperty, size, store, store, storeToXML, storeToXML, storeToXML, stringPropertyNames, toString, values
-
Constructor Details
-
Configuration
public Configuration()Creates a new (empty) configuration. -
Configuration
Creates a new instance of this class using the given parameters.- Parameters:
defaults- The property object which delivers the default values for the new configuration.
-
-
Method Details
-
getStringProperty
Reads the given property from the configuration and interprets it as a string.- Parameters:
key- The key of the property.- Returns:
- A string with the value of the given property or the empty string, if the property does not exist.
-
getStringProperty
Reads the given property from the configuration and interprets it as a string.- Parameters:
key- The key of the property.defaultValue- The default value for the givenkey- Returns:
- A string with the value of the given property or the given
defaultValue, if the property does not exist.
-
getBooleanProperty
Reads the given property from the configuration and interprets it as a boolean.- Parameters:
key- The key of the property.- Returns:
- A boolean with the value of the given property or null, if the property does not exist.
-
getBooleanProperty
Reads the given property from the configuration and interprets it as a boolean. If no value exists for this property, the given default value is returned.- Parameters:
key- The key of the property.defaultValue- The default value for this property- Returns:
- A boolean with the value of the given property or the default value
-
setProperty
Convenience method to set boolean-valued properties.- Parameters:
key- The key to be placed in this configurationvalue- The value to be stored for the given key
-
getIntProperty
Reads the given property from the configuration and interprets it as an integer.- Parameters:
key- The key of the property.- Returns:
- An integer with the value of the given property or zero, if the property does not exist.
-
getIntProperty
Reads the given property from the configuration and interprets it as an integer. If no value exists for this property, the given default value is returned.- Parameters:
key- The key of the property.defaultValue- The default value for this property- Returns:
- An integer with the value of the given property or the default value
-
setProperty
Convenience method to set int-valued properties.- Parameters:
key- The key to be placed in this configurationvalue- The value to be stored for the given key
-
getLongProperty
Reads the given property from the configuration and interprets it as a long.- Parameters:
key- The key of the property.- Returns:
- A long with the value of the given property or null, if the property does not exist.
-
getLongProperty
Reads the given property from the configuration and interprets it as a long. If no value exists for this property, the given default value is returned.- Parameters:
key- The key of the property.defaultValue- The default value for this property- Returns:
- A long with the value of the given property or the default value
-
setProperty
Convenience method to set long-valued properties.- Parameters:
key- The key to be placed in this configurationvalue- The value to be stored for the given key
-
getDoubleProperty
Reads the given property from the configuration and interprets it as a double.- Parameters:
key- The key of the property.- Returns:
- A long with the value of the given property or null, if the property does not exist.
-
getDoubleProperty
Reads the given property from the configuration and interprets it as a double. If no value exists for this property, the given default value is returned.- Parameters:
key- The key of the property.defaultValue- The default value for this property- Returns:
- A double with the value of the given property or the default value
-
getEnumProperty
Reads the given property from the configuration and interprets it as a double. If no value exists for this property, the given default value is returned.- Parameters:
key- The key of the property.defaultValue- The default value for this property- Returns:
- A double with the value of the given property or the default value
-
setProperty
Convenience method to set double-valued properties.- Parameters:
key- The key to be placed in this configurationvalue- The value to be stored for the given key
-
getPathProperty
Reads the given property from the configuration and interprets it as a path.- Parameters:
key- The key of the property.- Returns:
- A string with the value of the given property or null, if the property does not exist.
-
getStringArrayProperty
Interprets the property (defined by the given key) as an array of values and transforms it into a real array. Property values have to be split by '|'.- Parameters:
key- The key of the property.- Returns:
- A string array containing the single values of the properties.
-
setStringArrayProperty
Sets a property to the given string array. Note that the values must not contain the separator character '|'.- Parameters:
key- The key of the property to changevalue- The array to set
-
getStringArrayProperty
Interprets the property (defined by the given key) as an array of values and transforms it into a real array. Property values have to be split by 'split'.- Parameters:
split- a regular expressionkey- The key of the property.- Returns:
- A string array containing the single values of the properties.
- See Also:
-
toProperty
Converts the Object[] to a String split by '|'.- Parameters:
values- The values which will be transformed into a string.- Returns:
- A string representation of the given values array.
- See Also:
-
convertToPath
Based upon Guava 14.0.1 (Chris Nokleberg, Colin Decker). Guava is licensed under "The Apache Software License, Version 2.0". Simplifies a given file system path.- Parameters:
pathname- The path to be simplified.- Returns:
- A simplified version of the given path.
-
getPropertiesStartingWith
Flattens the Properties hierarchies and returns a Configuration object containing only keys starting with the prefix.- Parameters:
prefix- The prefix to be used during the flattening.- Returns:
- A new configuration object with a flattened properties hierarchy.
-
flatten
Flattens the Properties hierarchies and returns a new Configuration object.- Parameters:
defaultConfiguration- The configuration which will be used as a base.- Returns:
- A new configuration object with a flattened properties hierarchy.
-
flatten
Flattens the Properties hierarchies and returns a new Configuration object.- Returns:
- A new configuration object with a flattened properties hierarchy.
-
flattenInPlace
public final void flattenInPlace()Flattens the Properties hierarchies with this Configuration. Afterwards, all Properties will still be present and defaults will be null. -
setDefaultConfiguration
You should know what you do if you use this method! Currently it is used for a (dirty) hack to add default configurations to Writers or AnalysisPlugins.- Parameters:
defaultConfiguration- The default configuration for this configuration object.
-
put
Deprecated.This method will not be removed (as this is for technical reasons not possible), but should only be used within this class. Don't call this method directly.Puts a given key value pair into the container. This method should never be used directly! UseProperties.setProperty(String, String)instead! -
get
Deprecated.This method will not be removed (as this is for technical reasons not possible), but should only be used within this class. Don't call this method directly.Searches for a given key. This method should never be used directly! UsegetStringProperty(String)instead! -
getProperty
Deprecated.This method will not be removed (as this is for technical reasons not possible), but should only be used within this class. Don't call this method directly.Searches for a given property key. This method should never be used directly! UsegetStringProperty(String)instead!- Overrides:
getPropertyin classProperties- Parameters:
key- The key for the property in question.- Returns:
- The property for the specified key if available, null otherwise.
-
getProperty
Deprecated.This method will not be removed (as this is for technical reasons not possible), but should only be used within this class. Don't call this method directly.Searches for a given property key. This method should never be used directly!- Overrides:
getPropertyin classProperties- Parameters:
key- The key for the property in question.defaultValue- The default value to be returned.- Returns:
- The property for the specified key if available, the given default value otherwise.
-