Package com.scriptbasic.api
Interface Configuration
-
- All Known Implementing Classes:
BasicConfiguration
public interface ConfigurationManage 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
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description java.util.PropertiesgetConfigProperties()java.util.Optional<java.lang.String>getConfigValue(java.lang.String key)Get the value of the key.default java.util.Optional<java.lang.String>getConfigValue(java.lang.String key, int i)Get an indexed value.java.util.List<java.lang.String>getConfigValueList(java.lang.String key)Returns a list of strings that are the values assigned to the key in the configuration.default java.util.stream.Stream<java.lang.String>getConfigValueStream(java.lang.String key)Return the configuration values assigned to a keys 'key.0', 'key.1'...voidloadConfiguration(java.io.InputStream is)Load the configuration from an input stream.voidloadDefaultConfiguration()Load the default configuration.voidset(java.lang.String command)Set the property value in the configuration.voidset(java.lang.String name, java.lang.String value)Set the property value in the configuration.voidsetConfigProperties(java.util.Properties configProperties)Configuration of the script engine comes from standard Java properties.
-
-
-
Method Detail
-
setConfigProperties
void setConfigProperties(java.util.Properties configProperties)
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
java.util.Optional<java.lang.String> getConfigValue(java.lang.String key)
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
default java.util.Optional<java.lang.String> getConfigValue(java.lang.String key, int i)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
default java.util.stream.Stream<java.lang.String> getConfigValueStream(java.lang.String key)
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
java.util.List<java.lang.String> getConfigValueList(java.lang.String key)
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
void loadConfiguration(java.io.InputStream is)
Load the configuration from an input stream.- Parameters:
is- the input stream that is used to read the content of the properties file.
-
set
void set(java.lang.String name, java.lang.String value)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
void set(java.lang.String command)
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
java.util.Properties getConfigProperties()
- Returns:
- the properties object that stores the configuration
-
-