|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jconfig.DefaultConfiguration
This class is the configuration itself. The Configuration is useful if one wants to manage multiple configurations. A single instance of the Configuration may contain, for example, information for one application or user.
Nested Class Summary | |
protected class |
DefaultConfiguration.MyCategoryListener
|
Field Summary | |
protected java.lang.String |
baseConfigName
|
protected java.util.HashMap |
categories
|
protected java.lang.String |
configName
|
protected java.lang.String |
mainCategory
|
protected static VariableManager |
vm
|
Constructor Summary | |
protected |
DefaultConfiguration()
|
|
DefaultConfiguration(java.lang.String configName)
The constructor that creates a new configuration with one empty category called "general". |
Method Summary | |
void |
addCategoryListener(CategoryListener listener)
|
void |
addCategoryListener(CategoryListener listener,
java.lang.String categoryName)
|
void |
addConfigurationListener(ConfigurationListener listener)
Adds the specified configuration listener to receive configuration changed events from this configuration. |
void |
addInclude(int type,
java.lang.String name)
|
protected void |
addIncludeBlock(java.lang.StringBuffer buffer)
|
void |
addPropertyListener(PropertyListener listener)
Adds the PropertyListener to the main category. |
void |
addPropertyListener(PropertyListener listener,
java.lang.String categoryName)
Adds the PropertyListener to the given category. |
protected void |
addVariableBlock(java.lang.StringBuffer buffer)
|
boolean |
containsCategory(java.lang.String categoryName)
Use this method to determine if a category exists. |
protected java.lang.String |
escapeForXML(java.lang.String text)
|
void |
fireConfigurationChangedEvent(ConfigurationChangedEvent event)
Deliver configuration changed event to all listeners that are registered with our listener list. |
java.lang.String[] |
getArray(java.lang.String key)
|
java.lang.String[] |
getArray(java.lang.String key,
java.lang.String[] defaultValue)
|
java.lang.String[] |
getArray(java.lang.String key,
java.lang.String[] defaultValue,
java.lang.String category)
|
java.lang.String[] |
getArray(java.lang.String key,
java.lang.String[] defaultValue,
java.lang.String category,
java.lang.String separator)
|
java.lang.String |
getBaseConfiguration()
|
boolean |
getBooleanProperty(java.lang.String name,
boolean defaultValue)
Wrapper method to keep API simple |
boolean |
getBooleanProperty(java.lang.String name,
boolean defaultValue,
java.lang.String categoryName)
Wrapper method to Category method |
Category |
getCategory()
Returns the main category for this configuration |
Category |
getCategory(java.lang.String categoryName)
Returns a category based on the name provided. |
java.lang.String[] |
getCategoryNames()
This method returns a string array with all category names. |
protected java.lang.String[] |
getCategoryNames(boolean includeParent)
A convenience method that returns the key set in the form or a String Array. |
char |
getCharProperty(java.lang.String name,
char defaultValue)
Wrapper method to Category method |
char |
getCharProperty(java.lang.String name,
char defaultValue,
java.lang.String category)
Wrapper method to Category method |
java.lang.String |
getConfigName()
Return the name of the current configuration. |
double |
getDoubleProperty(java.lang.String name,
double defaultValue)
Wrapper method to Category method |
double |
getDoubleProperty(java.lang.String name,
double defaultValue,
java.lang.String category)
Wrapper method to Category method |
java.lang.String |
getEncoding()
|
java.util.Vector |
getIncludes()
|
int |
getIntProperty(java.lang.String name,
int defaultValue)
|
int |
getIntProperty(java.lang.String name,
int defaultValue,
java.lang.String category)
|
long |
getLongProperty(java.lang.String name,
long defaultValue)
Wrapper method to Category method |
long |
getLongProperty(java.lang.String name,
long defaultValue,
java.lang.String categoryName)
Wrapper method to Category method |
java.lang.String |
getMainCategoryName()
This method returns the name of the default category |
int |
getNumberOfCategories()
The method returns the number of categories inside this configuration. |
java.util.Properties |
getProperties()
This method returns all properties for the default category |
java.util.Properties |
getProperties(java.lang.String category)
This method returns all properties for the category with the given name |
protected java.util.Properties |
getProperties(java.lang.String category,
boolean includeParent)
|
java.lang.String |
getProperty(java.lang.String key)
This method returns the String value based on the given key. |
java.lang.String |
getProperty(java.lang.String key,
java.lang.String defaultValue)
This method is the same as getProperty(key) but it returns the defaultValue if the property cannot be found. |
java.lang.String |
getProperty(java.lang.String key,
java.lang.String defaultValue,
java.lang.String categoryName)
This is the real implementation. |
java.lang.String[] |
getPropertyNames(java.lang.String category)
This method returns all the names of the properties for the specific category |
protected java.util.SortedMap |
getSortedProperties(java.lang.String categoryName,
boolean includeParent)
|
java.lang.String |
getVariable(java.lang.String name)
|
java.util.HashMap |
getVariables()
It returns a HashMap with all variables with the variable name as key |
java.lang.String |
getXMLAsString()
This method converts the Configuration into a String which looks like XML. |
boolean |
hasChanged()
This methods returns a flag which indicates if the configuration has changed since it was loaded. |
boolean |
isNew()
This method determines if the configuration was loaded successfully (returns false) or if the configuration was created by the ConfigurationManager. |
protected void |
markDirty()
|
void |
removeCategory(java.lang.String category)
This method deletes a category with all its properties |
void |
removeConfigurationListener(ConfigurationListener listener)
Removes the specified configuration listener from the configuration change events from this configuration. |
void |
removeProperty(java.lang.String name)
This method deletes a property from the default category. |
void |
removeProperty(java.lang.String name,
java.lang.String category)
This method deletes a property with the given name from the specific category. |
void |
renameCategory(java.lang.String newName,
java.lang.String oldName)
|
void |
resetCreated()
This method is used by the handlers to reset the isNew flag to false. |
void |
setBaseConfiguration(java.lang.String name)
This method is used to define the base configuration of a configuration. |
void |
setBooleanProperty(java.lang.String key,
boolean value)
Wrapper method to Category method |
void |
setBooleanProperty(java.lang.String key,
boolean value,
java.lang.String category)
Wrapper method to Category method |
void |
setCategory(Category category)
|
void |
setCategory(java.lang.String name)
This method sets a category but it does not set this category as default. |
void |
setCategory(java.lang.String categoryName,
boolean main)
Besides setting the category, it will also set this category as default category if main is true. |
void |
setCharProperty(java.lang.String key,
char value)
Wrapper method to Category method |
void |
setCharProperty(java.lang.String key,
char value,
java.lang.String category)
Wrapper method to Category method |
void |
setConfigName(java.lang.String configName)
Sets the name of the configuration. |
void |
setDoubleProperty(java.lang.String key,
double value)
Wrapper method to Category method |
void |
setDoubleProperty(java.lang.String key,
double value,
java.lang.String category)
Wrapper method to Category method |
void |
setEncoding(java.lang.String encoding)
|
void |
setIntProperty(java.lang.String key,
int value)
Wrapper method to Category method |
void |
setIntProperty(java.lang.String key,
int value,
java.lang.String category)
Wrapper method to Category method |
void |
setLongProperty(java.lang.String key,
long value)
Wrapper method to Category method |
void |
setLongProperty(java.lang.String key,
long value,
java.lang.String category)
Wrapper method to Category method |
void |
setProperty(java.lang.String name,
java.lang.String value)
This method sets a property with the name and the value in the default category. |
void |
setProperty(java.lang.String name,
java.lang.String value,
java.lang.String categoryName)
This method sets the value for a property for the given category. |
void |
setVariable(java.lang.String name,
java.lang.String value)
This method sets a variable inside the configuration. |
java.lang.String |
toString()
This method creates a string representation of the configuration. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected static final VariableManager vm
protected java.lang.String configName
protected java.util.HashMap categories
protected java.lang.String mainCategory
protected java.lang.String baseConfigName
Constructor Detail |
protected DefaultConfiguration()
public DefaultConfiguration(java.lang.String configName)
configName
- the name of the configurationMethod Detail |
public void setCategory(java.lang.String name)
setCategory
in interface Configuration
name
- the name of the categorypublic void renameCategory(java.lang.String newName, java.lang.String oldName)
renameCategory
in interface Configuration
public void setCategory(java.lang.String categoryName, boolean main)
setCategory
in interface Configuration
categoryName
- the name of the categorymain
- if true then this category is the default categorypublic void setCategory(Category category)
setCategory
in interface Configuration
public java.lang.String getMainCategoryName()
getMainCategoryName
in interface Configuration
public java.lang.String[] getCategoryNames()
getCategoryNames
in interface Configuration
protected java.lang.String[] getCategoryNames(boolean includeParent)
includeParent
- true will check for a base configuration
and include those category names as well.
public java.lang.String getProperty(java.lang.String key)
getProperty
in interface Configuration
key
- the name of the property
public java.lang.String getProperty(java.lang.String key, java.lang.String defaultValue)
getProperty
in interface Configuration
key
- the name of the propertydefaultValue
- the defaultValue that will be returned if the property cannot be found
public java.lang.String getProperty(java.lang.String key, java.lang.String defaultValue, java.lang.String categoryName)
getProperty
in interface Configuration
key
- the name of the propertydefaultValue
- the default valuecategoryName
- the name of the category
public void setProperty(java.lang.String name, java.lang.String value)
setProperty
in interface Configuration
name
- the name of the propertyvalue
- the value as Stringpublic void setProperty(java.lang.String name, java.lang.String value, java.lang.String categoryName)
setProperty
in interface Configuration
name
- the name of the propertyvalue
- the value as StringcategoryName
- the name of the categorypublic void removeProperty(java.lang.String name)
removeProperty
in interface Configuration
name
- the name of the propertypublic void removeProperty(java.lang.String name, java.lang.String category)
removeProperty
in interface Configuration
name
- the name of the propertycategory
- the name of the categorypublic int getNumberOfCategories()
getNumberOfCategories
in interface Configuration
public void removeCategory(java.lang.String category)
removeCategory
in interface Configuration
category
- the name of the categorypublic java.util.Properties getProperties(java.lang.String category)
Configuration
getProperties
in interface Configuration
category
- the name of the category
public java.util.Properties getProperties()
Configuration
getProperties
in interface Configuration
protected java.util.Properties getProperties(java.lang.String category, boolean includeParent)
category
- includeParent
-
public java.lang.String[] getPropertyNames(java.lang.String category)
getPropertyNames
in interface Configuration
category
- the name of the category
public void setVariable(java.lang.String name, java.lang.String value)
setVariable
in interface Configuration
name
- the name of the variablevalue
- the value of the variablepublic java.util.HashMap getVariables()
getVariables
in interface Configuration
public java.lang.String getVariable(java.lang.String name)
getVariable
in interface Configuration
public int getIntProperty(java.lang.String name, int defaultValue)
getIntProperty
in interface Configuration
name
- defaultValue
-
public int getIntProperty(java.lang.String name, int defaultValue, java.lang.String category)
getIntProperty
in interface Configuration
name
- defaultValue
- category
-
public boolean getBooleanProperty(java.lang.String name, boolean defaultValue)
getBooleanProperty
in interface Configuration
name
- defaultValue
-
Category.getBooleanProperty(String, boolean)
public boolean getBooleanProperty(java.lang.String name, boolean defaultValue, java.lang.String categoryName)
getBooleanProperty
in interface Configuration
defaultValue
- categoryName
-
Category#getBooleanProperty(String, boolean, String)
public void setBooleanProperty(java.lang.String key, boolean value)
setBooleanProperty
in interface Configuration
key
- value
- public void setBooleanProperty(java.lang.String key, boolean value, java.lang.String category)
setBooleanProperty
in interface Configuration
key
- value
- category
- public long getLongProperty(java.lang.String name, long defaultValue)
getLongProperty
in interface Configuration
name
- defaultValue
-
public long getLongProperty(java.lang.String name, long defaultValue, java.lang.String categoryName)
getLongProperty
in interface Configuration
name
- defaultValue
- categoryName
-
public double getDoubleProperty(java.lang.String name, double defaultValue)
getDoubleProperty
in interface Configuration
name
- defaultValue
-
public double getDoubleProperty(java.lang.String name, double defaultValue, java.lang.String category)
getDoubleProperty
in interface Configuration
name
- defaultValue
- category
-
public char getCharProperty(java.lang.String name, char defaultValue)
getCharProperty
in interface Configuration
name
- defaultValue
-
public char getCharProperty(java.lang.String name, char defaultValue, java.lang.String category)
getCharProperty
in interface Configuration
name
- defaultValue
- category
-
public java.lang.String toString()
toString
in interface Configuration
public java.lang.String getXMLAsString()
getXMLAsString
in interface Configuration
protected java.util.SortedMap getSortedProperties(java.lang.String categoryName, boolean includeParent)
protected void addIncludeBlock(java.lang.StringBuffer buffer)
protected void addVariableBlock(java.lang.StringBuffer buffer)
protected java.lang.String escapeForXML(java.lang.String text)
public void addPropertyListener(PropertyListener listener)
addPropertyListener
in interface Configuration
listener
- public void addPropertyListener(PropertyListener listener, java.lang.String categoryName)
addPropertyListener
in interface Configuration
public void addCategoryListener(CategoryListener listener)
addCategoryListener
in interface Configuration
public void addCategoryListener(CategoryListener listener, java.lang.String categoryName)
addCategoryListener
in interface Configuration
public java.lang.String getConfigName()
getConfigName
in interface Configuration
public void setConfigName(java.lang.String configName)
Configuration
setConfigName
in interface Configuration
configName
- public void addConfigurationListener(ConfigurationListener listener)
addConfigurationListener
in interface Configuration
listener
- The ConfigurationListenerpublic void removeConfigurationListener(ConfigurationListener listener)
removeConfigurationListener
in interface Configuration
listener
- The ConfigurationListenerpublic void fireConfigurationChangedEvent(ConfigurationChangedEvent event)
fireConfigurationChangedEvent
in interface Configuration
event
- The ConfigurationChangedEventpublic Category getCategory()
getCategory
in interface Configuration
public Category getCategory(java.lang.String categoryName)
getCategory
in interface Configuration
categoryName
- The name of the category (if null, main category will be used)
public void setLongProperty(java.lang.String key, long value)
setLongProperty
in interface Configuration
key
- value
- public void setIntProperty(java.lang.String key, int value)
setIntProperty
in interface Configuration
key
- value
- public void setCharProperty(java.lang.String key, char value)
setCharProperty
in interface Configuration
key
- value
- public void setCharProperty(java.lang.String key, char value, java.lang.String category)
setCharProperty
in interface Configuration
key
- value
- category
- public void setDoubleProperty(java.lang.String key, double value)
setDoubleProperty
in interface Configuration
key
- value
- public void setLongProperty(java.lang.String key, long value, java.lang.String category)
setLongProperty
in interface Configuration
key
- value
- category
- public void setIntProperty(java.lang.String key, int value, java.lang.String category)
setIntProperty
in interface Configuration
key
- value
- category
- public void setDoubleProperty(java.lang.String key, double value, java.lang.String category)
setDoubleProperty
in interface Configuration
key
- value
- category
- public boolean hasChanged()
Configuration
hasChanged
in interface Configuration
public java.lang.String[] getArray(java.lang.String key)
getArray
in interface Configuration
key
-
public java.lang.String[] getArray(java.lang.String key, java.lang.String[] defaultValue)
getArray
in interface Configuration
key
- defaultValue
-
public java.lang.String[] getArray(java.lang.String key, java.lang.String[] defaultValue, java.lang.String category)
getArray
in interface Configuration
key
- defaultValue
- category
-
public java.lang.String[] getArray(java.lang.String key, java.lang.String[] defaultValue, java.lang.String category, java.lang.String separator)
public boolean isNew()
Configuration
isNew
in interface Configuration
public void resetCreated()
Configuration
resetCreated
in interface Configuration
public java.lang.String getEncoding()
getEncoding
in interface Configuration
protected void markDirty()
public void setEncoding(java.lang.String encoding)
setEncoding
in interface Configuration
public boolean containsCategory(java.lang.String categoryName)
Configuration
containsCategory
in interface Configuration
public void addInclude(int type, java.lang.String name)
addInclude
in interface Configuration
public java.util.Vector getIncludes()
getIncludes
in interface Configuration
public void setBaseConfiguration(java.lang.String name)
Configuration
setBaseConfiguration
in interface Configuration
public java.lang.String getBaseConfiguration()
getBaseConfiguration
in interface Configuration
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |