org.glite.authz.common.config
Class IniConfigUtil

java.lang.Object
  extended by org.glite.authz.common.config.IniConfigUtil

public class IniConfigUtil
extends java.lang.Object

Utilities for getting values for configuration files.


Field Summary
static java.lang.String STRING_LIST_SEPARATOR
          Separator for the strings list elements
 
Constructor Summary
IniConfigUtil()
           
 
Method Summary
static boolean getBoolean(org.ini4j.Profile.Section configSection, java.lang.String propName)
          Extracts a boolean value from a configuration property.
static boolean getBoolean(org.ini4j.Profile.Section configSection, java.lang.String propName, boolean defaultValue)
          Extracts a boolean value from a configuration property.
static int getInt(org.ini4j.Profile.Section configSection, java.lang.String propName, int minValue, int maxValue)
          Extracts an integer value from a configuration property.
static int getInt(org.ini4j.Profile.Section configSection, java.lang.String propName, int defaultValue, int minValue, int maxValue)
          Extracts an integer value from a configuration property.
static java.lang.String getString(org.ini4j.Profile.Section configSection, java.lang.String propName)
          Extracts a string value from a configuration property.
static java.lang.String getString(org.ini4j.Profile.Section configSection, java.lang.String propName, java.lang.String defaultValue)
          Extracts a string value from a configuration property.
static java.lang.String[] getStringsArray(org.ini4j.Profile.Section configSection, java.lang.String propName)
          Extracts a string list values from a configuration property, the values are separated with " " (space).
static java.lang.String[] getStringsArray(org.ini4j.Profile.Section configSection, java.lang.String propName, java.lang.String[] defaultValues)
          Extracts a string list values from a configuration property, the values are separated with " " (space).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STRING_LIST_SEPARATOR

public static final java.lang.String STRING_LIST_SEPARATOR
Separator for the strings list elements

See Also:
Constant Field Values
Constructor Detail

IniConfigUtil

public IniConfigUtil()
Method Detail

getBoolean

public static boolean getBoolean(org.ini4j.Profile.Section configSection,
                                 java.lang.String propName,
                                 boolean defaultValue)
Extracts a boolean value from a configuration property. The values 'true', 'yes', and '1' are treated as true, the values 'false', 'no', '0' are treated as false, use case insensitive matching. If the value is anything else, or not present, the default value is used.

Parameters:
configSection - configuration section from which to extract the attribute
propName - name of the configuration property
defaultValue - default value for the property
Returns:
the value

getBoolean

public static boolean getBoolean(org.ini4j.Profile.Section configSection,
                                 java.lang.String propName)
                          throws ConfigurationException
Extracts a boolean value from a configuration property. The values 'true', 'yes', and '1' are treated as true, the values 'false', 'no', '0' are treated as false, use case insensitive matching. If the value is anything else, or not present, the default value is used.

Parameters:
configSection - configuration section from which to extract the attribute
propName - name of the configuration property
Returns:
the value
Throws:
ConfigurationException - thrown if given configuration section does not contain a property with the given name

getString

public static java.lang.String getString(org.ini4j.Profile.Section configSection,
                                         java.lang.String propName,
                                         java.lang.String defaultValue)
Extracts a string value from a configuration property. If the property does not exist or has a null or empty value the default value is used.

Parameters:
configSection - configuration section from which to extract the attribute
propName - name of the configuration property
defaultValue - default value for the property
Returns:
the value of the property

getString

public static java.lang.String getString(org.ini4j.Profile.Section configSection,
                                         java.lang.String propName)
                                  throws ConfigurationException
Extracts a string value from a configuration property.

Parameters:
configSection - configuration section from which to extract the attribute
propName - name of the configuration property
Returns:
the value of the property
Throws:
ConfigurationException - thrown if the value does not exist or has a null/empty value

getInt

public static int getInt(org.ini4j.Profile.Section configSection,
                         java.lang.String propName,
                         int minValue,
                         int maxValue)
                  throws ConfigurationException
Extracts an integer value from a configuration property.

Parameters:
configSection - configuration section from which to extract the attribute
propName - name of the configuration property
minValue - minimum value of the property
maxValue - maximum value of the property
Returns:
the value for the property
Throws:
ConfigurationException - thrown if there is a problem getting the required integer value

getInt

public static int getInt(org.ini4j.Profile.Section configSection,
                         java.lang.String propName,
                         int defaultValue,
                         int minValue,
                         int maxValue)
Extracts an integer value from a configuration property. If the property does not exist or has an invalid value the default value is returned.

Parameters:
configSection - configuration section from which to extract the attribute
propName - name of the configuration property
defaultValue - default value of the property
minValue - minimum value of the property
maxValue - maximum value of the property
Returns:
the value for the property

getStringsArray

public static java.lang.String[] getStringsArray(org.ini4j.Profile.Section configSection,
                                                 java.lang.String propName)
                                          throws ConfigurationException
Extracts a string list values from a configuration property, the values are separated with " " (space).

Parameters:
configSection - configuration section from which to extract the strings list
propName - name of the configuration property
Returns:
the string values array of the property
Throws:
ConfigurationException - thrown if the configuration property does not exist.

getStringsArray

public static java.lang.String[] getStringsArray(org.ini4j.Profile.Section configSection,
                                                 java.lang.String propName,
                                                 java.lang.String[] defaultValues)
Extracts a string list values from a configuration property, the values are separated with " " (space).

Parameters:
configSection - configuration section from which to extract the strings list
propName - name of the configuration property
defaultValues - the default list values to return if the configuration property does not exist.
Returns:
the string values array of the property


Copyright © 2008-2012 EMI - European Middleware Initiative. All Rights Reserved.