|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdk.netarkivet.common.utils.SettingsStructure
public class SettingsStructure
Provides access to general application settings. The settings are retrieved from an xml file.
Field Summary | |
---|---|
int |
edition
The edition of the Settings-object. |
Constructor Summary | |
---|---|
SettingsStructure(java.lang.String systemProperty,
java.lang.String defaultSettingsFilepath)
Create new instance, look for settings file in the following order: If the property given is set, data are loaded from this file Otherwise the file path given as default is used. |
Method Summary | |
---|---|
void |
conditionalReload()
Reload the settings if they have changed on disk. |
void |
create(java.lang.String key,
java.lang.String... values)
Create a new setting. |
java.lang.String |
get(java.lang.String key)
Gets a setting. |
java.lang.String[] |
getAll(java.lang.String key)
Gets a list of settings. |
int |
getEdition()
Return the current edition of this class. |
int |
getInt(java.lang.String key)
Gets a setting as an int. |
long |
getLong(java.lang.String key)
Gets a setting as a long. |
java.io.File |
getSettingsFile()
Return the file these settings are read from. |
void |
reload()
Reloads the settings. |
void |
set(java.lang.String key,
java.lang.String... values)
Sets the key to one or more values. |
void |
validateStrings(java.lang.Class classToCheck,
java.util.List<java.lang.String> excludedFields)
Validate that the strings defined in the given class are present in the settings xml file. |
void |
validateWithXSD(java.io.File xsdFile)
Validate that the settings xml file conforms to the XSD. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public int edition
Constructor Detail |
---|
public SettingsStructure(java.lang.String systemProperty, java.lang.String defaultSettingsFilepath)
systemProperty
- The system property specifying the file
pathdefaultSettingsFilepath
- The file path if the system property is
not set.
ArgumentNotValid
- on null or empty parameters
IOFailure
- if settings cannot be loadedMethod Detail |
---|
public java.io.File getSettingsFile()
public 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 no settings loaded.public int getInt(java.lang.String key)
key
- name of the setting to retrieve
ArgumentNotValid
- if key is null, the empty string or key is not
parseable to int
UnknownID
- if no setting loaded matches key
IOFailure
- if no settings loaded.public long getLong(java.lang.String key) throws UnknownID, IOFailure, ArgumentNotValid
key
- name of the setting to retrieve
ArgumentNotValid
- if key is null, the empty string or key is not
parseable to long
UnknownID
- if no setting loaded matches key
IOFailure
- if no settings loaded.public java.lang.String[] getAll(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 no settings loaded.public void create(java.lang.String key, java.lang.String... values) throws ArgumentNotValid
key
- the name of the settingvalues
- the values
ArgumentNotValid
- if key or value is null,
or if a corresponding key already exists.public void set(java.lang.String key, java.lang.String... values)
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 void conditionalReload()
IOFailure
- if settings cannot be loadedpublic void reload()
set(java.lang.String, java.lang.String...)
or create(java.lang.String, java.lang.String...)
IOFailure
- if settings cannot be loadedconditionalReload()
public void validateWithXSD(java.io.File xsdFile)
xsdFile
- Schema to check settings against.public int getEdition()
public void validateStrings(java.lang.Class classToCheck, java.util.List<java.lang.String> excludedFields)
classToCheck
- The class defining the constants to checkexcludedFields
- Fields not to check, even thoug they are constants
in that class.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |