Class BasicConfiguration

  • All Implemented Interfaces:
    Configuration

    public class BasicConfiguration
    extends java.lang.Object
    implements Configuration
    Author:
    Peter Verhas date July 23, 2012
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Properties getConfigProperties()  
      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.
      void loadConfiguration​(java.io.InputStream is)
      Load the configuration from an input stream.
      void loadDefaultConfiguration()
      The default configuration is stored in the file sb4j.properties or in the file defined by the system property named sb4j.configuration.
      void set​(java.lang.String command)
      Set the property value in the configuration.
      void set​(java.lang.String name, java.lang.String value)
      Set the property value in the configuration.
      void setConfigProperties​(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, wait
    • Constructor Detail

      • BasicConfiguration

        public BasicConfiguration()
    • Method Detail

      • getConfigProperties

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

        public void setConfigProperties​(java.util.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 java.util.Optional<java.lang.String> getConfigValue​(java.lang.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 java.util.List<java.lang.String> getConfigValueList​(java.lang.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
      • loadConfiguration

        public void loadConfiguration​(java.io.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​(java.lang.String name,
                        java.lang.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​(java.lang.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 '='