org.argouml.application.api
Class Configuration

java.lang.Object
  extended byorg.argouml.application.api.Configuration

public class Configuration
extends 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
private static ConfigurationHandler config
          The only occurance of the configuration handler.
static String FILE_LOADED
          Property to indicate configuration load from file.
static String FILE_SAVED
          Property to indicate configuration save to file.
static String URL_LOADED
          Property to indicate configuration load from url.
static String URL_SAVED
          Property to indicate configuration save to url.
 
Constructor Summary
private Configuration()
          Private constructor so it cannot be instantiated.
 
Method Summary
static void addListener(ConfigurationKey key, PropertyChangeListener pcl)
          Adds a property change listener.Static for simplicity of use.
static void addListener(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 String getString(ConfigurationKey key)
          Returns the string value of a configuration property.
static String getString(ConfigurationKey key, String defaultValue)
          Returns the string value of a configuration property.
static boolean load()
          Load the configuration from the default location.
static boolean load(File file)
          Load the configuration from a specified file.
static boolean load(URL url)
          Load the configuration from a specified url.
static ConfigurationKey makeKey(ConfigurationKey ck, String k1)
          Create a sub-component of an existing configuration key.
static ConfigurationKey makeKey(String k1)
          Create a single component configuration key.
static ConfigurationKey makeKey(String k1, String k2)
          Create a two-component configuration key.
static ConfigurationKey makeKey(String k1, String k2, String k3)
          Create a three-component configuration key.
static ConfigurationKey makeKey(String k1, String k2, String k3, String k4)
          Create a four-component configuration key.
static ConfigurationKey makeKey(String k1, String k2, String k3, String k4, String k5)
          Create a five-component configuration key.
static void removeListener(ConfigurationKey key, PropertyChangeListener pcl)
          Removes a property change listener.
static void removeListener(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, 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

FILE_LOADED

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

See Also:
Constant Field Values

URL_LOADED

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

See Also:
Constant Field Values

FILE_SAVED

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

See Also:
Constant Field Values

URL_SAVED

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

See Also:
Constant Field Values

config

private static ConfigurationHandler config
The only occurance of the configuration handler.

Constructor Detail

Configuration

private Configuration()
Private constructor so it cannot be instantiated.

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(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(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.

Parameters:
force - the file to save even if it would not normally be saved.
Returns:
true if the save is successful, otherwise false

getString

public static 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 String getString(ConfigurationKey key,
                                     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
defaultValue - if the key is not found
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,
                                   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(PropertyChangeListener pcl)
Adds a property change listener.

Parameters:
pcl - The property change listener to add

removeListener

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

Parameters:
pcl - The property change listener to remove

addListener

public static final void addListener(ConfigurationKey key,
                                     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,
                                        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(String k1)
Create a single component configuration key.

Parameters:
k1 - key component 1.
Returns:
the new ConfigurationKey.

makeKey

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

Parameters:
ck - existing key to extend.
k1 - key component 1.
Returns:
the new ConfigurationKey.

makeKey

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

Parameters:
k1 - key component 1.
k2 - key component 2.
Returns:
the new ConfigurationKey.

makeKey

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

Parameters:
k1 - key component 1.
k2 - key component 2.
k3 - key component 3.
Returns:
the new ConfigurationKey.

makeKey

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

Parameters:
k1 - key component 1.
k2 - key component 2.
k3 - key component 3.
k4 - key component 4.
Returns:
the new ConfigurationKey.

makeKey

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

Parameters:
k1 - key component 1.
k2 - key component 2.
k3 - key component 3.
k4 - key component 4.
k5 - key component 5.
Returns:
the new ConfigurationKey.


ArgoUML © 1996-2004 (20050222)ArgoUML HomepageArgoUML Developers' pageArgoUML Cookbook