|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.argouml.application.configuration.ConfigurationHandler
This class provides a user configuration based upon properties.
This provides an implementation-free interface to a configuration
repository. Any classes which need to implement a configuration
datastore must extend this class.
All of the required behavioral logic for the configuration is
contained within this class, as public final methods. Any
storage-related logic must be handled by the extending class.
These methods are abstract.
This class is intimately related to
Configuration
.
Field Summary | |
private boolean |
changeable
Internal flag indicating whether the configuration can be updated. |
private boolean |
changed
Internal flag indicating whether the configuration has been modified after it was loaded. |
private boolean |
loaded
Internal flag indicating whether the configuration has been loaded. |
private File |
loadedFromFile
Internal storage for the File the configuration was
loaded from, otherwise null. |
private URL |
loadedFromURL
Internal storage for the URL the configuration was
loaded from, otherwise null. |
private static Logger |
LOG
Logger. |
private static PropertyChangeSupport |
pcl
Internal worker for property change. |
Constructor Summary | |
ConfigurationHandler()
Anonymous constructor allows configuration changes. |
|
ConfigurationHandler(boolean c)
Constructor which optionally allows configuration changes. |
Method Summary | |
void |
addListener(ConfigurationKey key,
PropertyChangeListener p)
Adds a property change listener.Static for simplicity of use. |
void |
addListener(PropertyChangeListener p)
Adds a property change listener. |
boolean |
getBoolean(ConfigurationKey key,
boolean defaultValue)
Returns the boolean value of a configuration property. |
abstract String |
getDefaultPath()
Returns a default configuration path. |
double |
getDouble(ConfigurationKey key,
double defaultValue)
Returns the numeric value of a configuration property. |
int |
getInteger(ConfigurationKey key,
int defaultValue)
Returns the numeric value of a configuration property. |
String |
getString(ConfigurationKey key,
String defaultValue)
Returns the string value of a configuration property. |
abstract String |
getValue(String key,
String defaultValue)
Returns the string value of a configuration property. |
boolean |
hasKey(ConfigurationKey key)
Allows query for the existence of a configuration property. |
boolean |
isChangeable()
Indicates whether the configuration can be saved. |
boolean |
isChanged()
Indicates whether the configuration can be saved. |
boolean |
isLoaded()
Indicates whether the configuration has been loaded. |
boolean |
load(File file)
Load the configuration from a File . |
boolean |
load(URL url)
Load the configuration from a URL . |
boolean |
loadDefault()
Load the configuration from the default location. |
(package private) abstract boolean |
loadFile(File file)
Internal processing to load a File . |
private void |
loadIfNecessary()
Internal worker which is called prior to any getValue or setValue to ensure that the default load is done if it was not loaded previously. |
(package private) boolean |
loadUnspecified()
Internal processing to load from an unspecified source. |
(package private) abstract boolean |
loadURL(URL url)
Internal processing to load a URL . |
void |
removeListener(ConfigurationKey key,
PropertyChangeListener p)
Removes a property change listener. |
void |
removeListener(PropertyChangeListener p)
Removes a property change listener. |
boolean |
save(File file)
Save the configuration to a File . |
boolean |
save(URL url)
Save the configuration to a URL . |
boolean |
saveDefault()
Save the configuration to the location it was loaded from. |
boolean |
saveDefault(boolean force)
Save the configuration to the location it was loaded from. |
(package private) abstract boolean |
saveFile(File file)
Internal processing to save a File . |
(package private) boolean |
saveUnspecified()
Internal processing to save to an unspecified source. |
(package private) abstract boolean |
saveURL(URL url)
Internal processing to save a URL . |
void |
setBoolean(ConfigurationKey key,
boolean value)
Sets the boolean value of a configuration property. |
void |
setDouble(ConfigurationKey key,
double value)
Sets the numeric value of a configuration property. |
void |
setInteger(ConfigurationKey key,
int value)
Sets the numeric value of a configuration property. |
void |
setString(ConfigurationKey key,
String newValue)
Sets the string value of a configuration property. |
(package private) abstract void |
setValue(String key,
String value)
Sets the string value of a configuration property. |
private void |
workerSetValue(ConfigurationKey key,
String newValue)
Internal routine which calls the abstract setValue and handles all necessary functionality including firing property change notifications and tracing. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private File loadedFromFile
File
the configuration was
loaded from, otherwise null.
private URL loadedFromURL
URL
the configuration was
loaded from, otherwise null.
private boolean changeable
private boolean loaded
private boolean changed
private static PropertyChangeSupport pcl
private static final Logger LOG
Constructor Detail |
public ConfigurationHandler()
public ConfigurationHandler(boolean c)
c
- indicates if the configuration can be changedMethod Detail |
public abstract String getDefaultPath()
private void loadIfNecessary()
public final boolean loadDefault()
isLoaded()
public final boolean saveDefault()
public final boolean saveDefault(boolean force)
force
- the save even if it would not normally be done.
public final boolean isChangeable()
public final boolean isChanged()
public final boolean isLoaded()
public final boolean load(File file)
File
.
file
- to load from.
public final boolean load(URL url)
URL
.
url
- to load from.
public final boolean save(File file)
File
.
file
- to save to.
public final boolean save(URL url)
URL
.
url
- to save to.
public final String getString(ConfigurationKey key, String defaultValue)
key
- the configuration key to return.defaultValue
- the default value key to return
if the key is not found.
public final int getInteger(ConfigurationKey key, int defaultValue)
key
- the configuration key to return.defaultValue
- the default value key to return
if the key is not found.
public final double getDouble(ConfigurationKey key, double defaultValue)
key
- the configuration key to return.defaultValue
- the default value key to return
if the key is not found.
public final boolean getBoolean(ConfigurationKey key, boolean defaultValue)
key
- the configuration key to return.defaultValue
- the default value key to return
if the key is not found.
private void workerSetValue(ConfigurationKey key, String newValue)
key
- the configuration key to modify.newValue
- the new value of the key.public final void setString(ConfigurationKey key, String newValue)
key
- the configuration key to modify.newValue
- the value to set the key to.public final void setInteger(ConfigurationKey key, int value)
key
- the configuration key to modify.value
- the value to set the key to.public final void setDouble(ConfigurationKey key, double value)
key
- the configuration key to modify.value
- the value to set the key to.public final void setBoolean(ConfigurationKey key, boolean value)
key
- the configuration key to modify.value
- the value to set the key to.public final void addListener(PropertyChangeListener p)
p
- The class which will listen for property changes.public final void removeListener(PropertyChangeListener p)
p
- The class to remove as a property change listener.public final void addListener(ConfigurationKey key, PropertyChangeListener p)
key
- The specific key to listen for.p
- The class which will listen for property changes.public final void removeListener(ConfigurationKey key, PropertyChangeListener p)
key
- The specific key being listened for.p
- The class to remove as a property change listener.boolean loadUnspecified()
boolean saveUnspecified()
abstract boolean loadFile(File file)
File
.
file
- the file to load.
abstract boolean loadURL(URL url)
URL
.
url
- the url to load.
abstract boolean saveFile(File file)
File
.
file
- the file to save.
abstract boolean saveURL(URL url)
URL
.
url
- the url to save.
public boolean hasKey(ConfigurationKey key)
key
- the property being checked.
public abstract String getValue(String key, String defaultValue)
key
- the configuration key to return.defaultValue
- the configuration key to return.
abstract void setValue(String key, String value)
key
- the configuration key to modify.value
- the value to set the key to.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ArgoUML © 1996-2004 (20050222) | ArgoUML Homepage | ArgoUML Developers' page | ArgoUML Cookbook |