|
|||||||||||
| 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
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=V01
The 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 |
RESOURCES_PATH
The path of the resources repository. |
static String |
TMP_PATH
The path for temporary files. |
| 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 void |
createInstance()
Reloads the Settings file. |
static SettingsReader |
getInstance()
This method returns an synchronized instance of this class. |
InputStream |
getInternalResource(String relativePath)
Get resource as stream, relative to internal resource path {@value} |
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 |
initialize(String base_dir)
|
static void |
initialize(String configdir,
String tmpdir)
|
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. |
String |
readInternalResourceAsString(String relativePath)
Reads internal resource as string. |
static String |
relocateFile(String file)
Relocates the relative file. |
void |
setSetting(String key,
String value)
|
| 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 TMP_PATH
public static String CONFIG_PATH
public static String CERT_PATH
public static final String CONFIG_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 read
public static void createInstance()
throws SettingsException
Subsequent calls to getInstance will return the new settings.
SettingsException - f.e.
public String getSetting(String key)
throws SettingNotFoundException
key - get the value for that key in the property file
SettingNotFoundException - ErrorCode: 100
public void setSetting(String key,
String value)
public static String relocateFile(String file)
file - The relative file.
public String getSetting(String key,
String defaultValue)
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)
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
PropertyTreepublic String getValueFromKey(String key)
PropertyTree.getFirstValue(String key).
key - get the value for that key in the property file
PropertyTreepublic PropertyTree getPTree()
PropertyTreepublic String readInternalResourceAsString(String relativePath)
relativePath -
public InputStream getInternalResource(String relativePath)
relativePath -
protected static File assembleTemporaryDirectoryFile()
TempDirHelper.assembleTemporaryDirectoryFile()public static File getTemporaryDirectory()
If the directory doesn't exist, it is created.
TempDirHelper.getTemporaryDirectory()public static void clearTemporaryDirectory()
This should be used to clear temporary files when the application shuts down.
TempDirHelper.clearTemporaryDirectory()
public static void initialize(String configdir,
String tmpdir)
public static void initialize(String base_dir)
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 | ||||||||||