|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.igfay.jfig.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.
Method Summary | |
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 java.util.Map |
getAllConfigFiles()
Returns the list of all config files that have been processed. |
java.lang.String[] |
getArrayValue(java.lang.String section,
java.lang.String key)
Convenience method for getting values as array. |
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. |
protected java.lang.String |
getConfigFileName()
|
protected java.util.List |
getConfigListeners()
Lazily initialize and return listeners |
protected JFigLocatorIF |
getConfigLocator()
|
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)
Convenience method for getting values as float |
static JFigIF |
getInstance()
Return the config singleton |
static JFigIF |
getInstance(int dummy)
Deprecated. - Use initialize |
static JFigIF |
getInstance(int dummy,
JFigLocatorIF locator)
Deprecated. - Use initialize |
static JFigIF |
getInstance(JFigLocatorIF jfigLocator)
Return the config singleton passing a JFigLocator |
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 |
protected JFigParser |
getParser()
Return the JFig parser |
java.util.Map |
getSection(java.lang.String section)
Return an entire section as a Map |
java.util.Properties |
getSectionAsProperties(java.lang.String section)
Return a section as a Properties object |
java.util.Properties |
getSectionAsProperties(java.lang.String section,
java.util.Properties properties)
Return a section populated in a 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)
Return the value for this section and key. |
java.util.List |
getValuesStartingWith(java.lang.String section,
java.lang.String key)
Return a list of all values starting with "key" in the section. |
static JFigIF |
initialize()
Initialize configuration |
static JFigIF |
initialize(JFigLocator locator)
Initialize configuration. |
protected boolean |
isXML()
Is the configuration file in XML format or ini format. |
static void |
main(java.lang.String[] args)
|
void |
print()
Print the values in the JFig dictionary. |
void |
printConfigurationDictionary()
Deprecated. |
protected void |
processConfig()
Call parser to process required config |
void |
reprocessConfiguration()
Reprocess the configuration creating a new config dictionary |
void |
reprocessConfiguration(JFigLocator locator)
Reprocess the configuration with the specified JFigLocator, creating a new config dictionary |
protected void |
setAllConfigFiles(java.util.HashMap map)
|
protected void |
setConfigDictionary(JFigDictionary configDictionary)
Sets the configDictionary. |
void |
setConfigurationValue(java.lang.String sectionName,
java.lang.String keyString,
java.lang.String valueString)
Set a configuration value. |
static void |
setInstance(JFigIF jfig)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static void main(java.lang.String[] args)
public static JFigIF getInstance()
public static void setInstance(JFigIF jfig)
public static JFigIF getInstance(int dummy) throws JFigException
JFigException
public static JFigIF getInstance(int dummy, JFigLocatorIF locator) throws JFigException
JFigException
public static JFigIF getInstance(JFigLocatorIF jfigLocator)
public void addConfigEventListener(JFigListener listener)
addConfigEventListener
in interface JFigIF
listener
- The feature to be added to the ConfigEventListener
attributeprotected java.util.List getConfigListeners()
protected void fireConfigUpdateEvent()
public void print()
print
in interface JFigIF
public void printConfigurationDictionary()
printConfigurationDictionary
in interface JFigIF
protected void processConfig() throws JFigException
JFigException
public void reprocessConfiguration() throws JFigException
reprocessConfiguration
in interface JFigIF
JFigException
public void reprocessConfiguration(JFigLocator locator) throws JFigException
reprocessConfiguration
in interface JFigIF
JFigException
public static JFigIF initialize() throws JFigException
JFigException
public static JFigIF initialize(JFigLocator locator) throws JFigException
JFigException
public JFigDictionary getConfigDictionary()
getConfigDictionary
in interface JFigIF
public java.lang.String[] getArrayValue(java.lang.String section, java.lang.String key) throws JFigException
getArrayValue
in interface JFigIF
JFigException
public boolean getBooleanValue(java.lang.String section, java.lang.String key, java.lang.String notFoundValue)
getBooleanValue
in interface JFigIF
public float getFloatValue(java.lang.String section, java.lang.String key, java.lang.String notFoundValue) throws JFigException
getFloatValue
in interface JFigIF
section
- Description of Parameterkey
- Description of ParameternotFoundValue
- Description of Parameter
JFigException
- Description of Exceptionpublic int getIntegerValue(java.lang.String section, java.lang.String key) throws JFigException
getIntegerValue
in interface JFigIF
JFigException
public int getIntegerValue(java.lang.String section, java.lang.String key, java.lang.String notFoundValue)
getIntegerValue
in interface JFigIF
protected JFigParser getParser()
protected boolean isXML()
public java.lang.String getValue(java.lang.String section, java.lang.String key, java.lang.String defaultValue)
getValue
in interface JFigIF
section
- Description of Parameterkey
- Description of ParameterdefaultValue
- Description of Parameter
public java.util.List getValuesStartingWith(java.lang.String section, java.lang.String key)
getValuesStartingWith
in interface JFigIF
section
- key
-
public java.util.Map getEntriesStartingWith(java.lang.String section, java.lang.String key)
getEntriesStartingWith
in interface JFigIF
section
- key
-
public java.util.Map getSection(java.lang.String section)
getSection
in interface JFigIF
section
-
public java.util.Properties getSectionAsProperties(java.lang.String section)
getSectionAsProperties
in interface JFigIF
section
-
public java.util.Properties getSectionAsProperties(java.lang.String section, java.util.Properties properties)
getSectionAsProperties
in interface JFigIF
section
-
public java.lang.String getValue(java.lang.String section, java.lang.String key) throws JFigException
getValue
in interface JFigIF
JFigException
public void setConfigurationValue(java.lang.String sectionName, java.lang.String keyString, java.lang.String valueString)
setConfigurationValue
in interface JFigIF
public java.lang.String[] getArrayValue(java.lang.String section, java.lang.String key, java.lang.String notFoundValue)
getArrayValue
in interface JFigIF
protected void setConfigDictionary(JFigDictionary configDictionary)
configDictionary
- protected java.util.Map getAllConfigFiles()
protected void setAllConfigFiles(java.util.HashMap map)
protected JFigLocatorIF getConfigLocator()
protected java.lang.String getConfigFileName()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |