org.jconfig
Class DefaultCategory

java.lang.Object
  |
  +--org.jconfig.DefaultCategory
All Implemented Interfaces:
Category
Direct Known Subclasses:
NestedCategory

public class DefaultCategory
extends java.lang.Object
implements Category

This class is the result of countless discussions of what a Category should be. After determing that it should be another class, and that we can do something useful, we created this Category. A Category is a logical extension of the Configuration has Categories has Properties has Value frame-of-mind. The primary goal is to reduce redundancy in source code when using setter and getters that include Category information.

Since:
2.2
Author:
Andreas Mecky , Terry Dye Changes: The helper methods for the primitives did not replaced variables, Lubos Pochman lubosp@myway.com

Constructor Summary
DefaultCategory(java.lang.String categoryName)
           
 
Method Summary
 void addCategoryListener(CategoryListener listener)
          Adds the specified category listener to receive category changed events from this category.
 void addPropertyListener(PropertyListener listener)
          Adds the given listener to the list that wish to receive the PropertyChangedEvent.
 void fireCategoryChangedEvent(CategoryChangedEvent event)
          Deliver category changed event to all listeners that are registered with our listener list.
 void firePropertyChangedEvent(PropertyChangedEvent event)
          Notifies all PropertyListeners of changes to the property (added, removed, changed).
 java.lang.String[] getArray(java.lang.String key)
           
 java.lang.String[] getArray(java.lang.String key, java.lang.String[] defaultValue)
           
 boolean getBooleanProperty(java.lang.String name, boolean defaultValue)
          Helper method to allow for strong-binding within Properties.
 java.lang.String getCategoryName()
          Returns the name of this category.
 char getCharProperty(java.lang.String name, char defaultValue)
          Helper method to allow for strong-binding within Properties.
 java.lang.String getConfigurationName()
          Getter for property configurationName.
 double getDoubleProperty(java.lang.String name, double defaultValue)
          Helper method to allow for strong-binding within Properties.
 java.lang.String getExtendsCategory()
           
 int getIntProperty(java.lang.String name, int defaultValue)
          Helper method to allow for strong-binding within Properties.
 long getLongProperty(java.lang.String name, long defaultValue)
          Helper method to allow for strong-binding within Properties.
 java.util.Properties getProperties()
          Return all properties related to this category
 java.lang.String getProperty(java.lang.String propertyName)
          Searches for the property with the specified key in this property list.
 java.lang.String getProperty(java.lang.String propertyName, java.lang.String defaultValue)
          Searches for the property with the specified key in this property list.
 void removeCategoryListener(CategoryListener listener)
          Removes the specified category listener from the category change events from this category.
 void removePropertyListener(PropertyListener listener)
          Removes the given listener to the list that wish to receive the PropertyChangedEvent.
 void setBooleanProperty(java.lang.String name, boolean value)
          Helper method to allow for strong-binding within Properties.
 void setCharProperty(java.lang.String key, char value)
          Helper method to allow for strong-binding within Properties.
 void setConfigurationName(java.lang.String configurationName)
          Setter for property configurationName.
 void setDoubleProperty(java.lang.String key, double value)
          Helper method to allow for strong-binding within Properties.
 void setExtendsCategory(java.lang.String extendsCategory)
           
 void setIntProperty(java.lang.String key, int value)
          Helper method to allow for strong-binding within Properties.
 void setLongProperty(java.lang.String key, long value)
          Helper method to allow for strong-binding within Properties.
 Category setProperty(java.lang.String propertyName, java.lang.String propertyValue)
          Sets the property with the value given.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultCategory

public DefaultCategory(java.lang.String categoryName)
Parameters:
categoryName -  
Since:
2.2
Method Detail

setProperty

public Category setProperty(java.lang.String propertyName,
                            java.lang.String propertyValue)
Sets the property with the value given. This will override any existing property values if the property name is duplicated. This will create a new property if no property exists. Setting the value to <null> will remove the property from the Category;
Specified by:
setProperty in interface Category
Parameters:
propertyName -  
propertyValue -  
Returns:
 
Since:
2.2

getProperty

public java.lang.String getProperty(java.lang.String propertyName)
Searches for the property with the specified key in this property list. If the key is not found in this property list, the default property list, and its defaults, recursively, are then checked. The method returns null if the property is not found.
Specified by:
getProperty in interface Category
Parameters:
key - the property key.
Returns:
the value in this property list with the specified key value.
Since:
2.2

getProperty

public java.lang.String getProperty(java.lang.String propertyName,
                                    java.lang.String defaultValue)
Searches for the property with the specified key in this property list. If the key is not found in this property list, the default property list, and its defaults, recursively, are then checked. The method returns the default value argument if the property is not found.
Specified by:
getProperty in interface Category
Parameters:
propertyName - The property name.
defaultValue - The default value.
Returns:
the value in this property list with the specified key value or the defaultValue.
Since:
2.2

getCategoryName

public java.lang.String getCategoryName()
Returns the name of this category.
Specified by:
getCategoryName in interface Category
Returns:
The name of the category.
Since:
2.2

addCategoryListener

public void addCategoryListener(CategoryListener listener)
Adds the specified category listener to receive category changed events from this category.
Specified by:
addCategoryListener in interface Category
Parameters:
listener - The ConfigurationListener
Since:
2.2

removeCategoryListener

public void removeCategoryListener(CategoryListener listener)
Removes the specified category listener from the category change events from this category.
Specified by:
removeCategoryListener in interface Category
Parameters:
listener - The ConfigurationListener
Since:
2.2

fireCategoryChangedEvent

public void fireCategoryChangedEvent(CategoryChangedEvent event)
Deliver category changed event to all listeners that are registered with our listener list.
Specified by:
fireCategoryChangedEvent in interface Category
Parameters:
event - The ConfigurationChangedEvent
Since:
2.2

getProperties

public java.util.Properties getProperties()
Return all properties related to this category
Specified by:
getProperties in interface Category
Returns:
The Properties
Since:
2.2

getArray

public java.lang.String[] getArray(java.lang.String key)
Specified by:
getArray in interface Category

getArray

public java.lang.String[] getArray(java.lang.String key,
                                   java.lang.String[] defaultValue)
Specified by:
getArray in interface Category

getBooleanProperty

public boolean getBooleanProperty(java.lang.String name,
                                  boolean defaultValue)
Helper method to allow for strong-binding within Properties.
Specified by:
getBooleanProperty in interface Category
Parameters:
name - The name of the property
defaultValue - The default value
Returns:
If the String value can be converted to Boolean, the value will be return, otherwise the the default value.
Since:
2.2

setBooleanProperty

public void setBooleanProperty(java.lang.String name,
                               boolean value)
Helper method to allow for strong-binding within Properties.
Specified by:
setBooleanProperty in interface Category
Parameters:
name -  
value -  
Since:
2.2

getCharProperty

public char getCharProperty(java.lang.String name,
                            char defaultValue)
Helper method to allow for strong-binding within Properties.
Specified by:
getCharProperty in interface Category
Parameters:
name - The name of the property
defaultValue - The default value
Returns:
If the String value can be converted to Boolean, the value will be return, otherwise the the default value.
Since:
2.2

setCharProperty

public void setCharProperty(java.lang.String key,
                            char value)
Helper method to allow for strong-binding within Properties.
Specified by:
setCharProperty in interface Category
Parameters:
string -  
c -  
Since:
2.2

getDoubleProperty

public double getDoubleProperty(java.lang.String name,
                                double defaultValue)
Helper method to allow for strong-binding within Properties.
Specified by:
getDoubleProperty in interface Category
Parameters:
name - The name of the property
defaultValue - The default value
Returns:
If the String value can be converted to Boolean, the value will be return, otherwise the the default value.
Since:
2.2

getIntProperty

public int getIntProperty(java.lang.String name,
                          int defaultValue)
Helper method to allow for strong-binding within Properties.
Specified by:
getIntProperty in interface Category
Parameters:
name - The name of the property
defaultValue - The default value
Returns:
If the String value can be converted to Boolean, the value will be return, otherwise the the default value.
Since:
2.2

setIntProperty

public void setIntProperty(java.lang.String key,
                           int value)
Helper method to allow for strong-binding within Properties.
Specified by:
setIntProperty in interface Category
Parameters:
string -  
i -  
Since:
2.2

getLongProperty

public long getLongProperty(java.lang.String name,
                            long defaultValue)
Helper method to allow for strong-binding within Properties.
Specified by:
getLongProperty in interface Category
Parameters:
name - The name of the property
defaultValue - The default value
Returns:
If the String value can be converted to Boolean, the value will be return, otherwise the the default value.
Since:
2.2

setLongProperty

public void setLongProperty(java.lang.String key,
                            long value)
Helper method to allow for strong-binding within Properties.
Specified by:
setLongProperty in interface Category
Parameters:
string -  
l -  
Since:
2.2

getConfigurationName

public java.lang.String getConfigurationName()
Getter for property configurationName.
Specified by:
getConfigurationName in interface Category
Returns:
Value of property configurationName.
Since:
2.2

setConfigurationName

public void setConfigurationName(java.lang.String configurationName)
Setter for property configurationName.
Specified by:
setConfigurationName in interface Category
Parameters:
configurationName - New value of property configurationName.
Since:
2.2

setDoubleProperty

public void setDoubleProperty(java.lang.String key,
                              double value)
Helper method to allow for strong-binding within Properties.
Specified by:
setDoubleProperty in interface Category
Parameters:
key -  
value -  
Since:
2.2

addPropertyListener

public void addPropertyListener(PropertyListener listener)
Adds the given listener to the list that wish to receive the PropertyChangedEvent.
Specified by:
addPropertyListener in interface Category
Parameters:
listener -  
Since:
2.2

removePropertyListener

public void removePropertyListener(PropertyListener listener)
Removes the given listener to the list that wish to receive the PropertyChangedEvent.
Specified by:
removePropertyListener in interface Category
Parameters:
listener -  
Since:
2.2

firePropertyChangedEvent

public void firePropertyChangedEvent(PropertyChangedEvent event)
Notifies all PropertyListeners of changes to the property (added, removed, changed).
Specified by:
firePropertyChangedEvent in interface Category
Parameters:
event -  

setExtendsCategory

public void setExtendsCategory(java.lang.String extendsCategory)
Specified by:
setExtendsCategory in interface Category

getExtendsCategory

public java.lang.String getExtendsCategory()
Specified by:
getExtendsCategory in interface Category


Copyright © 2001-2003 Andreas Mecky, Terry Dye. All Rights Reserved.