|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.eodisp.util.configuration.ConfigurationImpl
public class ConfigurationImpl
A basic implementation of the Configuration interface using a file as its backend.
| Nested Class Summary | |
|---|---|
class |
ConfigurationImpl.EntryImpl
A configuration entry that saves a configuration value as a string. |
| Nested classes/interfaces inherited from interface org.eodisp.util.configuration.Configuration |
|---|
Configuration.Entry |
| Field Summary | |
|---|---|
(package private) java.util.Map<java.lang.String,Configuration.Entry> |
entries
Holds configuration entries |
(package private) static org.apache.log4j.Logger |
logger
Log4J logger for this class |
(package private) boolean |
needsSave
|
| Constructor Summary | |
|---|---|
ConfigurationImpl(java.lang.String id,
java.lang.String name,
java.lang.String description,
java.io.File file)
Creates a new configuration with no entries. |
|
| Method Summary | ||
|---|---|---|
boolean |
containsEntry(java.lang.String key)
Returns whether this configuration contains an entry with the given key. |
|
Configuration.Entry |
createBooleanEntry(java.lang.String key,
boolean defaultValue,
java.lang.String entryDescription)
|
|
Configuration.Entry |
createEntry(java.lang.String key,
java.lang.String defaultValue,
java.lang.String entryDescription)
|
|
Configuration.Entry |
createEnumEntry(java.lang.String key,
java.lang.Enum defaultValue,
java.lang.String entryDescription)
|
|
|
createEnumSetEntry(java.lang.String key,
java.util.EnumSet<E> defaultEnumSet,
java.lang.Class elementType,
java.lang.String entryDescription)
|
|
Configuration.Entry |
createFileEntry(java.lang.String key,
java.io.File defaultValue,
java.lang.String entryDescription)
|
|
Configuration.Entry |
createFilelistEntry(java.lang.String key,
java.util.List<java.io.File> defaultFileList,
java.lang.String entryDescription)
|
|
Configuration.Entry |
createIntEntry(java.lang.String key,
int defaultValue,
java.lang.String entryDescription)
|
|
Configuration.Entry |
createLongEntry(java.lang.String key,
long defaultValue,
java.lang.String entryDescription)
|
|
Configuration.Entry[] |
entries()
Returns a safe array of all configuration entries of this configuration.. |
|
boolean |
equals(java.lang.Object obj)
|
|
java.lang.String |
getCode()
Helper method to generates the setter and getter methods of any configuration class. |
|
java.lang.String |
getDescription()
The description of this configuration. |
|
java.lang.String |
getDoc()
|
|
Configuration.Entry |
getEntry(java.lang.String key)
Returns the entry with the given key. |
|
java.io.File |
getFile()
Returns the location this configuration was last saved to or loaded from. |
|
java.lang.String |
getId()
The id is used as the registration key if the configuration is registered with and application. |
|
java.lang.String |
getName()
Returns the name of the configuration. |
|
java.lang.String |
getPropertyFileComment()
|
|
int |
hashCode()
|
|
void |
load()
Load the configuration from its stored location. |
|
boolean |
needsSave()
Indicates if this configuration needs to be saved. |
|
void |
overrideFromCommandLineParameters(com.martiansoftware.jsap.JSAPResult cliOptions)
Overrides configuration entries using the values given on the command line. |
|
void |
putEntry(Configuration.Entry entry)
Add a configuration entry. |
|
void |
save()
Saves the configuration to a persistent storage. |
|
java.lang.String |
toString()
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
static org.apache.log4j.Logger logger
java.util.Map<java.lang.String,Configuration.Entry> entries
boolean needsSave
| Constructor Detail |
|---|
public ConfigurationImpl(java.lang.String id,
java.lang.String name,
java.lang.String description,
java.io.File file)
name - the name of the new configuration. Must be unique among other
configurations. Make sure the name is human-readable as it is
possible that the name is displayed in a GUI.description - A description of this configuration. Can be used to generate
documentation or to proved online help in a GUI.file - The file this configuration is persisted or loaded from using
the load() and save() methods.| Method Detail |
|---|
public void putEntry(Configuration.Entry entry)
key - the key for the new entry.entry - the configuration entry.public Configuration.Entry getEntry(java.lang.String key)
getEntry in interface Configurationkey - the key of the entry
public boolean containsEntry(java.lang.String key)
null
and a non-existing entry.
containsEntry in interface Configurationkey - the key of the entry that shall be returned.
public void load()
throws java.io.IOException
load in interface Configurationjava.io.IOException - Indicates an error while loading.
public void save()
throws java.io.IOException
ConfigurationConfiguration.Entry.isSet() returns true.
save in interface Configurationjava.io.IOException - Indicates an error while saving.public Configuration.Entry[] entries()
entries in interface Configurationpublic java.io.File getFile()
null if
this configuration was never saved or loaded.public void overrideFromCommandLineParameters(com.martiansoftware.jsap.JSAPResult cliOptions)
cliOptions - the command line optionspublic java.lang.String getPropertyFileComment()
public java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String getDoc()
public java.lang.String getCode()
public java.lang.String getId()
Configuration
getId in interface Configurationpublic java.lang.String getName()
getName in interface Configurationpublic java.lang.String getDescription()
getDescription in interface Configuration
public Configuration.Entry createEntry(java.lang.String key,
java.lang.String defaultValue,
java.lang.String entryDescription)
public Configuration.Entry createIntEntry(java.lang.String key,
int defaultValue,
java.lang.String entryDescription)
public Configuration.Entry createBooleanEntry(java.lang.String key,
boolean defaultValue,
java.lang.String entryDescription)
public Configuration.Entry createLongEntry(java.lang.String key,
long defaultValue,
java.lang.String entryDescription)
public Configuration.Entry createFileEntry(java.lang.String key,
java.io.File defaultValue,
java.lang.String entryDescription)
public Configuration.Entry createEnumEntry(java.lang.String key,
java.lang.Enum defaultValue,
java.lang.String entryDescription)
public <E extends java.lang.Enum<E>> Configuration.Entry createEnumSetEntry(java.lang.String key,
java.util.EnumSet<E> defaultEnumSet,
java.lang.Class elementType,
java.lang.String entryDescription)
public Configuration.Entry createFilelistEntry(java.lang.String key,
java.util.List<java.io.File> defaultFileList,
java.lang.String entryDescription)
public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic boolean needsSave()
Configuration
needsSave in interface Configuration
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||