OpenNMS API 1.2.3

org.opennms.netmgt.config
Class CategoryFactory

java.lang.Object
  extended byorg.opennms.netmgt.config.CategoryFactory

public final class CategoryFactory
extends java.lang.Object

This is the singleton class used to load the configuration from the categories.xml. This provides convenience methods to get the configured categories and their information, add/delete categories from category groups. Note: Users of this class should make sure the init() is called before calling any other method to ensure the config is loaded before accessing other convenience methods.

Author:
Sowmya Nataraj , OpenNMS

Field Summary
private  Catinfo m_config
          The config class loaded from the config file
private static boolean m_loaded
          This member is set to true if the configuration file has been loaded.
private static CategoryFactory m_singleton
          The singleton instance of this factory
 
Constructor Summary
private CategoryFactory(java.lang.String configFile)
          Private constructor
 
Method Summary
 boolean addCategory(java.lang.String groupname, Category cat)
          Add category to a categorygroup.
 void addCategoryGroup(Categorygroup group)
          Add a categorygroup.
 boolean deleteCategory(java.lang.String groupname, Category cat)
          Delete category from a categorygroup.
 boolean deleteCategory(java.lang.String groupname, java.lang.String catlabel)
          Delete category from a categorygroup.
 boolean deleteCategoryGroup(Categorygroup group)
          Delete a categorygroup.
 boolean deleteCategoryGroup(java.lang.String groupname)
          Delete a categorygroup.
 Category getCategory(java.lang.String name)
          Return the category specified by name.
 Catinfo getConfig()
          Return the categories configuration.
 java.lang.String getEffectiveRule(java.lang.String catlabel)
          Return the effective rule for the specified category.
static CategoryFactory getInstance()
          Return the singleton instance of this factory.
 double getNormal(java.lang.String catlabel)
          Return the normal value for the specified category.
 java.lang.String getRule(java.lang.String catlabel)
          Return the rule for the specified category.
 java.lang.String[] getServices(java.lang.String catlabel)
          Return the services list for the specified category.
 double getWarning(java.lang.String catlabel)
          Return the warning value for the specified category.
static void init()
          Load the config from the default config file and create the singleton instance of this factory.
static void reload()
          Reload the config from the default config file
 boolean replaceCategory(java.lang.String groupname, Category cat)
          Replace category in a categorygroup.
 boolean replaceCategoryGroup(Categorygroup group)
          Replace categorygroup.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_singleton

private static CategoryFactory m_singleton
The singleton instance of this factory


m_config

private Catinfo m_config
The config class loaded from the config file


m_loaded

private static boolean m_loaded
This member is set to true if the configuration file has been loaded.

Constructor Detail

CategoryFactory

private CategoryFactory(java.lang.String configFile)
                 throws java.io.IOException,
                        org.exolab.castor.xml.MarshalException,
                        org.exolab.castor.xml.ValidationException
Private constructor

Throws:
java.io.IOException - Thrown if the specified config file cannot be read
org.exolab.castor.xml.MarshalException - Thrown if the file does not conform to the schema.
org.exolab.castor.xml.ValidationException - Thrown if the contents do not match the required schema.
Method Detail

init

public static void init()
                 throws java.io.IOException,
                        org.exolab.castor.xml.MarshalException,
                        org.exolab.castor.xml.ValidationException
Load the config from the default config file and create the singleton instance of this factory.

Throws:
java.io.IOException - Thrown if the specified config file cannot be read
org.exolab.castor.xml.MarshalException - Thrown if the file does not conform to the schema.
org.exolab.castor.xml.ValidationException - Thrown if the contents do not match the required schema.

reload

public static void reload()
                   throws java.io.IOException,
                          org.exolab.castor.xml.MarshalException,
                          org.exolab.castor.xml.ValidationException
Reload the config from the default config file

Throws:
java.io.IOException - Thrown if the specified config file cannot be read/loaded
org.exolab.castor.xml.MarshalException - Thrown if the file does not conform to the schema.
org.exolab.castor.xml.ValidationException - Thrown if the contents do not match the required schema.

getInstance

public static CategoryFactory getInstance()
Return the singleton instance of this factory.

Returns:
The current factory instance.
Throws:
java.lang.IllegalStateException - Thrown if the factory has not yet been initialized.

getConfig

public Catinfo getConfig()
Return the categories configuration.

Returns:
the categories configuration

addCategoryGroup

public void addCategoryGroup(Categorygroup group)
Add a categorygroup.

Parameters:
group - category group to be added

replaceCategoryGroup

public boolean replaceCategoryGroup(Categorygroup group)
Replace categorygroup.

Parameters:
group - category group to be replaced
Returns:
true if categorygroup is successfully replaced

deleteCategoryGroup

public boolean deleteCategoryGroup(Categorygroup group)
Delete a categorygroup.

Parameters:
group - category group to be removed
Returns:
true if categorygroup is successfully deleted

deleteCategoryGroup

public boolean deleteCategoryGroup(java.lang.String groupname)
Delete a categorygroup.

Parameters:
groupname - category group to be removed
Returns:
true if categorygroup is successfully deleted

addCategory

public boolean addCategory(java.lang.String groupname,
                           Category cat)
Add category to a categorygroup.

Parameters:
groupname - category group to which category is to be added
cat - category to be added
Returns:
true if category is successfully added to the specified category group

replaceCategory

public boolean replaceCategory(java.lang.String groupname,
                               Category cat)
Replace category in a categorygroup.

Parameters:
groupname - category group to which category is to be added
cat - category to be replaced
Returns:
true if category is successfully replaced in the specified category group

deleteCategory

public boolean deleteCategory(java.lang.String groupname,
                              Category cat)
Delete category from a categorygroup.

Parameters:
groupname - category group from which category is to be removed
cat - category to be deleted
Returns:
true if category is successfully deleted from the specified category group

deleteCategory

public boolean deleteCategory(java.lang.String groupname,
                              java.lang.String catlabel)
Delete category from a categorygroup.

Parameters:
groupname - category group from which category is to be removed
catlabel - label of the category to be deleted
Returns:
true if category is successfully deleted from the specified category group

getCategory

public Category getCategory(java.lang.String name)
Return the category specified by name.

Returns:
the category specified by name, null if not found

getNormal

public double getNormal(java.lang.String catlabel)
Return the normal value for the specified category.

Parameters:
catlabel - the label for the category whose normal value is needed
Returns:
the normal value for the specified category, -1 if category is not found

getWarning

public double getWarning(java.lang.String catlabel)
Return the warning value for the specified category.

Parameters:
catlabel - the label for the category whose warning value is needed
Returns:
the warning value for the specified category, -1 if category is not found

getServices

public java.lang.String[] getServices(java.lang.String catlabel)
Return the services list for the specified category.

Parameters:
catlabel - the label for the category whose services list is needed
Returns:
the services list for the specified category, null if category is not found

getRule

public java.lang.String getRule(java.lang.String catlabel)
Return the rule for the specified category.

Parameters:
catlabel - the label for the category whose services list is needed
Returns:
the rule for the specified category, null if the category is not found

getEffectiveRule

public java.lang.String getEffectiveRule(java.lang.String catlabel)
Return the effective rule for the specified category. The category rule ANDed with the rule of the category group that the category belongs to.

Parameters:
catlabel - the label for the category whose effective rule is needed
Returns:
the effective rule for the specified category, null if the category is not found

OpenNMS API 1.2.3

Generated by eevans on May 29 2005 2015.