| java.lang.Object org.igfay.jfig.JFig
JFig | public class JFig implements JFigIF(Code) | | 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 | |
public void | addConfigEventListener(JFigListener listener) Add JFig listeners to list so they can be notified when there
is a significant change in the configuration. | protected void | fireConfigUpdateEvent() Notify registered listeners when configuration is updated. | protected Map | getAllConfigFiles() Returns the list of all config files that have been processed. | public String[] | getArrayValue(String section, String key) Convenience method for getting values as array. | public String[] | getArrayValue(String section, String key, String notFoundValue) Convenience method for getting values as array with default value. | public boolean | getBooleanValue(String section, String key, String notFoundValue) | public JFigDictionary | getConfigDictionary() return the ConfigurationDictionary
Made public so we can access this from a jsp and show the configuration
via html. | protected String | getConfigFileName() | protected List | getConfigListeners() | protected JFigLocatorIF | getConfigLocator() | public Map | getEntriesStartingWith(String section, String key) Return a map of all values starting with "key" in the scetcion. | public float | getFloatValue(String section, String key, String notFoundValue) | public static synchronized JFigIF | getInstance() | public static synchronized JFigIF | getInstance(int dummy) Return the config singleton. | public static synchronized JFigIF | getInstance(int dummy, JFigLocatorIF locator) Return the config singleton passing a JFigLocator. | public static synchronized JFigIF | getInstance(JFigLocatorIF jfigLocator) | public int | getIntegerValue(String section, String key) | public int | getIntegerValue(String section, String key, String notFoundValue) | protected JFigParser | getParser() | public Map | getSection(String section) | public Properties | getSectionAsProperties(String section) | public Properties | getSectionAsProperties(String section, Properties properties) Return a section populated in a supplied Properties object. | public String | getValue(String section, String key, String defaultValue) Return the value for this section and key. | public String | getValue(String section, String key) Call configParser to get the value for a key in a given section. | public List | getValuesStartingWith(String section, String key) Return a list of all values starting with "key" in the section. | public static JFigIF | initialize() | public static JFigIF | initialize(JFigLocator locator) Initialize configuration. | protected boolean | isXML() Is the configuration file in XML format or ini format. | public static void | main(String[] args) | public void | print() Print the values in the JFig dictionary. | public void | printConfigurationDictionary() Print the values in the JFig dictionary. | protected void | processConfig() | public void | reprocessConfiguration() | public void | reprocessConfiguration(JFigLocator locator) | protected void | setAllConfigFiles(HashMap map) | protected void | setConfigDictionary(JFigDictionary configDictionary) Sets the configDictionary. | public void | setConfigurationValue(String sectionName, String keyString, String valueString) Set a configuration value. | public static void | setInstance(JFigIF jfig) |
addConfigEventListener | public void addConfigEventListener(JFigListener listener)(Code) | | Add JFig listeners to list so they can be notified when there
is a significant change in the configuration.
Parameters: listener - The feature to be added to the ConfigEventListenerattribute |
fireConfigUpdateEvent | protected void fireConfigUpdateEvent()(Code) | | Notify registered listeners when configuration is updated.
|
getAllConfigFiles | protected Map getAllConfigFiles()(Code) | | Returns the list of all config files that have been processed.
Used to prevent processing the same file multiple times
esp in case of circular includes.
List |
getArrayValue | public String[] getArrayValue(String section, String key) throws JFigException(Code) | | 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
|
getArrayValue | public String[] getArrayValue(String section, String key, String notFoundValue)(Code) | | Convenience method for getting values as array with default value.
|
getBooleanValue | public boolean getBooleanValue(String section, String key, String notFoundValue)(Code) | | Convenience method for getting values as boolean
|
getConfigDictionary | public JFigDictionary getConfigDictionary()(Code) | | return the ConfigurationDictionary
Made public so we can access this from a jsp and show the configuration
via html.
|
getConfigListeners | protected List getConfigListeners()(Code) | | Lazily initialize and return listeners
|
getEntriesStartingWith | public Map getEntriesStartingWith(String section, String key)(Code) | | 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 - Parameters: key - Parameters: defaultValue - List |
getFloatValue | public float getFloatValue(String section, String key, String notFoundValue) throws JFigException(Code) | | Convenience method for getting values as float
Parameters: section - Description of Parameter Parameters: key - Description of Parameter Parameters: notFoundValue - Description of Parameter The FloatValue value exception: JFigException - Description of Exception |
getInstance | public static synchronized JFigIF getInstance()(Code) | | Return the config singleton
|
getInstance | public static synchronized JFigIF getInstance(int dummy) throws JFigException(Code) | | Return the config singleton. If the configuration file is not found, throw an exception.
|
getInstance | public static synchronized JFigIF getInstance(int dummy, JFigLocatorIF locator) throws JFigException(Code) | | Return the config singleton passing a JFigLocator. If the configuration file is not found, throw an exception.
|
getInstance | public static synchronized JFigIF getInstance(JFigLocatorIF jfigLocator)(Code) | | Return the config singleton passing a JFigLocator
|
getIntegerValue | public int getIntegerValue(String section, String key, String notFoundValue)(Code) | | Convenience method for getting values as int, with default value
|
getSection | public Map getSection(String section)(Code) | | Return an entire section as a Map
|
getSectionAsProperties | public Properties getSectionAsProperties(String section)(Code) | | Return a section as a Properties object
|
getSectionAsProperties | public Properties getSectionAsProperties(String section, Properties properties)(Code) | | Return a section populated in a supplied Properties object.
|
getValue | public String getValue(String section, String key, String defaultValue)(Code) | | Return the value for this section and key. If none found, return the
default value.
Parameters: section - Description of Parameter Parameters: key - Description of Parameter Parameters: defaultValue - Description of Parameter The Value value |
getValuesStartingWith | public List getValuesStartingWith(String section, String key)(Code) | | Return a list of all values starting with "key" in the section.
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 - Parameters: key - Parameters: defaultValue - List |
initialize | public static JFigIF initialize(JFigLocator locator) throws JFigException(Code) | | Initialize configuration.
It is recommended that JFig is explicitly initialized by this method.
The alternative is to let getInstance() lazily initialize.
The difference is that this will throw a JFigException if there is a problem
in the initialization process while getInstance() will not.
|
isXML | protected boolean isXML()(Code) | | Is the configuration file in XML format or ini format.
boolean |
print | public void print()(Code) | | Print the values in the JFig dictionary.
|
printConfigurationDictionary | public void printConfigurationDictionary()(Code) | | Print the values in the JFig dictionary.
|
processConfig | protected void processConfig() throws JFigException(Code) | | Call parser to process required config
|
reprocessConfiguration | public void reprocessConfiguration() throws JFigException(Code) | | Reprocess the configuration creating a new config dictionary
|
reprocessConfiguration | public void reprocessConfiguration(JFigLocator locator) throws JFigException(Code) | | Reprocess the configuration with the specified JFigLocator, creating a new config dictionary
|
setAllConfigFiles | protected void setAllConfigFiles(HashMap map)(Code) | | |
setConfigDictionary | protected void setConfigDictionary(JFigDictionary configDictionary)(Code) | | Sets the configDictionary.
Parameters: configDictionary - |
setConfigurationValue | public void setConfigurationValue(String sectionName, String keyString, String valueString)(Code) | | Set a configuration value.
Most values are set during initial parsing so this is rarely used.
|
setInstance | public static void setInstance(JFigIF jfig)(Code) | | |
|
|