|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.Observable
com.digi.config.util.ConfigSettings
ConfigSettings reads and parses the content of a user defined configuration file and provides a set of query functions to retrieve these configuration information.
The default configuration file pathname is config.ini in the classpath.
Syntax : //
Syntax : [section_name]
Syntax : tag = value
Syntax : $([[section_name]:]tag)
Field Summary | |
static java.lang.String |
CATEGORY_CFG
Constant to use when dealing with general configuration settings |
static java.lang.String |
CATEGORY_SYSTEM
Constant to use when dealing with configuration settings in the System category. |
Method Summary | |
void |
addDefaultValueFinderListener(DefaultValueFinder def)
This method adds a defaultvalue finder listener. |
static boolean |
getBoolean(java.lang.String category,
java.lang.String key)
Gets boolean value of the specified key in the specified category. |
static boolean |
getBoolean(java.lang.String category,
java.lang.String key,
java.lang.String fallbackSection,
java.lang.String fallbackTag)
Gets boolean value of the specified key in the specified category. |
boolean |
getBooleanProfileProperty(java.lang.String section,
java.lang.String tag)
Returns the Profile Property as a boolean. |
boolean |
getBooleanProfileProperty(java.lang.String section,
java.lang.String tag,
java.lang.String fallbackSection,
java.lang.String fallbackTag)
Returns the Profile Property as a boolean. |
static java.awt.Color |
getColor(java.lang.String category,
java.lang.String key)
Gets color value of the specified key in the specified category. |
static java.awt.Color |
getColor(java.lang.String category,
java.lang.String key,
java.lang.String fallbackSection,
java.lang.String fallbackTag)
Gets color value of the specified key in the specified category. |
java.awt.Color |
getColorProfileProperty(java.lang.String section,
java.lang.String tag)
Returns the Profile property as a color. |
java.awt.Color |
getColorProfileProperty(java.lang.String section,
java.lang.String tag,
java.lang.String fallbackSection,
java.lang.String fallbackTag)
Returns the Profile property as a color. |
java.lang.String |
getConfigFileName()
Returns environment configuration file pathname. |
static java.awt.Font |
getFont(java.lang.String section,
java.lang.String tag)
Gets font value of the specified tag. |
static java.awt.Font |
getFont(java.lang.String section,
java.lang.String tag,
java.lang.String fallbackSection,
java.lang.String fallbackTag)
Gets font value of the specified tag. |
java.awt.Font |
getFontProfileProperty(java.lang.String section,
java.lang.String tag)
Returns the Profile property as a font. |
java.awt.Font |
getFontProfileProperty(java.lang.String section,
java.lang.String tag,
java.lang.String fallbackSection,
java.lang.String fallbackTag)
Returns the Profile property as a color. |
static ConfigSettings |
getInstance()
This method returns the only instance of the configsettings object |
static int |
getInteger(java.lang.String category,
java.lang.String key)
Gets integer value of the specified key in the specified category. |
static int |
getInteger(java.lang.String category,
java.lang.String key,
java.lang.String fallbackSection,
java.lang.String fallbackTag)
Gets integer value of the specified key in the specified category. |
int |
getIntegerProfileProperty(java.lang.String section,
java.lang.String tag)
Returns the Profile property as integer. |
int |
getIntegerProfileProperty(java.lang.String section,
java.lang.String tag,
java.lang.String fallbackSection,
java.lang.String fallbackTag)
Returns the Profile property as integer. |
java.lang.String |
getProfileProperty(java.lang.String section,
java.lang.String tag)
Returns value of specified ProfileProperty as a string. |
java.lang.String |
getProfileProperty(java.lang.String section,
java.lang.String tag,
java.lang.String defRetVal)
Returns the Profile Property as a String. |
java.lang.String |
getProfileProperty(java.lang.String section,
java.lang.String tag,
java.lang.String fallbackSection,
java.lang.String fallbackTag)
Returns value of specified ProfileProperty as a string. |
static java.lang.String |
getProperty(java.lang.String category,
java.lang.String key)
Gets value of the specified key within the specified category in the ConfigSettings. |
static java.lang.String |
getProperty(java.lang.String category,
java.lang.String key,
java.lang.String dftRetValue)
Gets value of the specified key within the specified category in the ConfigSettings. |
static java.lang.String |
getProperty(java.lang.String category,
java.lang.String key,
java.lang.String fallbackSection,
java.lang.String fallbackTag)
Gets value of the specified key within the specified category in the ConfigSettings. |
void |
list(java.io.PrintWriter out)
List properties, for debugging. |
void |
load_profile()
Loads configuration file contents into the ConfigSettings object. |
java.io.BufferedReader |
openProfile()
Locates the configuration profile and returns a BufferedReader to it. |
void |
save_profile()
This method saves the config settings to the file |
static void |
save()
This method saves the config settings to the ini file |
static void |
setBoolean(java.lang.String category,
java.lang.String key,
boolean value)
Sets the boolean value of the specified key in the specified category. |
void |
setBooleanProfileProperty(java.lang.String section,
java.lang.String tag,
boolean value)
Sets value of the specified tag. |
static void |
setColor(java.lang.String category,
java.lang.String key,
java.awt.Color value)
Sets the color value of the specified key in the specified category. |
void |
setColorProfileProperty(java.lang.String section,
java.lang.String tag,
java.awt.Color c)
Sets value of the specified tag. |
static void |
setInteger(java.lang.String category,
java.lang.String key,
int value)
Sets the integer value of the specified key in the specified category. |
void |
setIntegerProfileProperty(java.lang.String section,
java.lang.String tag,
int value)
Sets value of the specified tag. |
void |
setProfileProperty(java.lang.String section,
java.lang.String tag,
java.lang.String value)
Sets value of the specified tag. |
static void |
setProperty(java.lang.String category,
java.lang.String key,
java.lang.String value)
Sets the provided value under the specified key within the specified category in the ConfigSettings. |
Methods inherited from class java.util.Observable |
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String CATEGORY_SYSTEM
public static final java.lang.String CATEGORY_CFG
Method Detail |
public static ConfigSettings getInstance()
public void addDefaultValueFinderListener(DefaultValueFinder def)
def
- the default value finder classpublic java.lang.String getConfigFileName()
public java.lang.String getProfileProperty(java.lang.String section, java.lang.String tag)
section
- Section name in the profiletag
- Tag name
public java.lang.String getProfileProperty(java.lang.String section, java.lang.String tag, java.lang.String fallbackSection, java.lang.String fallbackTag)
section
- First section name in the profile to look fortag
- First tag name to look forfallbackSection
- Second section name in the profile to look forfallbackTag
- Second tag name to look for
public java.lang.String getProfileProperty(java.lang.String section, java.lang.String tag, java.lang.String defRetVal)
section
- Section name in the profiletag
- Tag namedefRetVal
- Default return String if none is found.
public boolean getBooleanProfileProperty(java.lang.String section, java.lang.String tag)
section
- Section name in the profiletag
- Tag name
public boolean getBooleanProfileProperty(java.lang.String section, java.lang.String tag, java.lang.String fallbackSection, java.lang.String fallbackTag)
section
- First section name in the profile to look fortag
- First tag name to look forfallbackSection
- Second section name in the profile to look forfallbackTag
- Second tag name to look for
public int getIntegerProfileProperty(java.lang.String section, java.lang.String tag)
section
- Section of the propertytag
- Key of the property
public int getIntegerProfileProperty(java.lang.String section, java.lang.String tag, java.lang.String fallbackSection, java.lang.String fallbackTag)
section
- First section name in the profile to look fortag
- First tag name to look forfallbackSection
- Second section name in the profile to look forfallbackTag
- Second tag name to look for
public java.awt.Color getColorProfileProperty(java.lang.String section, java.lang.String tag)
section
- First section name in the profile to look fortag
- First tag name to look for
public java.awt.Color getColorProfileProperty(java.lang.String section, java.lang.String tag, java.lang.String fallbackSection, java.lang.String fallbackTag)
section
- First section name in the profile to look fortag
- First tag name to look forfallbackSection
- Second section name in the profile to look forfallbackTag
- Second tag name to look for
public java.awt.Font getFontProfileProperty(java.lang.String section, java.lang.String tag)
section
- Section name in the profiletag
- Tag name
public java.awt.Font getFontProfileProperty(java.lang.String section, java.lang.String tag, java.lang.String fallbackSection, java.lang.String fallbackTag)
section
- First section name in the profile to look fortag
- First tag name to look forfallbackSection
- Second section name in the profile to look forfallbackTag
- Second tag name to look for
public void setProfileProperty(java.lang.String section, java.lang.String tag, java.lang.String value)
section
- Section name in the profiletag
- Tag namevalue
- Value to setpublic void setBooleanProfileProperty(java.lang.String section, java.lang.String tag, boolean value)
section
- Section name in the profiletag
- Tag namevalue
- Value to setpublic void setColorProfileProperty(java.lang.String section, java.lang.String tag, java.awt.Color c)
section
- Section name in the profiletag
- Tag namec
- Color to setpublic void setIntegerProfileProperty(java.lang.String section, java.lang.String tag, int value)
section
- Section name in the profiletag
- Tag namevalue
- Value to setpublic void save_profile() throws java.io.IOException
java.io.IOException
public void list(java.io.PrintWriter out)
out
- Output Streampublic java.io.BufferedReader openProfile()
public void load_profile() throws java.io.IOException
java.io.FileNotFoundException
- File not found
java.io.IOException
- File read or close errorpublic static boolean getBoolean(java.lang.String category, java.lang.String key)
The logic will first look for the value by searching the specified category in the ConfigSettings for the specified key. If either the category or the key cannot be found, the logic will perform the same search in the DefaultConfigSettings. If a value is still not found, a MissingResourceException is thrown.
category
- is the name of the setting category to searchkey
- is the name of the key to the value within the category
true
if and only if the value associated with
the category/key is true.
java.lang.IllegalArgumentException
- if the category or key values are either not
provided or are empty Strings.
java.util.MissingResourceException
- if a value for the specified category/key is
not found.public static boolean getBoolean(java.lang.String category, java.lang.String key, java.lang.String fallbackSection, java.lang.String fallbackTag)
The logic will first look for the value by searching the specified category in the ConfigSettings for the specified key. If either the category or the key cannot be found, the logic will perform the same search in the DefaultConfigSettings. If a value is still not found, a MissingResourceException is thrown.
category
- is the name of the setting category to searchkey
- is the name of the key to the value within the category
true
if and only if the value associated with
the category/key is true.
java.lang.IllegalArgumentException
- if the category or key values are either not
provided or are empty Strings.
java.util.MissingResourceException
- if a value for the specified category/key is
not found.public static void setBoolean(java.lang.String category, java.lang.String key, boolean value)
category
- is the name of the setting category into which the key/value pair is
inserted. If it does not exist, it will be created.key
- is the name of the key to the value within the categoryvalue
- is the boolean value to be inserted into the ConfigSettings
java.lang.IllegalArgumentException
- if the category or key values are either not
provided or are empty Strings.public static int getInteger(java.lang.String category, java.lang.String key)
The logic will first look for the value by searching the specified category in the ConfigSettings for the specified key. If either the category or the key cannot be found, the logic will perform the same search in the DefaultConfigSettings. If a value is still not found, false is returned.
category
- is the name of the setting category to searchkey
- is the name of the key to the value within the category
true
if and only if the value associated with
the category/key is true.
java.lang.IllegalArgumentException
- if the category or key values are either not
provided or are empty Strings.
java.util.MissingResourceException
- if a value for the specified category/key is
not found.
java.lang.NumberFormatException
- if the requested value is not actually an integer.public static int getInteger(java.lang.String category, java.lang.String key, java.lang.String fallbackSection, java.lang.String fallbackTag)
The logic will first look for the value by searching the specified category in the ConfigSettings for the specified key. If either the category or the key cannot be found, the logic will perform the same search in the DefaultConfigSettings. If a value is still not found, false is returned.
category
- is the name of the setting category to searchkey
- is the name of the key to the value within the category
true
if and only if the value associated with
the category/key is true.
java.lang.IllegalArgumentException
- if the category or key values are either not
provided or are empty Strings.
java.util.MissingResourceException
- if a value for the specified category/key is
not found.
java.lang.NumberFormatException
- if the requested value is not actually an integer.public static void setInteger(java.lang.String category, java.lang.String key, int value)
category
- is the name of the setting category into which the key/value pair is
inserted. If it does not exist, it will be created.key
- is the name of the key to the value within the categoryvalue
- is the integer value to be inserted into the ConfigSettings
java.lang.IllegalArgumentException
- if the category or key values are either not
provided or are empty Strings.public static java.awt.Font getFont(java.lang.String section, java.lang.String tag)
section
- Section name in the profiletag
- Tag name
public static java.awt.Font getFont(java.lang.String section, java.lang.String tag, java.lang.String fallbackSection, java.lang.String fallbackTag)
section
- Section name in the profiletag
- Tag name
public static java.awt.Color getColor(java.lang.String category, java.lang.String key)
The logic will first look for the value by searching the specified category in the ConfigSettings for the specified key. If either the category or the key cannot be found, the logic will perform the same search in the DefaultConfigSettings. If a value is still not found, a MissingResourceException is thrown.
category
- is the name of the setting category to searchkey
- is the name of the key to the value within the category
true
if and only if the value associated with
the category/key is true.
java.lang.IllegalArgumentException
- if the category or key values are either not
provided or are empty Strings.
java.util.MissingResourceException
- if a value for the specified category/key is
not found.public static java.awt.Color getColor(java.lang.String category, java.lang.String key, java.lang.String fallbackSection, java.lang.String fallbackTag)
The logic will first look for the value by searching the specified category in the ConfigSettings for the specified key. If either the category or the key cannot be found, the logic will perform the same search in the DefaultConfigSettings. If a value is still not found, a MissingResourceException is thrown.
category
- is the name of the setting category to searchkey
- is the name of the key to the value within the category
true
if and only if the value associated with
the category/key is true.
java.lang.IllegalArgumentException
- if the category or key values are either not
provided or are empty Strings.
java.util.MissingResourceException
- if a value for the specified category/key is
not found.public static void setColor(java.lang.String category, java.lang.String key, java.awt.Color value)
category
- is the name of the setting category into which the key/value pair is
inserted. If it does not exist, it will be created.key
- is the name of the key to the value within the categoryvalue
- is the color value to be inserted into the ConfigSettings
java.lang.IllegalArgumentException
- if the category or key values are either not
provided or are empty Strings.public static java.lang.String getProperty(java.lang.String category, java.lang.String key)
category
- is the name of the setting category to searchkey
- is the name of the key to the value within the category
java.lang.IllegalArgumentException
- if the category or key values are either not
provided or are empty Strings.
java.util.MissingResourceException
- if a value for the specified category/key is
not found.public static java.lang.String getProperty(java.lang.String category, java.lang.String key, java.lang.String fallbackSection, java.lang.String fallbackTag)
category
- is the name of the setting category to searchkey
- is the name of the key to the value within the category
java.lang.IllegalArgumentException
- if the category or key values are either not
provided or are empty Strings.
java.util.MissingResourceException
- if a value for the specified category/key is
not found.public static java.lang.String getProperty(java.lang.String category, java.lang.String key, java.lang.String dftRetValue)
category
- is the name of the setting category to searchkey
- is the name of the key to the value within the categorydftRetValue
- is the default return String if a value for the specified category/key
is not found in the configSettings.
java.lang.IllegalArgumentException
- if the category or key values are either not
provided or are empty Strings.
java.util.MissingResourceException
- if a value for the specified category/key is
not found.public static void setProperty(java.lang.String category, java.lang.String key, java.lang.String value)
System
or CFG
categories
will NOT be persisted between restarts of this application.
category
- is the name of the setting category to searchkey
- is the name of the key to the value within the categoryvalue
- is the String value to be placed in the ConfigSettings
java.lang.IllegalArgumentException
- if the category or key values are
empty Strings.
java.lang.NullPointerException
- if the category, key or value are null.public static void save() throws java.io.IOException
java.io.IOException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |