org.argouml.application.api
Class Configuration

java.lang.Object
  |
  +--org.argouml.application.api.Configuration

public class Configuration
extends java.lang.Object

This class provides the core user configuration implementation logic. All fancy handling and registry access occurs behind the scenes.

Since:
0.9.4

Field Summary
static Category cat
          Define a static log4j category variable for ArgoUML configuration.
static java.lang.String FILE_LOADED
          Property to indicate configuration load from file
static java.lang.String FILE_SAVED
          Property to indicate configuration save to file
static java.lang.String URL_LOADED
          Property to indicate configuration load from url
static java.lang.String URL_SAVED
          Property to indicate configuration save to url
 
Method Summary
static void addListener(ConfigurationKey key, java.beans.PropertyChangeListener pcl)
          Adds a property change listener.Static for simplicity of use.
static void addListener(java.beans.PropertyChangeListener pcl)
          Adds a property change listener.
static boolean getBoolean(ConfigurationKey key)
          Returns the boolean value of a configuration property.
static boolean getBoolean(ConfigurationKey key, boolean defaultValue)
          Returns the boolean value of a configuration property.
static ConfigurationHandler getConfigurationHandler()
          Returns the instance of the configuration singleton.
static double getDouble(ConfigurationKey key)
          Returns the numeric value of a configuration property.
static double getDouble(ConfigurationKey key, double defaultValue)
          Returns the numeric value of a configuration property.
static ConfigurationFactory getFactory()
          Returns the configuration factory instance.
static int getInteger(ConfigurationKey key)
          Returns the numeric value of a configuration property.
static int getInteger(ConfigurationKey key, int defaultValue)
          Returns the numeric value of a configuration property.
static java.lang.String getString(ConfigurationKey key)
          Returns the string value of a configuration property.
static java.lang.String getString(ConfigurationKey key, java.lang.String defaultValue)
          Returns the string value of a configuration property.
static boolean load()
          Load the configuration from the default location.
static boolean load(java.io.File file)
          Load the configuration from a specified file
static boolean load(java.net.URL url)
          Load the configuration from a specified url
static ConfigurationKey makeKey(ConfigurationKey ck, java.lang.String k1)
          Create a sub-component of an existing configuration key.
static ConfigurationKey makeKey(java.lang.String k1)
          Create a single component configuration key.
static ConfigurationKey makeKey(java.lang.String k1, java.lang.String k2)
          Create a two-component configuration key.
static ConfigurationKey makeKey(java.lang.String k1, java.lang.String k2, java.lang.String k3)
          Create a three-component configuration key.
static ConfigurationKey makeKey(java.lang.String k1, java.lang.String k2, java.lang.String k3, java.lang.String k4)
          Create a four-component configuration key.
static ConfigurationKey makeKey(java.lang.String k1, java.lang.String k2, java.lang.String k3, java.lang.String k4, java.lang.String k5)
          Create a five-component configuration key.
static void removeListener(ConfigurationKey key, java.beans.PropertyChangeListener pcl)
          Removes a property change listener.
static void removeListener(java.beans.PropertyChangeListener pcl)
          Removes a property change listener.
static boolean save()
          Save the configuration to the default location.
static boolean save(boolean force)
          Save the configuration to the default location.
static void setBoolean(ConfigurationKey key, boolean newValue)
          Sets the boolean value of a configuration property.
static void setDouble(ConfigurationKey key, double newValue)
          Sets the numeric value of a configuration property.
static void setInteger(ConfigurationKey key, int newValue)
          Sets the numeric value of a configuration property.
static void setString(ConfigurationKey key, java.lang.String newValue)
          Sets the string value of a configuration property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cat

public static final Category cat
Define a static log4j category variable for ArgoUML configuration.


FILE_LOADED

public static final java.lang.String FILE_LOADED
Property to indicate configuration load from file

See Also:
Constant Field Values

URL_LOADED

public static final java.lang.String URL_LOADED
Property to indicate configuration load from url

See Also:
Constant Field Values

FILE_SAVED

public static final java.lang.String FILE_SAVED
Property to indicate configuration save to file

See Also:
Constant Field Values

URL_SAVED

public static final java.lang.String URL_SAVED
Property to indicate configuration save to url

See Also:
Constant Field Values
Method Detail

getConfigurationHandler

public static ConfigurationHandler getConfigurationHandler()
Returns the instance of the configuration singleton.

Returns:
the configuration handler

getFactory

public static final ConfigurationFactory getFactory()
Returns the configuration factory instance. This is equivalent to ConfigurationFactory.getInstance() but using Configuration.getFactory() is shorter to type and allows us not to have to deal with ConfigurationFactory at all if we don't need to modify or configure it.

Returns:
the configuration factory

load

public static final boolean load()
Load the configuration from the default location. The configuration will be automatically loaded from the default location the first time a value is queried or modified, if it had not been previously loaded. Only the first load request will be honored, so if the configuration is to be loaded from a non-default location, load(name) must be used prior to any other call. The configuration can be loaded only one time. Implementations must ignore load requests once a load is already successful, and must return false for each of those ignored requests.

Returns:
true if the load is successful, otherwise false

load

public static final boolean load(java.io.File file)
Load the configuration from a specified file

Parameters:
file - the File to load
Returns:
true if the load is successful, otherwise false

load

public static final boolean load(java.net.URL url)
Load the configuration from a specified url

Parameters:
url - the URL to load
Returns:
true if the load is successful, otherwise false

save

public static final boolean save()
Save the configuration to the default location. Implementations do not have to handle this method. If the method is not allowed or it fails, the implementation must return false.

Returns:
true if the save is successful, otherwise false

save

public static final boolean save(boolean force)
Save the configuration to the default location. Implementations do not have to handle this method. If the method is not allowed or it fails, the implementation must return false.

Returns:
true if the save is successful, otherwise false

getString

public static java.lang.String getString(ConfigurationKey key)
Returns the string value of a configuration property.

Parameters:
key - the key to retrieve the value of
Returns:
the string value of the parameter if it exists, otherwise a zero length string

getString

public static final java.lang.String getString(ConfigurationKey key,
                                               java.lang.String defaultValue)
Returns the string value of a configuration property.

Parameters:
key - the key to retrieve the value of
defaultValue - the value to return if the key does not exist
Returns:
the string value of the parameter if it exists, otherwise the default value

getInteger

public static final int getInteger(ConfigurationKey key)
Returns the numeric value of a configuration property.

Parameters:
key - the key to retrieve the value of
Returns:
the string value of the parameter if it exists, otherwise zero

getDouble

public static final double getDouble(ConfigurationKey key,
                                     double defaultValue)
Returns the numeric value of a configuration property.

Parameters:
key - the key to retrieve the value of
Returns:
the string value of the parameter if it exists, otherwise the default value

getDouble

public static final double getDouble(ConfigurationKey key)
Returns the numeric value of a configuration property.

Parameters:
key - the key to retrieve the value of
Returns:
the string value of the parameter if it exists, otherwise zero

getInteger

public static final int getInteger(ConfigurationKey key,
                                   int defaultValue)
Returns the numeric value of a configuration property.

Parameters:
key - the key to retrieve the value of
defaultValue - the value to return if the key does not exist
Returns:
the numeric value of the parameter if it exists, otherwise the default value

getBoolean

public static final boolean getBoolean(ConfigurationKey key)
Returns the boolean value of a configuration property.

Parameters:
key - the key to retrieve the value of
Returns:
the boolean value of the parameter if it exists, otherwise false

getBoolean

public static final boolean getBoolean(ConfigurationKey key,
                                       boolean defaultValue)
Returns the boolean value of a configuration property.

Parameters:
key - the key to retrieve the value of
defaultValue - the value to return if the key does not exist
Returns:
the boolean value of the parameter if it exists, otherwise the default value

setString

public static final void setString(ConfigurationKey key,
                                   java.lang.String newValue)
Sets the string value of a configuration property.

Parameters:
key - the key to set
newValue - the value to set the key to.

setInteger

public static final void setInteger(ConfigurationKey key,
                                    int newValue)
Sets the numeric value of a configuration property.

Parameters:
key - the key to set
newValue - the value to set the key to.

setDouble

public static final void setDouble(ConfigurationKey key,
                                   double newValue)
Sets the numeric value of a configuration property.

Parameters:
key - the key to set
newValue - the value to set the key to.

setBoolean

public static final void setBoolean(ConfigurationKey key,
                                    boolean newValue)
Sets the boolean value of a configuration property.

Parameters:
key - the key to set
newValue - the value to set the key to.

addListener

public static final void addListener(java.beans.PropertyChangeListener pcl)
Adds a property change listener.

Parameters:
pcl - The property change listener to add

removeListener

public static final void removeListener(java.beans.PropertyChangeListener pcl)
Removes a property change listener.

Parameters:
pcl - The property change listener to remove

addListener

public static final void addListener(ConfigurationKey key,
                                     java.beans.PropertyChangeListener pcl)
Adds a property change listener.Static for simplicity of use.

Parameters:
key - The key to listen for changes of
pcl - The property change listener to add

removeListener

public static final void removeListener(ConfigurationKey key,
                                        java.beans.PropertyChangeListener pcl)
Removes a property change listener.

Parameters:
key - The key to listen for changes of
pcl - The property change listener to remove

makeKey

public static ConfigurationKey makeKey(java.lang.String k1)
Create a single component configuration key.


makeKey

public static ConfigurationKey makeKey(ConfigurationKey ck,
                                       java.lang.String k1)
Create a sub-component of an existing configuration key.


makeKey

public static ConfigurationKey makeKey(java.lang.String k1,
                                       java.lang.String k2)
Create a two-component configuration key.


makeKey

public static ConfigurationKey makeKey(java.lang.String k1,
                                       java.lang.String k2,
                                       java.lang.String k3)
Create a three-component configuration key.


makeKey

public static ConfigurationKey makeKey(java.lang.String k1,
                                       java.lang.String k2,
                                       java.lang.String k3,
                                       java.lang.String k4)
Create a four-component configuration key.


makeKey

public static ConfigurationKey makeKey(java.lang.String k1,
                                       java.lang.String k2,
                                       java.lang.String k3,
                                       java.lang.String k4,
                                       java.lang.String k5)
Create a five-component configuration key.



ArgoUML © 1996-2003 (20040216)ArgoUML Project HomeArgoUML Cookbook