|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectat.knowcenter.wag.egov.egiz.cfg.SettingsReader
public class SettingsReader
The SettingsReader reads the settings.txt
file. The
settings.txt
is a simple java property file that collects all
parameters used in different modules.
The SettingsReader provides methods to get the property keys and the
corresponding values. The keys could be defined as combinations of single
keys. Therefore it is possible to combine differen classes of keys. An
example could be:
#SettingNotFoundException error.code.100=Interner Fehler error.code.101=Die Konfigurationsdatei konnte nicht geladen werden #PDFDocumentException error.code.200=Das Dokument konnte nicht geladen werden #SignatureException error.code.300=Die Signatur ist ungültig #NormalizeException error.code.400=Die angegebene Version ist nicht bekannt normalizer.version=V01The internal representation of the example above is:
.error| |.code| | |.200=Das Dokument konnte nicht geladen werden | |.100=Interner Fehler | |.400=Die angegebene Version ist nicht bekannt | |.101=Die Konfigurationsdatei konnte nicht geladen werden | |.300=Die Signatur ist ungültig .normalizer| |.version=V01
Field Summary | |
---|---|
static String |
CERT_PATH
The path of the certificated directory. |
static String |
CONFIG_FILE_DEFAULT_NAME
The name of the default configuration file. |
static String |
CONFIG_PATH
The path of the configuration directory. |
static String |
HELP_TEXT_FILE_DEFAULT_NAME
The name of the help text configuration file. |
static String |
RESOURCES_PATH
The path of the resources repository. |
protected static String |
TEMP_DIR_NAME
The name of the directory, where temporary files are stored. |
Method Summary | |
---|---|
protected static File |
assembleTemporaryDirectoryFile()
Assembles the File of the temporary directory without checking if it really exists. |
static void |
clearTemporaryDirectory()
Deletes all files in the temporary directory, if it exists. |
static SettingsReader |
getInstance()
This method returns an synchronized instance of this class. |
int |
getIntSetting(String key,
int defaultValue)
If a property value is number (interger) this method extracts the value and convert it to an int. |
ArrayList |
getKeys(String key)
This method returns an array of sub keys (children references) of the key. |
PropertyTree |
getPTree()
This method returns the PropertyTree representation of the configuration file. |
String |
getSetting(String key)
This method returns a property value to the corresponding key. |
String |
getSetting(String key,
String defaultValue)
This method returns a property value to the corresponding key. |
String |
getSetting(String primaryKey,
String defaultKey,
String defaultValue)
This method returns a property value to the corresponding key. |
Vector |
getSettingKeys(String keyPrefix)
This method returns an array of keys in the same hierarchy of the keyPrefix. |
static File |
getTemporaryDirectory()
Returns the directory where temporary files should be stored. |
String |
getValueFromKey(String key)
This method returns a the first value from a key. |
static void |
initializeForCommandLine()
Initializes the paths of the SettingsReader for commanline usage. |
static void |
initializeForWeb(String base_dir)
Initializes the paths of the SettingsReader for web application usage. |
static String |
relocateFile(String file)
Relocates the relative file. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static String RESOURCES_PATH
This usually contains sub directories for the templates, the configuration files, etc.
public static String CONFIG_PATH
public static String CERT_PATH
protected static String TEMP_DIR_NAME
public static final String CONFIG_FILE_DEFAULT_NAME
public static final String HELP_TEXT_FILE_DEFAULT_NAME
Method Detail |
---|
public static SettingsReader getInstance() throws SettingsException
CONFIG_FILE_DEFAULT_NAME
: "settings.txt"
SettingsException
- if the default settings file could not be readpublic String getSetting(String key) throws SettingNotFoundException
getSetting
in interface Settings
key
- get the value for that key in the property file
SettingNotFoundException
- ErrorCode: 100public static String relocateFile(String file)
file
- The relative file.
public String getSetting(String key, String defaultValue)
getSetting
in interface Settings
key
- get the value for that key in the property filedefaultValue
- the default value if the key is not found
public String getSetting(String primaryKey, String defaultKey, String defaultValue)
getSetting
in interface Settings
primaryKey
- get the value for that key in the property filedefaultKey
- the default key that should be searched if the primaryKey is not
founddefaultValue
- the default value if the defaultKey is not found
public Vector getSettingKeys(String keyPrefix)
Object[]
collects all
sub keys without the keyPrefix.
keyPrefix
- to search for sub keys
public int getIntSetting(String key, int defaultValue)
key
- get the value for that key in the property filedefaultValue
- the default value if the key is not found
public ArrayList getKeys(String key)
PropertyTree.getKeys(String key)
.
key
- get all sub keys for that key in the property file
PropertyTree
public String getValueFromKey(String key)
PropertyTree.getFirstValue(String key)
.
key
- get the value for that key in the property file
PropertyTree
public PropertyTree getPTree()
PropertyTree
protected static File assembleTemporaryDirectoryFile()
public static File getTemporaryDirectory()
If the directory doesn't exist, it is created.
public static void clearTemporaryDirectory()
This should be used to clear temporary files when the application shuts down.
public static void initializeForWeb(String base_dir)
base_dir
- The base directory of this web application. E.g. TOMCAT_HOME/webapps/pdf-aspublic static void initializeForCommandLine()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |