appl.ext
Class XuluConfig

java.lang.Object
  extended by appl.ext.XuluConfig

public class XuluConfig
extends Object

Simple Property store, which is loaded at each Xulu start and saved at each Xulu exit. Every class or plugin can store and retrieve configuration information easy through a static method. To keep the property file readable and to avoid conflicts with other plugins please prefix the key-name with a unique name, which identifies your class, followed by a dot and the property. This is important for correct display in a User-GUI (which could be implemented).

Keyformat: domain.property
Example key: DiscoveryService.className

There could be no double entries.But you can save multiple values to one key using the setMultiProperty method.
These values are internally separated with ';', so see that you don't use ';' in your values of Multi Properties

First the settings of the file "DefaultProperties" are loaded. After that the values are possibly overwritten by the loading of the file "XuluProperties" in which is intended to store a actual user configuration. "DefaultPropoerties" should never be modified by the user. The programmer should store all default values there.

The user may change values through the ConfigurationEditorGUI.

Author:
Dominik Appl
See Also:
ConfigurationEditorGUI, ConfigurationEditorEngine

Method Summary
 boolean getBooleanProperty(String key)
           
 double getDoubleProperty(String key)
           
 int getIntProperty(String key)
           
 Set<String> getKeysStartingWith(String startingString)
          Gets all entries starting with the given String
 String[] getMultiProperty(String key)
          A multiproperty stores multiple values for one key.
 Set<String> getPrefixes()
          Gets all prefixes.
 String getProperty(String key)
           
 String getProperty(String key, boolean giveWarning)
          Same as getProperty(String), but you can disable the warning message
 Set<String> getSuffixesOfPrefix(String prefix)
          Gets all suffixes for one prefix.
static XuluConfig getXuluConfig()
           
static XuluConfig getXuluConfig(File rootDir)
           
 void load()
          loads the Properties from the Propertyfile.
static void main(String[] args)
          Deprecated.  
 void removeAll(String key)
          removes all keys starting with the value given.
 void removeProperty(String key)
          removes the Property from the list
 void setBooleanProperty(String key, boolean value)
          inserts the property value with the specified key into the XuluConfig
 void setIntProperty(String key, int value)
          inserts the property value with the specified key into the XuluConfig
 void setMultiProperty(String key, String[] values)
          A multiproperty stores multiple values for one key.
 void setProperty(String key, String value)
          inserts the property value with the specified key into the XuluConfig
 void setPropertyFile(File file)
          Sets the Property file.
 void store()
          Saves the configuration to the file system
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getXuluConfig

public static XuluConfig getXuluConfig()

getXuluConfig

public static XuluConfig getXuluConfig(File rootDir)

store

public void store()
Saves the configuration to the file system


setPropertyFile

public void setPropertyFile(File file)
Sets the Property file. Notice that this has only an effect if you call load afterwards.

Parameters:
file -

load

public void load()
loads the Properties from the Propertyfile. No loaded values are deleted - only existing ones are overwritten;


setProperty

public void setProperty(String key,
                        String value)
inserts the property value with the specified key into the XuluConfig

Parameters:
key - the key
value - the value associated with the key

getProperty

public String getProperty(String key)
Returns:
the property associated with the provided key. If not found the defaults are searched. If still not found, null is returned. Gives out a warning to console if the key was not found

getProperty

public String getProperty(String key,
                          boolean giveWarning)
Same as getProperty(String), but you can disable the warning message

Parameters:
giveWarning - if true, a warning is given to the console if the specified entry was not found
Returns:
the property associated with the provided key. If not found the defaults are searched. If still not found, null is returned. Gives out a warning to console if the key was not found

getIntProperty

public int getIntProperty(String key)
Returns:
the property associated with the provided key as integer value. If not found the defaults are searched. If not found or the value is in a wrong format 0 is returned and a warning is given to the console

getDoubleProperty

public double getDoubleProperty(String key)
Returns:
the property associated with the provided key as double value. If not found the defaults are searched. If not found or the value is in a wrong format 0 is returned and a warning is given to the console

setBooleanProperty

public void setBooleanProperty(String key,
                               boolean value)
inserts the property value with the specified key into the XuluConfig

Parameters:
key - the key
value - the value associated with the key

setIntProperty

public void setIntProperty(String key,
                           int value)
inserts the property value with the specified key into the XuluConfig

Parameters:
key - the key
value - the value associated with the key

getBooleanProperty

public boolean getBooleanProperty(String key)
Returns:
the property associated with the provided key as boolean value. If not found the defaults are searched. If still not found or null then false is returned. Gives out a warning to console if the key was not found

setMultiProperty

public void setMultiProperty(String key,
                             String[] values)
A multiproperty stores multiple values for one key. These values are internaly seperated with spaces, so see that you dont use spaces in your values.

Parameters:
key - the key
values - array of the values which should be associated with the key

getMultiProperty

public String[] getMultiProperty(String key)
A multiproperty stores multiple values for one key. These values are internaly seperated with ';', so do not use ';' in your values. if the key was not found it gives out a warning to console and a empty array is retured.

Returns:
the multiProperty associated with the provided key, which is in this case just a String array

removeProperty

public void removeProperty(String key)
removes the Property from the list

Parameters:
key -

removeAll

public void removeAll(String key)
removes all keys starting with the value given. USE WITH CAUTION! If you give a String "a" all entrys starting with "a" will be removed from the registry

Parameters:
key -

getPrefixes

public Set<String> getPrefixes()
Gets all prefixes. A Prefix is the string of all characters up to the first dot. A Suffix is the string of all characters following this dot.

Returns:
the prefixes

getSuffixesOfPrefix

public Set<String> getSuffixesOfPrefix(String prefix)
Gets all suffixes for one prefix. A Prefix is the string of all characters up to the first dot. A Suffix is the string of all characters following this dot. The Strings are ordered alphabeticly

Parameters:
prefix - the prefix.

getKeysStartingWith

public Set<String> getKeysStartingWith(String startingString)
Gets all entries starting with the given String

Parameters:
startingString - the prefixstring
Returns:
all keys starting the given prefix

main

public static void main(String[] args)
Deprecated. 

Just for testing.