com.cafesoft.cams.util
Class ConfigSupport

java.lang.Object
  |
  +--com.cafesoft.cams.util.ConfigSupport

public class ConfigSupport
extends Object

A Helper class that performs common functions on Config Objects

Since:
7/18/02
See Also:
Config

Constructor Summary
ConfigSupport()
           
 
Method Summary
static boolean getBooleanParam(Config config, String paramName, boolean defaultValue)
          Get a boolean param from the Config object
static Properties getInitProperties(Config config)
          Get the initial parameters from the Config object and put them into a new Properties object This method is useful in situations where a Properties object is used to initialize an Object and the parent Object has a Config Object instead.
static Properties getProperties(Config config)
          Extracts the properties contained within the config.
static int getRequiredIntParam(Config config, String source, String paramName, int defaultValue, Logger logger)
          Get an Integer parameter from the Config object
static String getRequiredStringParam(Config config, String source, String paramName, String defaultValue, Logger logger)
          Get a required String param from the Config object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConfigSupport

public ConfigSupport()
Method Detail

getInitProperties

public static final Properties getInitProperties(Config config)
Get the initial parameters from the Config object and put them into a new Properties object

This method is useful in situations where a Properties object is used to initialize an Object and the parent Object has a Config Object instead.

Parameters:
config - the Config object that contains the initial parameters
Returns:
a new Properties object that contains all initial parameters

getRequiredIntParam

public static final int getRequiredIntParam(Config config,
                                            String source,
                                            String paramName,
                                            int defaultValue,
                                            Logger logger)
Get an Integer parameter from the Config object

Parameters:
config - the Config object that contains all initialization parameters
source - the source object that is attempting to get the parameter. This value is used to give a contextual warning message.
paramName - the name of the Parameter for which to retreive the integer value
defaultValue - the default value to use if a valid integer can not be evaluated.
logger - the logger to log warning messages to
Returns:
the requested int value if the parameter exists and is a valid integer. Otherwise, the method returns the default value

getRequiredStringParam

public static final String getRequiredStringParam(Config config,
                                                  String source,
                                                  String paramName,
                                                  String defaultValue,
                                                  Logger logger)
Get a required String param from the Config object

Parameters:
config - the Config object that contains all initialization properties.
source - the source object that is attempting to get the parameter. This value is used to give a contextual warning message.
paramName - the name of the Parameter for which to retreive the String value.
defaultValue - the default value to use if the parameter is not defined in the config object.
logger - the logger to log warning messages to
Returns:
the requested String value if the parameter exists else the default value.

getBooleanParam

public static final boolean getBooleanParam(Config config,
                                            String paramName,
                                            boolean defaultValue)
Get a boolean param from the Config object

Parameters:
config - the Config object to get the boolean value from
paramName - the parameter name of the boolean value
defaultValue - the default value if the parameter is not found in the Config object
Returns:
the boolean value assigned to the parameter name, or if the parameter name is not present in the Config Object then the default value is returned

getProperties

public static Properties getProperties(Config config)
Extracts the properties contained within the config.

Parameters:
config - contains configuration properties
Returns:
the configuration properties contained within the config


Generated on 10:40:31 AM September 10, 2003, © 1996-2003 Cafésoft LLC. All rights reserved.