org.igfay.jfig
Interface JFigIF

All Known Implementing Classes:
JFig

public interface JFigIF

Interface for JFig The JFig package provides very simple, flexible and powerful functionality for managing one or more configurations in a java environment.

It allows for a combination of a hierarchy of configuration files, substitution variables and property variables. Methods are provided to get values stored in a configuration dictionary with a variety of types (String, array, integer, float, boolean, etc) and default values.

Usage:
To get an instance of the JFig singleton, use: JFig. getInstance();

There are a number of helper methods to retrieve configuration values. The most common is:
String value = JFig. getInstance().getValue ("aSection","aKey","aDefaultValue");

See the javadocs for additional helper methods to retrieve values as different java types and with different exception handling.

Author:
bconrad

Method Summary
 void addConfigEventListener(JFigListener listener)
          Add ConfigEvent listeners to vector so they can be notified when there is a significant change in the configuration.
 java.lang.String[] getArrayValue(java.lang.String section, java.lang.String key)
          convenience method for getting values as array The value is tokenized depending on the first token found in the following order: comma, semicolon, colon, space
 java.lang.String[] getArrayValue(java.lang.String section, java.lang.String key, java.lang.String notFoundValue)
          convenience method for getting values as array with default value
 boolean getBooleanValue(java.lang.String section, java.lang.String key, java.lang.String notFoundValue)
          convenience method for getting values as boolean
 JFigDictionary getConfigDictionary()
          return the ConfigurationDictionary Made public so we can access this from a jsp and show the configuration via html.
 java.util.Map getEntriesStartingWith(java.lang.String section, java.lang.String key)
          Return a map of all values starting with "key" in the scetcion.
 float getFloatValue(java.lang.String section, java.lang.String key, java.lang.String notFoundValue)
          getFloatValue() convenience method for getting values as float
 int getIntegerValue(java.lang.String section, java.lang.String key)
          convenience method for getting values as int
 int getIntegerValue(java.lang.String section, java.lang.String key, java.lang.String notFoundValue)
          convenience method for getting values as int, with default value
 java.util.Map getSection(java.lang.String section)
          Return an entire section
 java.util.Properties getSectionAsProperties(java.lang.String section)
          Return a section converted to a Properties object (but not system properties)
 java.util.Properties getSectionAsProperties(java.lang.String section, java.util.Properties properties)
          Return a section added to the supplied Properties object
 java.lang.String getValue(java.lang.String section, java.lang.String key)
          Call configParser to get the value for a key in a given section.
 java.lang.String getValue(java.lang.String section, java.lang.String key, java.lang.String defaultValue)
          First look in given section.
 java.util.List getValuesStartingWith(java.lang.String section, java.lang.String key)
          Return a list of all values starting with "key" in the scetcion.
 void print()
          Print the values in the configuration dictionary.
 void printConfigurationDictionary()
          Deprecated.  
 void reprocessConfiguration()
          reprocess the configuration creating a new config dictionary
 void reprocessConfiguration(JFigLocator locator)
          reprocess the configuration creating a new config dictionary
 void setConfigurationValue(java.lang.String sectionName, java.lang.String keyString, java.lang.String valueString)
          Set a configuration value.
 

Method Detail

addConfigEventListener

public void addConfigEventListener(JFigListener listener)
Add ConfigEvent listeners to vector so they can be notified when there is a significant change in the configuration.

Parameters:
listener - The feature to be added to the ConfigEventListener attribute

print

public void print()
Print the values in the configuration dictionary.


printConfigurationDictionary

public void printConfigurationDictionary()
Deprecated.  

Print the values in the configuration dictionary.


reprocessConfiguration

public void reprocessConfiguration()
                            throws JFigException
reprocess the configuration creating a new config dictionary

Throws:
JFigException

reprocessConfiguration

public void reprocessConfiguration(JFigLocator locator)
                            throws JFigException
reprocess the configuration creating a new config dictionary

Throws:
JFigException

getConfigDictionary

public JFigDictionary getConfigDictionary()
return the ConfigurationDictionary Made public so we can access this from a jsp and show the configuration via html.


getArrayValue

public java.lang.String[] getArrayValue(java.lang.String section,
                                        java.lang.String key)
                                 throws JFigException
convenience method for getting values as array The value is tokenized depending on the first token found in the following order: comma, semicolon, colon, space

Throws:
JFigException

getBooleanValue

public boolean getBooleanValue(java.lang.String section,
                               java.lang.String key,
                               java.lang.String notFoundValue)
convenience method for getting values as boolean


getFloatValue

public float getFloatValue(java.lang.String section,
                           java.lang.String key,
                           java.lang.String notFoundValue)
                    throws JFigException
getFloatValue() convenience method for getting values as float

Parameters:
section - Description of Parameter
key - Description of Parameter
notFoundValue - Description of Parameter
Returns:
The FloatValue value
Throws:
JFigException - Description of Exception

getIntegerValue

public int getIntegerValue(java.lang.String section,
                           java.lang.String key)
                    throws JFigException
convenience method for getting values as int

Throws:
JFigException

getIntegerValue

public int getIntegerValue(java.lang.String section,
                           java.lang.String key,
                           java.lang.String notFoundValue)
convenience method for getting values as int, with default value


getValue

public java.lang.String getValue(java.lang.String section,
                                 java.lang.String key,
                                 java.lang.String defaultValue)
First look in given section. Try again for default section.

Parameters:
section - Description of Parameter
key - Description of Parameter
defaultValue - Description of Parameter
Returns:
The Value value

getValuesStartingWith

public java.util.List getValuesStartingWith(java.lang.String section,
                                            java.lang.String key)
Return a list of all values starting with "key" in the scetcion. If section xxx contains x.1, x.2, and x.3, getValuesStartingWith("xxx", "x.") returns a list containing x.1, x.2, and x.3.

Parameters:
section -
key -
Returns:
List

getEntriesStartingWith

public java.util.Map getEntriesStartingWith(java.lang.String section,
                                            java.lang.String key)
Return a map of all values starting with "key" in the scetcion. If section xxx contains x.1=a, x.2=b, and x.3=c, getValuesStartingWith("xxx", "x.") returns a map containing x.1,a x.2,b and x.3,c.

Parameters:
section -
key -
Returns:
List

getValue

public java.lang.String getValue(java.lang.String section,
                                 java.lang.String key)
                          throws JFigException
Call configParser to get the value for a key in a given section.

Throws:
JFigException

getSection

public java.util.Map getSection(java.lang.String section)
Return an entire section

Parameters:
section -
Returns:

getSectionAsProperties

public java.util.Properties getSectionAsProperties(java.lang.String section)
Return a section converted to a Properties object (but not system properties)

Parameters:
section -
Returns:

getSectionAsProperties

public java.util.Properties getSectionAsProperties(java.lang.String section,
                                                   java.util.Properties properties)
Return a section added to the supplied Properties object

Parameters:
section -
Returns:

setConfigurationValue

public void setConfigurationValue(java.lang.String sectionName,
                                  java.lang.String keyString,
                                  java.lang.String valueString)
Set a configuration value. Most values are set during initial parsing so this is rarely used.


getArrayValue

public java.lang.String[] getArrayValue(java.lang.String section,
                                        java.lang.String key,
                                        java.lang.String notFoundValue)
convenience method for getting values as array with default value