|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object dk.netarkivet.common.utils.Settings
public class Settings
Provides access to general application settings. The settings are retrieved
from xml files. XML files may be specified one of two places: 1) Default
settings in XML files, specified by class path. These are intended to be
packaged in the jar files, to provide a fallback for settings. 2) Overriding
settings in XML files in file systems. These are intended to override the
necessary values with minimal XML files. The location of these files are
either specified by the system property SETTINGS_FILE_PROPERTY
,
multiple files can be separated by File.pathSeparator
, that is ':' on
linux and ';' on windows; or if that property is not set, the default
location is DEFAULT_SETTINGS_FILEPATH
.
Field Summary | |
---|---|
static java.lang.String |
DEFAULT_SETTINGS_FILEPATH
The file path to look for settings in, if the system property SETTINGS_FILE_PROPERTY is not set. |
static java.lang.String |
SETTINGS_FILE_PROPERTY
This system property specifies alternative position(s) to look for settings files. |
Constructor Summary | |
---|---|
Settings()
|
Method Summary | |
---|---|
static void |
addDefaultClasspathSettings(java.lang.String defaultClasspathSettingsPath)
Add the settings file represented by this path to the list of default classpath settings. |
static void |
conditionalReload()
Reload the settings if they have changed on disk. |
static java.lang.String |
get(java.lang.String key)
Gets a setting. |
static java.lang.String[] |
getAll(java.lang.String key)
Gets a list of settings. |
static boolean |
getBoolean(java.lang.String key)
Gets a setting as a boolean. |
static double |
getDouble(java.lang.String key)
Gets a setting as a double. |
static java.io.File |
getFile(java.lang.String key)
Gets a setting as a file. |
static int |
getInt(java.lang.String key)
Gets a setting as an int. |
static long |
getLong(java.lang.String key)
Gets a setting as a long. |
static java.util.List<java.io.File> |
getSettingsFiles()
Return the file these settings are read from. |
static StringTree<java.lang.String> |
getTree(java.lang.String path)
Get a tree view of a part of the settings. |
static void |
reload()
Reloads the settings. |
static void |
set(java.lang.String key,
java.lang.String... values)
Sets the key to one or more values. |
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 SETTINGS_FILE_PROPERTY
File.pathSeparatorChar
public static final java.lang.String DEFAULT_SETTINGS_FILEPATH
SETTINGS_FILE_PROPERTY
is not set.
Constructor Detail |
---|
public Settings()
Method Detail |
---|
public static java.util.List<java.io.File> getSettingsFiles()
public static java.lang.String get(java.lang.String key) throws UnknownID, IOFailure, ArgumentNotValid
key
- name of the setting to retrieve
ArgumentNotValid
- if key is null or the empty string
UnknownID
- if no setting loaded matches key
IOFailure
- if IO Failurepublic static int getInt(java.lang.String key) throws UnknownID, ArgumentNotValid
key
- name of the setting to retrieve
ArgumentNotValid
- if key is null, the empty string or key is not
parseable as an integer
UnknownID
- if no setting loaded matches keypublic static long getLong(java.lang.String key) throws UnknownID, ArgumentNotValid
key
- name of the setting to retrieve
ArgumentNotValid
- if key is null, the empty string or key is not
parseable as a long
UnknownID
- if no setting loaded matches keypublic static double getDouble(java.lang.String key) throws UnknownID, ArgumentNotValid
key
- name of the setting to retrieve
ArgumentNotValid
- if key is null, the empty string or key is not
parseable as a double
UnknownID
- if no setting loaded matches keypublic static java.io.File getFile(java.lang.String key)
key
- name of the setting to retrieve
ArgumentNotValid
- if key is null, the empty string
UnknownID
- if no setting loaded matches kepublic static boolean getBoolean(java.lang.String key) throws UnknownID, ArgumentNotValid
key
- name of the setting to retrieve
ArgumentNotValid
- if key is null or the empty string
UnknownID
- if no setting loaded matches keypublic static java.lang.String[] getAll(java.lang.String key) throws UnknownID, ArgumentNotValid
key
- name of the setting to retrieve
ArgumentNotValid
- if key is null or the empty string
UnknownID
- if no setting loaded matches keypublic static void set(java.lang.String key, java.lang.String... values)
reload()
is executed.
TODO write these values to its own simpleXml structure, that are not
reset during reload.
key
- The settings key to add this under, legal keys are fields
in this class.values
- The (ordered) list of values to put under this key.
ArgumentNotValid
- if key or values are null
UnknownID
- if the key does not already existpublic static void conditionalReload()
IOFailure
- if settings cannot be loadedpublic static void reload()
set(java.lang.String, java.lang.String...)
The field lastModified
is updated to timestamp of the settings
file that has been changed most recently.
IOFailure
- if settings cannot be loadedconditionalReload()
public static void addDefaultClasspathSettings(java.lang.String defaultClasspathSettingsPath)
defaultClasspathSettingsPath
- the given default classpath setting.public static StringTree<java.lang.String> getTree(java.lang.String path)
path
- Dotted path to a unique element in the tree.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |