Class ConfigurationUtils

java.lang.Object
rs.baselib.configuration.ConfigurationUtils

public class ConfigurationUtils
extends java.lang.Object
Useful methods for configuration issues.
Author:
ralph
  • Constructor Summary

    Constructors 
    Constructor Description
    ConfigurationUtils()  
  • Method Summary

    Modifier and Type Method Description
    static void configure​(IConfigurable configurable, org.apache.commons.configuration.Configuration config)
    Configure the object accordingly.
    static java.lang.String getParam​(org.apache.commons.configuration.SubnodeConfiguration config, java.lang.String name)
    Returns the config parameter with given value for attribute name.
    static <T> T load​(java.lang.Class<T> clazz, org.apache.commons.configuration.Configuration config, boolean configure)
    Loads an object from a configuration.
    static java.lang.Object load​(java.lang.String className, org.apache.commons.configuration.Configuration config, boolean configure)
    Loads an object from a configuration.
    static java.lang.Object load​(org.apache.commons.configuration.Configuration config, boolean configure)
    Loads an object from a configuration.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • load

      public static java.lang.Object load​(org.apache.commons.configuration.Configuration config, boolean configure)
      Loads an object from a configuration. The object is configured if it is an instance of IConfigurable. The class will be taken from attribute [@class].
      Parameters:
      config - the configuration to apply
      configure - whether the object shall be configured (if it is a IConfigurable).
      Returns:
      the object
    • load

      public static java.lang.Object load​(java.lang.String className, org.apache.commons.configuration.Configuration config, boolean configure)
      Loads an object from a configuration. The object is configured if it is an instance of IConfigurable.
      Parameters:
      className - the name of class to be instantiated
      config - the configuration to apply
      configure - whether the object shall be configured (if it is a IConfigurable).
      Returns:
      the object
    • load

      public static <T> T load​(java.lang.Class<T> clazz, org.apache.commons.configuration.Configuration config, boolean configure)
      Loads an object from a configuration. The object is configured if it is an instance of IConfigurable.
      Type Parameters:
      T - the type of the object to be instantiated
      Parameters:
      clazz - the class to be instantiated
      config - the configuration to apply
      configure - whether the object shall be configured (if it is a IConfigurable).
      Returns:
      the object
    • configure

      public static void configure​(IConfigurable configurable, org.apache.commons.configuration.Configuration config) throws org.apache.commons.configuration.ConfigurationException
      Configure the object accordingly.
      Parameters:
      configurable - the object to be configured
      config - the configuration to apply
      Throws:
      org.apache.commons.configuration.ConfigurationException - when a problem occurs
    • getParam

      public static java.lang.String getParam​(org.apache.commons.configuration.SubnodeConfiguration config, java.lang.String name)
      Returns the config parameter with given value for attribute name.
      Parameters:
      config - config
      name - name of param
      Returns:
      value of param