Package com.scriptbasic.api
Interface Configuration
- All Known Implementing Classes:
BasicConfiguration
public interface Configuration
Manage the configuration of the interpreter. Configuration parameters can be
requested from the implementing class. Configuration is read from input
stream, properties files.
When requesting individual configuration keys the implementation can look for the values in different sources. Typical implementation will look up values in the system properties and environment first before searching the configuration properties.
- Author:
- Peter Verhas date Jul 23, 2012
-
Method Summary
Modifier and TypeMethodDescriptiongetConfigValue(String key) Get the value of the key.getConfigValue(String key, int i) Get an indexed value.getConfigValueList(String key) Returns a list of strings that are the values assigned to the key in the configuration.Return the configuration values assigned to a keys 'key.0', 'key.1'...voidLoad the configuration from an input stream.voidLoad the default configuration.voidSet the property value in the configuration.voidSet the property value in the configuration.voidsetConfigProperties(Properties configProperties) Configuration of the script engine comes from standard Java properties.
-
Method Details
-
setConfigProperties
Configuration of the script engine comes from standard Java properties. Calling this method the caller can set the properties for the configuration. The properties passed as argument will be used as configuration solely and will NOT be merged with the keys and values of other property files.The fact that all other, possibly already loaded properties are not taken into account does not affect the fact that the configuration implementation itself may search other sources in addition to the properties to locate values for certain configuration keys.
- Parameters:
configProperties- the properties to be used as configuration properties.
-
getConfigValue
Get the value of the key.- Parameters:
key- the configuration key for which the value is looked up.- Returns:
- the string value of the configuration or
nullif the key is not configured.
-
getConfigValue
Get an indexed value. The indexed value is simple associated with thekey.iproperty.- Parameters:
key- the string keyi- the index value usually goes from zero- Returns:
- the configuration value
-
getConfigValueStream
Return the configuration values assigned to a keys 'key.0', 'key.1'... 'key.n' as a stream.- Parameters:
key- the key to which the values are assigned using the numberic key postfix- Returns:
- the stream of the values
-
getConfigValueList
Returns a list of strings that are the values assigned to the key in the configuration. List of strings in the configuration should be defined using the notationkey'.n' where 'n' starts with zero and should increment by one continuously.- Parameters:
key- parameter- Returns:
- the list of configured strings
-
loadDefaultConfiguration
void loadDefaultConfiguration()Load the default configuration. The implementation should define some default properties file to load the configuration from. -
loadConfiguration
Load the configuration from an input stream.- Parameters:
is- the input stream that is used to read the content of the properties file.
-
set
Set the property value in the configuration. This method is available for host application to configure the interpreter programmatically.- Parameters:
name- configuration property namevalue- configuration property value
-
set
Set the property value in the configuration. This method is available for host application to configure the interpreter programmatically.- Parameters:
command- the name and the value separated by '='
-
getConfigProperties
Properties getConfigProperties()- Returns:
- the properties object that stores the configuration
-