|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.opensubsystems.core.util.Config
public class Config
Class responsible for reading and saving of configuration files.
| Field Summary | |
|---|---|
static java.lang.String |
CONFIG_FILE_NAME
Name of the property which can specify the configuration file to use. |
static java.lang.String |
DEFAULT_CONFIG_FILE_NAME
Default file name of configuration file. |
static java.lang.String |
DEPENDENT_CONFIG_FILE_NAME
Name of the property which can specify the configuration file that a given configuration file depends on. |
protected java.util.Properties |
m_prpProperties
Property file containing settings for this application This property is not transient since it represents values which needs to be stored on a disk. |
protected java.lang.String |
m_strConfigFile
Name of the configuration file actually used. |
protected java.lang.String |
m_strMutex
Helper mutex to synchronize some methods. |
protected java.lang.String |
m_strPropertyFileName
Name of the property file containing application properties. |
protected java.net.URL |
m_urlDefaultPropertyFile
If the property file name is not specified by s_strPropertyFileName, it can be specified by this URL as found on the system class path. |
static java.lang.String |
VALUE_NO_FALSE
This value can be used to signal no or false in the config file but in general we should test on TRUE and if it is not TRUE then it is FALSE. |
static java.lang.String |
VALUE_NO_FALSE_BOOLEAN
This value can be used to signal no or false in the config file but |
static java.lang.String |
VALUE_YES_TRUE
This value can be used to signal yes or true in the config file. |
static java.lang.String |
VALUE_YES_TRUE_BOOLEAN
This value can be used to signal yes or true in the config file. |
| Constructor Summary | |
|---|---|
Config()
Constructor to construct accessor to default property file. |
|
Config(java.util.Properties predefinedProperties)
Public constructor to use specified properties |
|
Config(java.lang.String strPropertyFileName)
Public constructor to access specified property file. |
|
| Method Summary | |
|---|---|
protected java.io.InputStream |
findConfigFile(java.lang.String strConfigFileName)
Find and configuration file. |
static boolean |
getBooleanProperty(java.util.Properties prpSettings,
java.lang.String strProperty,
boolean bDefaultValue,
java.lang.String strDisplayName)
Retrieve boolean property value and if the value is not specified throw an exception. |
static boolean |
getBooleanProperty(java.util.Properties prpSettings,
java.lang.String strProperty,
java.lang.String strDisplayName)
Retrieve boolean property value and if the value is not specified throw an exception. |
static java.lang.String |
getBooleanPropertyAsString(java.util.Properties prpSettings,
java.lang.String strProperty,
boolean bDefaultValue,
java.lang.String strDisplayName)
Retrieve boolean property value and if the value is not specified throw an exception. |
java.lang.String |
getFullPropertyFileName()
Get full location of the property file. |
static Config |
getInstance()
Get the default config instance. |
static int |
getIntPropertyInRange(java.util.Properties prpSettings,
java.lang.String strProperty,
int iDefaultValue,
java.lang.String strDisplayName,
int iMinValue,
int iMaxValue)
Retrieve integer property value of which should existin within a specified range. |
java.util.Properties |
getProperties()
Load all properties from default configuration file or return the ones passed into the constructor. |
java.util.Properties |
getPropertiesSafely()
Load all properties from default configuration file or return the ones passed into the constructor. |
java.lang.String |
getPropertyFileName()
Get the name of the propety file. |
static java.lang.String |
getStringProperty(Config configFile,
java.lang.String strProperty,
java.lang.String strDisplayName)
Retrieve string property value and if the value is not specified throw an exception. |
static java.lang.String |
getStringProperty(java.util.Properties prpSettings,
java.lang.String strProperty,
java.lang.String strDisplayName)
Retrieve string property value and if the value is not specified or it is empty throw an exception. |
static java.lang.String |
getStringProperty(java.util.Properties prpSettings,
java.lang.String strProperty,
java.lang.String strDisplayName,
boolean bAllowEmpty)
Retrieve string property value and if the value is not specified throw an exception. |
static java.lang.String |
getStringProperty(java.util.Properties prpSettings,
java.lang.String strProperty,
java.lang.String strDefaultValue,
java.lang.String strDisplayName)
Retrieve string property value and if the property is not specified or it is specified as an empty value, use the default value instead. |
static java.lang.String |
getStringProperty(java.util.Properties prpSettings,
java.lang.String strProperty,
java.lang.String strDefaultValue,
java.lang.String strDisplayName,
boolean bAllowEmpty)
Retrieve string property value. |
static boolean |
isTrue(java.lang.String strValue)
Test if specified value is true according to config file rules. |
void |
save()
Save the configuration to a file. |
static void |
save(java.io.File fileConfig,
java.util.Properties prpSettings)
Save the configuration to a file. |
static void |
setInstance(Config defaultInstance)
Set default instance. |
void |
setPropertyFileName(java.lang.String strPropertyFileName)
Set the name of the propety file. |
| 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 CONFIG_FILE_NAME
public static final java.lang.String DEPENDENT_CONFIG_FILE_NAME
public static final java.lang.String VALUE_YES_TRUE
public static final java.lang.String VALUE_YES_TRUE_BOOLEAN
public static final java.lang.String VALUE_NO_FALSE
public static final java.lang.String VALUE_NO_FALSE_BOOLEAN
public static final java.lang.String DEFAULT_CONFIG_FILE_NAME
protected java.lang.String m_strMutex
protected java.util.Properties m_prpProperties
protected java.lang.String m_strPropertyFileName
protected java.net.URL m_urlDefaultPropertyFile
protected java.lang.String m_strConfigFile
| Constructor Detail |
|---|
public Config()
public Config(java.lang.String strPropertyFileName)
strPropertyFileName - - name of the property file to use.public Config(java.util.Properties predefinedProperties)
predefinedProperties - - predefined properties which should be used| Method Detail |
|---|
public static Config getInstance()
public static void setInstance(Config defaultInstance)
defaultInstance - - new default Config instancegetInstance()
public java.util.Properties getProperties()
throws java.io.IOException
java.io.IOException - - for example the file was not found
protected java.io.InputStream findConfigFile(java.lang.String strConfigFileName)
throws java.io.IOException,
java.io.FileNotFoundException
strConfigFileName - - name of the configuration file
java.io.IOException - - an error has occured opening configuration file
java.io.FileNotFoundException - - file cannot be foundpublic java.util.Properties getPropertiesSafely()
public void save()
throws java.io.IOException,
java.io.FileNotFoundException
java.io.IOException - - there was a problem saving configuration file.
java.io.FileNotFoundException - - file cannot be found
public static void save(java.io.File fileConfig,
java.util.Properties prpSettings)
throws java.io.IOException,
java.io.FileNotFoundException
fileConfig - - file to save the properties toprpSettings - - configuration settings to store to the file
java.io.IOException - - there was a problem saving configuration file.
java.io.FileNotFoundException - - file cannot be foundpublic java.lang.String getPropertyFileName()
public java.lang.String getFullPropertyFileName()
public void setPropertyFileName(java.lang.String strPropertyFileName)
strPropertyFileName - - the strPropertyFileName to setpublic static boolean isTrue(java.lang.String strValue)
strValue - - value to test
public static int getIntPropertyInRange(java.util.Properties prpSettings,
java.lang.String strProperty,
int iDefaultValue,
java.lang.String strDisplayName,
int iMinValue,
int iMaxValue)
prpSettings - - properties to retrieve the setting fromstrProperty - - name of the property to retrieveiDefaultValue - - default value to use if a valid value is not specifiedstrDisplayName - - user friendly name of the propertyiMinValue - - inclusive minimal value of the rangeiMaxValue - - inclusive maximal value of the range
public static java.lang.String getStringProperty(Config configFile,
java.lang.String strProperty,
java.lang.String strDisplayName)
throws OSSConfigException
configFile - - configuration file to retrieve the setting fromstrProperty - - name of the property to retrievestrDisplayName - - user friendly name of the property
OSSConfigException - - value for the requested property is not specified
public static java.lang.String getStringProperty(java.util.Properties prpSettings,
java.lang.String strProperty,
java.lang.String strDisplayName)
throws OSSConfigException
prpSettings - - properties to retrieve the setting fromstrProperty - - name of the property to retrievestrDisplayName - - user friendly name of the property
OSSConfigException - - value for the requested property is not specified
public static java.lang.String getStringProperty(java.util.Properties prpSettings,
java.lang.String strProperty,
java.lang.String strDisplayName,
boolean bAllowEmpty)
throws OSSConfigException
prpSettings - - properties to retrieve the setting fromstrProperty - - name of the property to retrievestrDisplayName - - user friendly name of the propertybAllowEmpty - - if true then empty value is allowed
OSSConfigException - - value for the requested property is not specified
public static java.lang.String getStringProperty(java.util.Properties prpSettings,
java.lang.String strProperty,
java.lang.String strDefaultValue,
java.lang.String strDisplayName)
prpSettings - - properties to retrieve the setting fromstrProperty - - name of the property to retrievestrDefaultValue - - default value to use if a valid value is not specifiedstrDisplayName - - user friendly name of the property
public static java.lang.String getStringProperty(java.util.Properties prpSettings,
java.lang.String strProperty,
java.lang.String strDefaultValue,
java.lang.String strDisplayName,
boolean bAllowEmpty)
prpSettings - - properties to retrieve the setting fromstrProperty - - name of the property to retrievestrDefaultValue - - default value to use if a valid value is not specifiedstrDisplayName - - user friendly name of the propertybAllowEmpty - - if true then empty value is allowed
public static boolean getBooleanProperty(java.util.Properties prpSettings,
java.lang.String strProperty,
java.lang.String strDisplayName)
throws OSSConfigException
prpSettings - - properties to retrieve the setting fromstrProperty - - name of the property to retrievestrDisplayName - - user friendly name of the property
OSSConfigException - - value for the requested property is not specified
public static boolean getBooleanProperty(java.util.Properties prpSettings,
java.lang.String strProperty,
boolean bDefaultValue,
java.lang.String strDisplayName)
prpSettings - - properties to retrieve the setting fromstrProperty - - name of the property to retrievebDefaultValue - - default value to use if a valid value is not specifiedstrDisplayName - - user friendly name of the property
public static java.lang.String getBooleanPropertyAsString(java.util.Properties prpSettings,
java.lang.String strProperty,
boolean bDefaultValue,
java.lang.String strDisplayName)
prpSettings - - properties to retrieve the setting fromstrProperty - - name of the property to retrievebDefaultValue - - default value to use if a valid value is not specifiedstrDisplayName - - user friendly name of the property
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||