Package com.scriptbasic.configuration
Class BasicConfiguration
java.lang.Object
com.scriptbasic.configuration.BasicConfiguration
- All Implemented Interfaces:
Configuration
public class BasicConfiguration extends java.lang.Object implements Configuration
- Author:
- Peter Verhas date July 23, 2012
-
Constructor Summary
Constructors Constructor Description BasicConfiguration() -
Method Summary
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.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.voidloadConfiguration(java.io.InputStream is)Load the configuration from an input stream.voidloadDefaultConfiguration()The default configuration is stored in the filesb4j.propertiesor in the file defined by the system property namedsb4j.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.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.scriptbasic.api.Configuration
getConfigValue, getConfigValueStream
-
Constructor Details
-
BasicConfiguration
public BasicConfiguration()
-
-
Method Details
-
getConfigProperties
public java.util.Properties getConfigProperties()- Specified by:
getConfigPropertiesin interfaceConfiguration- Returns:
- the properties object that stores the configuration
-
setConfigProperties
public void setConfigProperties(java.util.Properties configProperties)Description copied from interface:ConfigurationConfiguration 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.
- Specified by:
setConfigPropertiesin interfaceConfiguration- Parameters:
configProperties- the configProperties to set
-
getConfigValue
public java.util.Optional<java.lang.String> getConfigValue(java.lang.String key)Description copied from interface:ConfigurationGet the value of the key.- Specified by:
getConfigValuein interfaceConfiguration- 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.
-
getConfigValueList
public java.util.List<java.lang.String> getConfigValueList(java.lang.String key)Description copied from interface:ConfigurationReturns 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.- Specified by:
getConfigValueListin interfaceConfiguration- Parameters:
key- parameter- Returns:
- the list of configured strings
-
loadDefaultConfiguration
public void loadDefaultConfiguration()The default configuration is stored in the filesb4j.propertiesor in the file defined by the system property namedsb4j.configuration.- Specified by:
loadDefaultConfigurationin interfaceConfiguration- See Also:
Configuration.loadDefaultConfiguration()
-
loadConfiguration
public void loadConfiguration(java.io.InputStream is)Description copied from interface:ConfigurationLoad the configuration from an input stream.- Specified by:
loadConfigurationin interfaceConfiguration- Parameters:
is- the input stream that is used to read the content of the properties file.
-
set
public void set(java.lang.String name, java.lang.String value)Description copied from interface:ConfigurationSet the property value in the configuration. This method is available for host application to configure the interpreter programmatically.- Specified by:
setin interfaceConfiguration- Parameters:
name- configuration property namevalue- configuration property value
-
set
public void set(java.lang.String command)Description copied from interface:ConfigurationSet the property value in the configuration. This method is available for host application to configure the interpreter programmatically.- Specified by:
setin interfaceConfiguration- Parameters:
command- the name and the value separated by '='
-