commons_config library
The Commons Configuration software library provides a generic configuration interface which enables a Dart/Flutter application to read configuration data from a variety of sources.
Classes
- BaseConfiguration
- Provides a basic Configuration implementation that is backed by a map.
- Configuration
- Abstract configuration class. Provides basic functionality but does not store any data. If you want to write your own Configuration class then you should implement only abstract methods from this class. Following is a list of features implemented here:
- ConfigurationInterpolator
-
A class that handles interpolation (variable substitution) for
configuration objects.
Each instance of
Configurationis associated with an object of this class. All interpolation tasks are delegated to this object.ConfigurationInterpolatorworks together with theStrSubstitutorclass from Commons Lang. By extendingStrLookupit is able to provide values for variables that appear in expressions. The basic idea of this class is that it can maintain a set of primitiveStrLookupobjects, each of which is identified by a special prefix. The variables to be processed have the form${prefix:name}.ConfigurationInterpolatorwill extract the prefix and determine, which primitive lookup object is registered for it. Then the name of the variable is passed to this object to obtain the actual value. It is also possible to define a default lookup object, which will be used for variables that do not have a prefix or that cannot be resolved by their associated lookup object. When a new instance of this class is created it is initialized with a default set of primitive lookup objects. Per default it contains the following standard lookup objects:EnvStrLookupmapped to theenvprefix.CfgEnvStrLookupmapped to thecfgprefix. After an instance has been created the current set of lookup objects can be modified using theregisterLookup()andderegisterLookup()methods. The default lookup object (that is invoked for variables without a prefix) can be set with thesetDefaultLookup()method. (If aConfigurationInterpolatorinstance is created by a configuration object, this lookup points to the configuration itself, so that variables are resolved using the configuration's properties. - ConfigurationLookup
-
Implements a
StrLookupfor theConfiguration. - EnvStrLookup
-
Lookup implementation that gets values from the platform environment.
This can be used to retrieve environment variables.
See
Platform.fromEnvironment - FileConfiguration
- A persistent configuration loaded and saved to a file.
- A strategy that never triggers a reloading.
- MapConfiguration
-
Provides a
Configurationimplementation backed by aMapobject. - PrefixedKeysIterator
-
A specialized iterator implementation used by
AbstractConfigurationto return an iteration over all keys starting with a specified prefix. - Properties
- Represents a set of key value pairs that can be saved to or read from file. Each key and value is a String. Supports synchronous and asynchronous file operations.
- PropertiesConfiguration
- PropertyConverter
- A utility class to convert the configuration properties into any type.
- ReloadingStrategy
- A strategy to decide if a configuration should be reloaded.
- SubsetConfiguration
- A subset of another configuration. The new Configuration object contains every key from the parent Configuration that starts with prefix. The prefix is removed from the keys in the subset.
- SubsetIterator
-
A specialized iterator to be returned by the
getKeys()methods. This implementation wraps an iterator from the parent configuration. The keys returned by this iterator are correspondingly transformed.
Exceptions / Errors
- ConfigurationException
- General configuration exception.
- ConversionException
- Exception thrown when a property is incompatible with the type requested.
- NoSuchElementException
- Exception thrown when a property is not found.