|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--org.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.
| Inner 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)
|
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 name)
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)
|
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 |
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 name,
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)
|
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 configuration| Method Detail |
public void setCategory(java.lang.String name)
setCategory in interface Configurationname - the name of the category
public void setCategory(java.lang.String name,
boolean main)
setCategory in interface Configurationname - the name of the categorymain - if true then this category is the default categorypublic void setCategory(Category category)
setCategory in interface Configurationpublic java.lang.String getMainCategoryName()
getMainCategoryName in interface Configurationpublic java.lang.String[] getCategoryNames()
getCategoryNames in interface Configurationprotected java.lang.String[] getCategoryNames(boolean includeParent)
public java.lang.String getProperty(java.lang.String key)
getProperty in interface Configurationkey - the name of the property
public java.lang.String getProperty(java.lang.String key,
java.lang.String defaultValue)
getProperty in interface Configurationkey - 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 Configurationkey - 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 Configurationname - the name of the propertyvalue - the value as String
public void setProperty(java.lang.String name,
java.lang.String value,
java.lang.String categoryName)
setProperty in interface Configurationname - the name of the propertyvalue - the value as StringcategoryName - the name of the categorypublic void removeProperty(java.lang.String name)
removeProperty in interface Configurationname - the name of the property
public void removeProperty(java.lang.String name,
java.lang.String category)
removeProperty in interface Configurationname - the name of the propertycategory - the name of the categorypublic int getNumberOfCategories()
getNumberOfCategories in interface Configurationpublic void removeCategory(java.lang.String category)
removeCategory in interface Configurationcategory - the name of the categorypublic java.util.Properties getProperties(java.lang.String category)
ConfigurationgetProperties in interface Configurationorg.jconfig.Configurationname - the name of the categorypublic java.util.Properties getProperties()
ConfigurationgetProperties in interface Configurationorg.jconfig.Configuration
protected java.util.Properties getProperties(java.lang.String category,
boolean includeParent)
public java.lang.String[] getPropertyNames(java.lang.String category)
getPropertyNames in interface Configurationcategory - the name of the category
public void setVariable(java.lang.String name,
java.lang.String value)
setVariable in interface Configurationname - the name of the variablevalue - the value of the variablepublic java.util.HashMap getVariables()
getVariables in interface Configurationpublic java.lang.String getVariable(java.lang.String name)
getVariable in interface Configuration
public int getIntProperty(java.lang.String name,
int defaultValue)
getIntProperty in interface Configurationname - defaultValue -
public int getIntProperty(java.lang.String name,
int defaultValue,
java.lang.String category)
getIntProperty in interface Configurationname - defaultValue - category -
public boolean getBooleanProperty(java.lang.String name,
boolean defaultValue)
getBooleanProperty in interface Configurationname - defaultValue - Category.getBooleanProperty(String, boolean)
public boolean getBooleanProperty(java.lang.String name,
boolean defaultValue,
java.lang.String categoryName)
getBooleanProperty in interface ConfigurationdefaultValue - categoryName - Category#getBooleanProperty(String, boolean, String)
public void setBooleanProperty(java.lang.String key,
boolean value)
setBooleanProperty in interface Configurationkey - value -
public void setBooleanProperty(java.lang.String key,
boolean value,
java.lang.String category)
setBooleanProperty in interface Configurationkey - value - category -
public long getLongProperty(java.lang.String name,
long defaultValue)
getLongProperty in interface Configurationname - defaultValue -
public long getLongProperty(java.lang.String name,
long defaultValue,
java.lang.String categoryName)
getLongProperty in interface Configurationname - defaultValue - category -
public double getDoubleProperty(java.lang.String name,
double defaultValue)
getDoubleProperty in interface Configurationname - defaultValue -
public double getDoubleProperty(java.lang.String name,
double defaultValue,
java.lang.String category)
getDoubleProperty in interface Configurationname - defaultValue - category -
public char getCharProperty(java.lang.String name,
char defaultValue)
getCharProperty in interface Configurationname - defaultValue -
public char getCharProperty(java.lang.String name,
char defaultValue,
java.lang.String category)
getCharProperty in interface Configurationname - defaultValue - category - public java.lang.String toString()
toString in interface ConfigurationtoString in class java.lang.Objectpublic 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 Configurationlistener -
public void addPropertyListener(PropertyListener listener,
java.lang.String categoryName)
addPropertyListener in interface Configurationpublic void addCategoryListener(CategoryListener listener)
addCategoryListener in interface Configuration
public void addCategoryListener(CategoryListener listener,
java.lang.String categoryName)
addCategoryListener in interface Configurationpublic java.lang.String getConfigName()
getConfigName in interface Configurationpublic void setConfigName(java.lang.String configName)
setConfigName in interface Configurationpublic void addConfigurationListener(ConfigurationListener listener)
addConfigurationListener in interface Configurationlistener - The ConfigurationListenerpublic void removeConfigurationListener(ConfigurationListener listener)
removeConfigurationListener in interface Configurationlistener - The ConfigurationListenerpublic void fireConfigurationChangedEvent(ConfigurationChangedEvent event)
fireConfigurationChangedEvent in interface Configurationevent - The ConfigurationChangedEventpublic Category getCategory()
getCategory in interface Configurationpublic Category getCategory(java.lang.String name)
getCategory in interface Configurationname - The name of the category (if null, main category will be used)
public void setLongProperty(java.lang.String key,
long value)
setLongProperty in interface Configurationkey - value -
public void setIntProperty(java.lang.String key,
int value)
setIntProperty in interface Configurationkey - value -
public void setCharProperty(java.lang.String key,
char value)
setCharProperty in interface Configurationkey - value -
public void setCharProperty(java.lang.String key,
char value,
java.lang.String category)
setCharProperty in interface Configurationkey - value - category -
public void setDoubleProperty(java.lang.String key,
double value)
setDoubleProperty in interface Configurationkey - value -
public void setLongProperty(java.lang.String key,
long value,
java.lang.String category)
setLongProperty in interface Configurationkey - value - category -
public void setIntProperty(java.lang.String key,
int value,
java.lang.String category)
setIntProperty in interface Configurationkey - value - category -
public void setDoubleProperty(java.lang.String key,
double value,
java.lang.String category)
setDoubleProperty in interface Configurationkey - value - category - public boolean hasChanged()
ConfigurationhasChanged in interface Configurationorg.jconfig.Configurationpublic java.lang.String[] getArray(java.lang.String key)
getArray in interface Configurationorg.jconfig.Configurationkey -
public java.lang.String[] getArray(java.lang.String key,
java.lang.String[] defaultValue)
getArray in interface Configurationorg.jconfig.Configurationkey - defaultValue -
public java.lang.String[] getArray(java.lang.String key,
java.lang.String[] defaultValue,
java.lang.String category)
getArray in interface Configurationorg.jconfig.Configurationkey - defaultValue - category - public boolean isNew()
ConfigurationisNew in interface Configurationorg.jconfig.Configurationpublic void resetCreated()
ConfigurationresetCreated in interface Configurationpublic java.lang.String getEncoding()
getEncoding in interface Configurationprotected void markDirty()
public void setEncoding(java.lang.String encoding)
setEncoding in interface Configurationpublic boolean containsCategory(java.lang.String categoryName)
ConfigurationcontainsCategory in interface Configuration
public void addInclude(int type,
java.lang.String name)
addInclude in interface Configurationpublic java.util.Vector getIncludes()
getIncludes in interface Configurationpublic void setBaseConfiguration(java.lang.String name)
ConfigurationsetBaseConfiguration in interface Configuration
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||