Class ConfigurationUtil


  • public class ConfigurationUtil
    extends Object
    A helper class to get configuration properties.
    • Method Detail

      • getProperty

        public static final String getProperty​(org.osgi.framework.BundleContext context,
                                               String name,
                                               String def)
        Returns the named property from the framework. If the property does not exist, the default value def is returned.
        Parameters:
        context - The BundleContext providing framework properties
        name - The name of the property to return
        def - The default value if the named property does not exist
        Returns:
        The value of the named property or def if the property does not exist
      • getProperty

        public static final int getProperty​(org.osgi.framework.BundleContext context,
                                            String name,
                                            int def)
        Returns the named property from the framework. If the property does not exist, the default value def is returned.
        Parameters:
        context - The BundleContext providing framework properties
        name - The name of the property to return
        def - The default value if the named property does not exist
        Returns:
        The value of the named property as a string or def if the property does not exist
      • getProperty

        public static final String getProperty​(Map config,
                                               String name,
                                               String def)
        Returns the named property from the configuration. If the property does not exist, the default value def is returned.
        Parameters:
        config - The properties from which to returned the named one
        name - The name of the property to return
        def - The default value if the named property does not exist
        Returns:
        The value of the named property as a string or def if the property does not exist
      • getProperty

        public static final int getProperty​(Map config,
                                            String name,
                                            int def)
        Returns the named property from the configuration. If the property does not exist, the default value def is returned.
        Parameters:
        config - The properties from which to returned the named one
        name - The name of the property to return
        def - The default value if the named property does not exist
        Returns:
        The value of the named property as a string or def if the property does not exist
      • getStringArrayProperty

        public static final String[] getStringArrayProperty​(Map config,
                                                            String name)
        Gets a property as String[]
        Parameters:
        config - The properties from which to returned the named one
        name - The name of the property to return
        Returns:
        the property value as string array - no matter if originally it was other kind of array, collection or comma-separated string. Returns null if the property is not set.
      • getProperty

        public static boolean getProperty​(Map<String,​Object> config,
                                          String name,
                                          boolean def)
        Returns the value of the named property from the configuration. If the property does not exist, the default value def is returned.
        Parameters:
        config - The properties from which to returned the named one
        name - The name of the property to return
        def - The default value if the named property does not exist
        Returns:
        The value of the named property as a boolean or def if the property does not exist