Class BasicConfiguration

java.lang.Object
com.scriptbasic.configuration.BasicConfiguration
All Implemented Interfaces:
Configuration

public class BasicConfiguration extends Object implements Configuration
Author:
Peter Verhas date July 23, 2012
  • Constructor Details

    • BasicConfiguration

      public BasicConfiguration()
  • Method Details

    • getConfigProperties

      public Properties getConfigProperties()
      Specified by:
      getConfigProperties in interface Configuration
      Returns:
      the properties object that stores the configuration
    • setConfigProperties

      public void setConfigProperties(Properties configProperties)
      Description copied from interface: Configuration
      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.

      Specified by:
      setConfigProperties in interface Configuration
      Parameters:
      configProperties - the configProperties to set
    • getConfigValue

      public Optional<String> getConfigValue(String key)
      Description copied from interface: Configuration
      Get the value of the key.
      Specified by:
      getConfigValue in interface Configuration
      Parameters:
      key - the configuration key for which the value is looked up.
      Returns:
      the string value of the configuration or null if the key is not configured.
    • getConfigValueList

      public List<String> getConfigValueList(String key)
      Description copied from interface: Configuration
      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 notation key'.n' where 'n' starts with zero and should increment by one continuously.
      Specified by:
      getConfigValueList in interface Configuration
      Parameters:
      key - parameter
      Returns:
      the list of configured strings
    • loadDefaultConfiguration

      public void loadDefaultConfiguration()
      The default configuration is stored in the file sb4j.properties or in the file defined by the system property named sb4j.configuration.
      Specified by:
      loadDefaultConfiguration in interface Configuration
      See Also:
    • loadConfiguration

      public void loadConfiguration(InputStream is)
      Description copied from interface: Configuration
      Load the configuration from an input stream.
      Specified by:
      loadConfiguration in interface Configuration
      Parameters:
      is - the input stream that is used to read the content of the properties file.
    • set

      public void set(String name, String value)
      Description copied from interface: Configuration
      Set the property value in the configuration. This method is available for host application to configure the interpreter programmatically.
      Specified by:
      set in interface Configuration
      Parameters:
      name - configuration property name
      value - configuration property value
    • set

      public void set(String command)
      Description copied from interface: Configuration
      Set the property value in the configuration. This method is available for host application to configure the interpreter programmatically.
      Specified by:
      set in interface Configuration
      Parameters:
      command - the name and the value separated by '='